<blockquote>
<p>Should we expect the regression on individual and aggregated data to be the same?</p>
</blockquote>
<p>Not necessarily. One reason is that data may be aggregated in more than one way, and different aggregations may yield different results, a phenomenon known, for spatial aggregation, as the <a href="https://en.wikipedia.org/wiki/Modifiable_areal_unit_problem" rel="nofollow noreferrer">modifiable areal unit problem</a>. If different aggregations lead to different results, then some at least must yield different results to the individual data.</p>

CC BY-SA 4.0
2023-03-31T13:18:37.500Z
2023-03-31T21:09:37.677Z
2023-03-31T21:09:37.677Z
Adam Bailey
<p>In general, regressing at the individual level does not guarantee the same results as at the group level. The results may be the same, depending on how the data was collapsed, but not always.</p>
<p>However, there may be different reasons to regress at the grouped/collapsed level instead of individual.</p>
<p>One reason may be as a robustness check in addition to the individual level regression.</p>
<p>A very common reason, is when the variable of interest, such as the treatment, only varies at the group level and not individual level.</p>
<p>In that case, there is no meaningful individual-level variation for the research question in hand. Since the variable of interest would take the same value for all individuals in one group and a different value for all individuals in another group, all the variation is at the group level.</p>
<p>A danger in that case, an individual level regression would overestimate significance (underestimate standard errors), because you are using more observations, which drives down standard errors, but in fact those observations are meaningless duplicates as far as the variable of interest (e.g. treatment) is concerned. This could be partially addressed with clustering standard errors by group.</p>
<p>As an example, suppose you are analyzing a policy that affects all people in one county and want to compare it to non-treated counties. Then the main variable you are interested in - the treatment - does not vary by each person in that county. The treatment variable has the same value for each individual in any county, so you should collapse by county before regressing.</p>
<p>Another point to consider here is that you may want to do a weighted collapse before the regression, so your collapsed group is more representative. For example, instead of collapsing all firms in a group (e.g. county) and regressing on the average for all firms, you might want to weight the firms by size. That's because larger firms account for a larger share of economic activity, so it may make sense to give them a higher weight than smaller firms, instead of just treating all firms equal in the collapse.</p>

CC BY-SA 4.0
2023-04-01T09:48:33.877Z
Thanks! Are we overestimating significance though? We want to study the impact of a shock on the outcomes of people. It's not clear to me the unit of observation should be the aggregate. The group-level treatment may be the same, but the outcome varies within group. When we collapse we loose the within-group variation.
Papayapap
CC BY-SA 4.0
2023-04-01T14:09:31.810Z
Yes but there’s no meaningful within-group variation if your variable of interest (e.g. treatment) doesn’t vary within groups.
BB King
CC BY-SA 4.0
2023-03-31T13:16:58.803Z
2023-03-31T13:40:58.360Z
2023-03-31T13:40:58.360Z
BB King
<p><strong>EDIT</strong>: Clearly, the controls were the problem. Without controls, this works fine, but with controls not. We are starting to learn that including controls linearly is not as innocuous as one might think. See for example <a href="https://direct.mit.edu/rest/article/104/3/501/97692/Interpreting-OLS-Estimands-When-Treatment-Effects" rel="nofollow noreferrer">Słoczyński (2022)</a>.</p>
<p><a href="https://ucd34319790bb5e941d8f1c352c3.dl.dropboxusercontent.com/cd/0/inline2/B5Wvy75uACw18HbRUP2-k7qKaLht9LUEJlzAQgMKBk3sNcro5uB1S5CW8ggDRpbWnjc6JomIkIMn0OM_hWfYFjtfbaLHvWRfoFc8Fn4bTaRQ580toD9bgJEuHbXM2uIgpbYrOr1FmIJbeRpyhIMrYd7qI1EH7I19AB7y1Sq9BUML6x6foTC4JuPWBP3qV4sWtUkhbv41yNSiXrk6jqOcW2mTH5na-9YocPUlcYJUpLlOd7x90qPWMp7gVsHwVtb8mGMr1JpUQ6VuHFMJ5iIh-dvvYnRydh6vRf0BnirdaRUX0Q2uXMvYRhkMw0PhVkVpoKuquuNcW8o_eTyYwQx7Y0Gm-td9NDB5HL4vm3nFr96qdtG0V46rE_Sirr3Bp3gwCENRZc6IXIMjeto7wb2N39IlTI32FjBOm-L_VMFhw44HEw/file" rel="nofollow noreferrer">Peter Hull's slides</a> include a section on this, I guess taken from MHE, which argues that if the treatment varies only at the group-level, a weighted regression on means at the group level should give the same results as the micro-level regression (without controls!).</p>
<p><a href="https://i.sstatic.net/apdpk.png" rel="nofollow noreferrer"><img src="https://i.sstatic.net/apdpk.png" alt="enter image description here" /></a></p>
<p><a href="https://i.sstatic.net/30TGX.png" rel="nofollow noreferrer"><img src="https://i.sstatic.net/30TGX.png" alt="enter image description here" /></a></p>
<p>Maybe it has to do with the controls? I can update my code to get a count-weighted regression at the micro- and group-level to deliver the same results without controls (see 4. in the code), but not with the original example that included controls.</p>
<pre><code>** make some random data
set seed 35135
clear
set obs 1000
gen state = ceil(_n/100)
gen shock = runiformint(0,1000)
bysort state (shock): replace shock = shock[_N]
gen wage = abs(int(rnormal() * 1000))
gen age = floor(abs(rlogistic()) * 15 + abs(rlogistic() * 5))


** 1. individual data
gen age2 = age^2
gen ln_wage = ln(wage)

reg ln_wage age age2 shock
reg ln_wage age age2 shock i.state

** 2. aggregated data
preserve 
    collapse (mean) wage age shock (count) count=wage, by(state)
    gen age2 = age^2
    gen ln_wage = ln(wage)

    reg ln_wage age age2 shock [aweight=count]
restore

** 3. transform before collapsing
preserve
    collapse (mean) ln_wage age age2 shock (count) count=wage, by(state)
    reg ln_wage age age2 shock [aweight=count]
restore


** 4. without contrals 
reg wage shock
collapse (mean) wage shock (count) count=wage, by(state)
reg wage shock [aweight=count]
</code></pre>

CC BY-SA 4.0
2023-04-01T12:28:20.143Z
2023-06-23T07:54:17.837Z
2023-06-23T07:54:17.837Z
Papayapap
<p>Lots of analysis in the US collapse CPS or Census data and run regressions on the group means. I wonder why not run the regression on the individual data? Absent measurement error, should we expect the regression on individual and aggregated data to be the same?</p>
<p>Here is a Stata example with random data where the regressions at the individual level or on the means seem to deliver different estimates.</p>
<p><strong>EDIT:</strong></p>
<p>Following BB King's comments, I changed the example to include a &quot;shock&quot; at the group level. In this case, it seems like the individual regression 1. and the collapsing on transformed data regression 3. do deliver similar results absent covariates. Is this a general result?</p>
<pre><code>** make some random data
set seed 35135
clear
set obs 1000
gen state = ceil(_n/100)
gen shock = runiformint(0,1000)
bysort state (shock): replace shock = shock[_N]
gen wage = abs(int(rnormal() * 1000))
gen age = floor(abs(rlogistic()) * 15 + abs(rlogistic() * 5))


** 1. individual data
gen age2 = age^2
gen ln_wage = ln(wage)

reg ln_wage age age2 shock
reg ln_wage age age2 shock i.state

** 2. aggregated data
preserve 
    collapse (mean) wage age shock, by(state)
    gen age2 = age^2
    gen ln_wage = ln(wage)

    reg ln_wage age age2 shock
restore

** 3. transform before collapsing
collapse (mean) ln_wage age age2 shock, by(state)
reg ln_wage age age2 shock
</code></pre>

CC BY-SA 4.0
2023-03-30T13:21:04.380Z
I think the answer will depend on the research question and empirical strategy, so more context would be useful.
BB King
CC BY-SA 4.0
2023-03-30T15:18:40.700Z
Not sure. I am asking in general about the difference between a regression on individual data, versus a regression on the group and whether the two give the same result. As an example, I am making up some state-level wage data to run a Mincer regression.
Papayapap
CC BY-SA 4.0
2023-03-30T16:28:40.330Z
So in general they do not guarantee the same results. But if you're asking why some people do them at collapsed level instead of individual, it will depend on the context on what they want. It could be a robustness check, or it could be that the variation of their treatment is only at the group level and not individual level, so there is no meaningful individual-level variation. Suppose you are analyzing the policy that affects all people in one county- then the main variable you are interested in does not vary by person in that county- its all the same value - so you collapse by county.
BB King
CC BY-SA 4.0
2023-03-31T07:13:06.277Z
That's a good point. In the literature I am thinking about, indeed, the "treatment" is at the group level.
Papayapap
CC BY-SA 4.0
2023-03-31T13:06:01.717Z
Ok since this is helpful, let me put it as an answer.
BB King
<regression><stata><data><economic-measurement>
Regression on individual vs collapsed data
Papayapap
# Regression on individual vs collapsed data

(Asked by: username_0 on 2023-03-30)

Lots of analysis in the US collapse CPS or Census data and run regressions on the group means. I wonder why not run the regression on the individual data? Absent measurement error, should we expect the regression on individual and aggregated data to be the same?
Here is a Stata example with random data where the regressions at the individual level or on the means seem to deliver different estimates.
EDIT:
Following username_1's comments, I changed the example to include a "shock" at the group level. In this case, it seems like the individual regression 1. and the collapsing on transformed data regression 3. do deliver similar results absent covariates. Is this a general result?
** make some random data
set seed 35135
clear
set obs 1000
gen state = ceil(_n/100)
gen shock = runiformint(0,1000)
bysort state (shock): replace shock = shock[_N]
gen wage = abs(int(rnormal() * 1000))
gen age = floor(abs(rlogistic()) * 15 + abs(rlogistic() * 5))


** 1. individual data
gen age2 = age^2
gen ln_wage = ln(wage)

reg ln_wage age age2 shock
reg ln_wage age age2 shock i.state

** 2. aggregated data
preserve 
    collapse (mean) wage age shock, by(state)
    gen age2 = age^2
    gen ln_wage = ln(wage)

    reg ln_wage age age2 shock
restore

** 3. transform before collapsing
collapse (mean) ln_wage age age2 shock, by(state)
reg ln_wage age age2 shock

**Tags:** regression, stata, data, economic-measurement

> **Comments:**
> **username_1**: I think the answer will depend on the research question and empirical strategy, so more context would be useful.  
> **username_0**: Not sure. I am asking in general about the difference between a regression on individual data, versus a regression on the group and whether the two give the same result. As an example, I am making up some state-level wage data to run a Mincer regression.  
> **username_1**: So in general they do not guarantee the same results. But if you're asking why some people do them at collapsed level instead of individual, it will depend on the context on what they want. It could be a robustness check, or it could be that the variation of their treatment is only at the group level and not individual level, so there is no meaningful individual-level variation. Suppose you are analyzing the policy that affects all people in one county- then the main variable you are interested in does not vary by person in that county- its all the same value - so you collapse by county.  
> **username_0**: That's a good point. In the literature I am thinking about, indeed, the "treatment" is at the group level.  
> **username_1**: Ok since this is helpful, let me put it as an answer.  

---

## 3 answers

### Answer by username_0 on 2023-04-01. Score: 4 | Accepted answer

EDIT: Clearly, the controls were the problem. Without controls, this works fine, but with controls not. We are starting to learn that including controls linearly is not as innocuous as one might think. See for example Słoczyński (2022).
Peter Hull's slides include a section on this, I guess taken from MHE, which argues that if the treatment varies only at the group-level, a weighted regression on means at the group level should give the same results as the micro-level regression (without controls!).


Maybe it has to do with the controls? I can update my code to get a count-weighted regression at the micro- and group-level to deliver the same results without controls (see 4. in the code), but not with the original example that included controls.
** make some random data
set seed 35135
clear
set obs 1000
gen state = ceil(_n/100)
gen shock = runiformint(0,1000)
bysort state (shock): replace shock = shock[_N]
gen wage = abs(int(rnormal() * 1000))
gen age = floor(abs(rlogistic()) * 15 + abs(rlogistic() * 5))


** 1. individual data
gen age2 = age^2
gen ln_wage = ln(wage)

reg ln_wage age age2 shock
reg ln_wage age age2 shock i.state

** 2. aggregated data
preserve 
    collapse (mean) wage age shock (count) count=wage, by(state)
    gen age2 = age^2
    gen ln_wage = ln(wage)

    reg ln_wage age age2 shock [aweight=count]
restore

** 3. transform before collapsing
preserve
    collapse (mean) ln_wage age age2 shock (count) count=wage, by(state)
    reg ln_wage age age2 shock [aweight=count]
restore


** 4. without contrals 
reg wage shock
collapse (mean) wage shock (count) count=wage, by(state)
reg wage shock [aweight=count]


---

### Answer by username_2 on 2023-03-31. Score: 4

> Should we expect the regression on individual and aggregated data to be the same?

Not necessarily. One reason is that data may be aggregated in more than one way, and different aggregations may yield different results, a phenomenon known, for spatial aggregation, as the [modifiable areal unit problem](https://en.wikipedia.org/wiki/Modifiable_areal_unit_problem). If different aggregations lead to different results, then some at least must yield different results to the individual data.


---

### Answer by username_1 on 2023-03-31. Score: 4

In general, regressing at the individual level does not guarantee the same results as at the group level. The results may be the same, depending on how the data was collapsed, but not always.

However, there may be different reasons to regress at the grouped/collapsed level instead of individual.

One reason may be as a robustness check in addition to the individual level regression.

A very common reason, is when the variable of interest, such as the treatment, only varies at the group level and not individual level.

In that case, there is no meaningful individual-level variation for the research question in hand. Since the variable of interest would take the same value for all individuals in one group and a different value for all individuals in another group, all the variation is at the group level.

A danger in that case, an individual level regression would overestimate significance (underestimate standard errors), because you are using more observations, which drives down standard errors, but in fact those observations are meaningless duplicates as far as the variable of interest (e.g. treatment) is concerned. This could be partially addressed with clustering standard errors by group.

As an example, suppose you are analyzing a policy that affects all people in one county and want to compare it to non-treated counties. Then the main variable you are interested in - the treatment - does not vary by each person in that county. The treatment variable has the same value for each individual in any county, so you should collapse by county before regressing.

Another point to consider here is that you may want to do a weighted collapse before the regression, so your collapsed group is more representative. For example, instead of collapsing all firms in a group (e.g. county) and regressing on the average for all firms, you might want to weight the firms by size. That's because larger firms account for a larger share of economic activity, so it may make sense to give them a higher weight than smaller firms, instead of just treating all firms equal in the collapse.

> **Comments:**
> **username_0**: Thanks! Are we overestimating significance though? We want to study the impact of a shock on the outcomes of people. It's not clear to me the unit of observation should be the aggregate. The group-level treatment may be the same, but the outcome varies within group. When we collapse we loose the within-group variation.  
> **username_1**: Yes but there’s no meaningful within-group variation if your variable of interest (e.g. treatment) doesn’t vary within groups.  

---

