I'm trying to understand how `areg` works. I'm attempting to replicate it - I'm able to get the expected coefficients, but different standard errors. What am I missing?
Code:
. sysuse auto, clear
(1978 automobile data)
. drop if missing(rep78)
(5 observations deleted)
.
.
. reg mpg weight gear_ratio i.rep78
Source | SS df MS Number of obs = 69
-------------+---------------------------------- F(6, 62) = 21.31
Model | 1575.97621 6 262.662702 Prob > F = 0.0000
Residual | 764.226686 62 12.3262369 R-squared = 0.6734
-------------+---------------------------------- Adj R-squared = 0.6418
Total | 2340.2029 68 34.4147485 Root MSE = 3.5109
------------------------------------------------------------------------------
mpg | Coefficient Std. err. t P>|t| [95% conf. interval]
-------------+----------------------------------------------------------------
weight | -.0051031 .0009206 -5.54 0.000 -.0069433 -.003263
gear_ratio | .901478 1.565552 0.58 0.567 -2.228015 4.030971
|
rep78 |
2 | -.3828844 2.784787 -0.14 0.891 -5.949594 5.183825
3 | -.5204951 2.568204 -0.20 0.840 -5.654262 4.613272
4 | -.7514522 2.633873 -0.29 0.776 -6.01649 4.513585
5 | 2.036937 2.740728 0.74 0.460 -3.4417 7.515574
|
_cons | 34.20089 7.387405 4.63 0.000 19.43367 48.9681
------------------------------------------------------------------------------
. areg mpg weight gear_ratio, absorb(rep78)
Linear regression, absorbing indicators Number of obs = 69
Absorbed variable: rep78 No. of categories = 5
F(2, 62) = 41.64
Prob > F = 0.0000
R-squared = 0.6734
Adj R-squared = 0.6418
Root MSE = 3.5109
------------------------------------------------------------------------------
mpg | Coefficient Std. err. t P>|t| [95% conf. interval]
-------------+----------------------------------------------------------------
weight | -.0051031 .0009206 -5.54 0.000 -.0069433 -.003263
gear_ratio | .901478 1.565552 0.58 0.567 -2.228015 4.030971
_cons | 34.05889 7.056383 4.83 0.000 19.95338 48.1644
------------------------------------------------------------------------------
F test of absorbed indicators: F(4, 62) = 1.117 Prob > F = 0.356
.
. foreach var of varlist mpg weight gear_ratio {
2. egen mean`var' = mean(`var'), by(rep78)
3. egen mean`var'overall = mean(`var')
4. gen `var'c = `var' - mean`var' + mean`var'overall
5. drop mean`var' mean`var'overall
6. }
. reg mpgc weightc gear_ratioc
Source | SS df MS Number of obs = 69
-------------+---------------------------------- F(2, 66) = 44.33
Model | 1026.56042 2 513.280211 Prob > F = 0.0000
Residual | 764.226699 66 11.5791924 R-squared = 0.5732
-------------+---------------------------------- Adj R-squared = 0.5603
Total | 1790.78712 68 26.3351047 Root MSE = 3.4028
------------------------------------------------------------------------------
mpgc | Coefficient Std. err. t P>|t| [95% conf. interval]
-------------+----------------------------------------------------------------
weightc | -.0051031 .0008922 -5.72 0.000 -.0068845 -.0033217
gear_ratioc | .9014782 1.517369 0.59 0.554 -2.128047 3.931004
_cons | 34.05889 6.839212 4.98 0.000 20.40396 47.71382
------------------------------------------------------------------------------

Comment