Announcement

Collapse
No announcement yet.
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • Appropriate error term for TWFE Regression

    Hello -

    I am working with a panel data of n = 23 countries and t = 27 years. I have run an "xtreg y x1... x7 i.year, fe" model, but when I include "robust" standard errors, my variables are no longer statistically significant. I have tried to use vce(cluster country1) and vce(robust) to account for heteroskedasticity and autocorrelation, but that is also leading to surprising results where well established variables are not appearing to be significant.

    I would be grateful for any advice or suggestions.


    xtreg ln_emissions ln_population ln_GDP ln_urban ln_energyi ln_energyc ln_freigh
    > t ln_passenger i.year, fe vce(conventional)

    Fixed-effects (within) regression Number of obs = 644
    Group variable: country1 Number of groups = 23

    R-squared: Obs per group:
    Within = 0.7975 min = 28
    Between = 0.9367 avg = 28.0
    Overall = 0.8924 max = 28

    F(34, 587) = 68.01
    corr(u_i, Xb) = 0.8698 Prob > F = 0.0000

    -------------------------------------------------------------------------------
    ln_emissions | Coefficient Std. err. t P>|t| [95% conf. interval]
    --------------+----------------------------------------------------------------
    ln_population | -.0337926 .0835744 -0.40 0.686 -.1979338 .1303485
    ln_GDP | .6707038 .0623552 10.76 0.000 .5482373 .7931703
    ln_urban | -.6823813 .1379903 -4.95 0.000 -.953396 -.4113665
    ln_energyi | .2863301 .0567451 5.05 0.000 .174882 .3977783
    ln_energyc | .6587665 .1141716 5.77 0.000 .434532 .883001
    ln_freight | .0753019 .0154509 4.87 0.000 .044956 .1056477
    ln_passenger | .2911854 .0328459 8.87 0.000 .2266756 .3556952
    |
    year |
    1996 | .0212138 .0236724 0.90 0.371 -.0252791 .0677067
    1997 | .0225933 .0237727 0.95 0.342 -.0240966 .0692831
    1998 | .0375484 .0239838 1.57 0.118 -.0095561 .0846529
    1999 | .0229932 .0242705 0.95 0.344 -.0246743 .0706608
    2000 | .0058723 .0246496 0.24 0.812 -.0425398 .0542844
    2001 | .0277172 .0250404 1.11 0.269 -.0214624 .0768968
    2002 | .032074 .0254849 1.26 0.209 -.0179788 .0821267
    2003 | .0351375 .0260637 1.35 0.178 -.016052 .0863271
    2004 | .0396721 .0268454 1.48 0.140 -.0130525 .0923968
    2005 | .0420939 .0276458 1.52 0.128 -.0122029 .0963906
    2006 | .045472 .0286576 1.59 0.113 -.0108119 .101756
    2007 | .0555367 .0297042 1.87 0.062 -.0028028 .1138762
    2008 | .0557996 .0300856 1.85 0.064 -.003289 .1148882
    2009 | .0711214 .0294516 2.41 0.016 .013278 .1289647
    2010 | .0555851 .0297598 1.87 0.062 -.0028636 .1140337
    2011 | .0379912 .0302558 1.26 0.210 -.0214316 .097414
    2012 | .0231495 .0305849 0.76 0.449 -.0369197 .0832188
    2013 | .0108011 .0310587 0.35 0.728 -.0501985 .0718007
    2014 | .0285997 .0319254 0.90 0.371 -.0341021 .0913016
    2015 | .0412954 .0326392 1.27 0.206 -.0228084 .1053993
    2016 | .0457002 .0329293 1.39 0.166 -.0189734 .1103737
    2017 | .0359183 .0338866 1.06 0.290 -.0306354 .1024721
    2018 | .0396046 .0348834 1.14 0.257 -.0289068 .108116
    2019 | .0416776 .0358788 1.16 0.246 -.0287889 .112144
    2020 | .0160818 .0359768 0.45 0.655 -.0545771 .0867406
    2021 | .0191024 .0373291 0.51 0.609 -.0542125 .0924173
    2022 | .0259837 .0385384 0.67 0.500 -.0497063 .1016736
    |
    _cons | 2.045922 1.183142 1.73 0.084 -.2777857 4.369629
    --------------+----------------------------------------------------------------
    sigma_u | .79042426
    sigma_e | .07992255
    rho | .98987953 (fraction of variance due to u_i)
    -------------------------------------------------------------------------------
    F test that all u_i=0: F(22, 587) = 60.71 Prob > F = 0.0000

    .
    . xtreg ln_emissions ln_population ln_GDP ln_urban ln_energyi ln_energyc ln_freigh
    > t ln_passenger i.year, fe robust

    Fixed-effects (within) regression Number of obs = 644
    Group variable: country1 Number of groups = 23

    R-squared: Obs per group:
    Within = 0.7975 min = 28
    Between = 0.9367 avg = 28.0
    Overall = 0.8924 max = 28

    F(22, 22) = .
    corr(u_i, Xb) = 0.8698 Prob > F = .

    (Std. err. adjusted for 23 clusters in country1)
    -------------------------------------------------------------------------------
    | Robust
    ln_emissions | Coefficient std. err. t P>|t| [95% conf. interval]
    --------------+----------------------------------------------------------------
    ln_population | -.0337926 .3019467 -0.11 0.912 -.6599918 .5924066
    ln_GDP | .6707038 .1556004 4.31 0.000 .3480084 .9933992
    ln_urban | -.6823813 .36935 -1.85 0.078 -1.448366 .0836038
    ln_energyi | .2863301 .112803 2.54 0.019 .052391 .5202693
    ln_energyc | .6587665 .4708758 1.40 0.176 -.3177701 1.635303
    ln_freight | .0753019 .054206 1.39 0.179 -.0371145 .1877183
    ln_passenger | .2911854 .109376 2.66 0.014 .0643534 .5180173
    |
    year |
    1996 | .0212138 .0166292 1.28 0.215 -.013273 .0557006
    1997 | .0225933 .0190104 1.19 0.247 -.016832 .0620185
    1998 | .0375484 .0290602 1.29 0.210 -.0227187 .0978155
    1999 | .0229932 .0326031 0.71 0.488 -.0446214 .0906079
    2000 | .0058723 .0349706 0.17 0.868 -.0666522 .0783968
    2001 | .0277172 .0379029 0.73 0.472 -.0508885 .1063229
    2002 | .032074 .0404138 0.79 0.436 -.0517392 .1158872
    2003 | .0351375 .0445973 0.79 0.439 -.0573516 .1276267
    2004 | .0396721 .0483981 0.82 0.421 -.0606994 .1400437
    2005 | .0420939 .0510843 0.82 0.419 -.0638486 .1480363
    2006 | .045472 .0521962 0.87 0.393 -.0627762 .1537203
    2007 | .0555367 .0554875 1.00 0.328 -.0595373 .1706107
    2008 | .0557996 .0553746 1.01 0.325 -.0590403 .1706394
    2009 | .0711214 .0534839 1.33 0.197 -.0397975 .1820403
    2010 | .0555851 .0524591 1.06 0.301 -.0532085 .1643786
    2011 | .0379912 .05559 0.68 0.501 -.0772954 .1532778
    2012 | .0231495 .0602469 0.38 0.704 -.101795 .148094
    2013 | .0108011 .0630046 0.17 0.865 -.1198625 .1414647
    2014 | .0285997 .0688644 0.42 0.682 -.1142163 .1714158
    2015 | .0412954 .0682816 0.60 0.552 -.1003119 .1829028
    2016 | .0457002 .0678447 0.67 0.508 -.0950012 .1864015
    2017 | .0359183 .0690491 0.52 0.608 -.1072808 .1791174
    2018 | .0396046 .0729832 0.54 0.593 -.1117534 .1909626
    2019 | .0416776 .0764724 0.55 0.591 -.1169164 .2002716
    2020 | .0160818 .077312 0.21 0.837 -.1442535 .176417
    2021 | .0191024 .0787538 0.24 0.811 -.144223 .1824279
    2022 | .0259837 .083765 0.31 0.759 -.1477344 .1997017
    |
    _cons | 2.045922 1.992457 1.03 0.316 -2.086181 6.178025
    --------------+----------------------------------------------------------------
    sigma_u | .79042426
    sigma_e | .07992255
    rho | .98987953 (fraction of variance due to u_i)
    -------------------------------------------------------------------------------

    .
    . xtreg ln_emissions ln_population ln_GDP ln_urban ln_energyi ln_energyc ln_freigh
    > t ln_passenger i.year, fe vce(robust)

    Fixed-effects (within) regression Number of obs = 644
    Group variable: country1 Number of groups = 23

    R-squared: Obs per group:
    Within = 0.7975 min = 28
    Between = 0.9367 avg = 28.0
    Overall = 0.8924 max = 28

    F(22, 22) = .
    corr(u_i, Xb) = 0.8698 Prob > F = .

    (Std. err. adjusted for 23 clusters in country1)
    -------------------------------------------------------------------------------
    | Robust
    ln_emissions | Coefficient std. err. t P>|t| [95% conf. interval]
    --------------+----------------------------------------------------------------
    ln_population | -.0337926 .3019467 -0.11 0.912 -.6599918 .5924066
    ln_GDP | .6707038 .1556004 4.31 0.000 .3480084 .9933992
    ln_urban | -.6823813 .36935 -1.85 0.078 -1.448366 .0836038
    ln_energyi | .2863301 .112803 2.54 0.019 .052391 .5202693
    ln_energyc | .6587665 .4708758 1.40 0.176 -.3177701 1.635303
    ln_freight | .0753019 .054206 1.39 0.179 -.0371145 .1877183
    ln_passenger | .2911854 .109376 2.66 0.014 .0643534 .5180173
    |
    year |
    1996 | .0212138 .0166292 1.28 0.215 -.013273 .0557006
    1997 | .0225933 .0190104 1.19 0.247 -.016832 .0620185
    1998 | .0375484 .0290602 1.29 0.210 -.0227187 .0978155
    1999 | .0229932 .0326031 0.71 0.488 -.0446214 .0906079
    2000 | .0058723 .0349706 0.17 0.868 -.0666522 .0783968
    2001 | .0277172 .0379029 0.73 0.472 -.0508885 .1063229
    2002 | .032074 .0404138 0.79 0.436 -.0517392 .1158872
    2003 | .0351375 .0445973 0.79 0.439 -.0573516 .1276267
    2004 | .0396721 .0483981 0.82 0.421 -.0606994 .1400437
    2005 | .0420939 .0510843 0.82 0.419 -.0638486 .1480363
    2006 | .045472 .0521962 0.87 0.393 -.0627762 .1537203
    2007 | .0555367 .0554875 1.00 0.328 -.0595373 .1706107
    2008 | .0557996 .0553746 1.01 0.325 -.0590403 .1706394
    2009 | .0711214 .0534839 1.33 0.197 -.0397975 .1820403
    2010 | .0555851 .0524591 1.06 0.301 -.0532085 .1643786
    2011 | .0379912 .05559 0.68 0.501 -.0772954 .1532778
    2012 | .0231495 .0602469 0.38 0.704 -.101795 .148094
    2013 | .0108011 .0630046 0.17 0.865 -.1198625 .1414647
    2014 | .0285997 .0688644 0.42 0.682 -.1142163 .1714158
    2015 | .0412954 .0682816 0.60 0.552 -.1003119 .1829028
    2016 | .0457002 .0678447 0.67 0.508 -.0950012 .1864015
    2017 | .0359183 .0690491 0.52 0.608 -.1072808 .1791174
    2018 | .0396046 .0729832 0.54 0.593 -.1117534 .1909626
    2019 | .0416776 .0764724 0.55 0.591 -.1169164 .2002716
    2020 | .0160818 .077312 0.21 0.837 -.1442535 .176417
    2021 | .0191024 .0787538 0.24 0.811 -.144223 .1824279
    2022 | .0259837 .083765 0.31 0.759 -.1477344 .1997017
    |
    _cons | 2.045922 1.992457 1.03 0.316 -2.086181 6.178025
    --------------+----------------------------------------------------------------
    sigma_u | .79042426
    sigma_e | .07992255
    rho | .98987953 (fraction of variance due to u_i)
    -------------------------------------------------------------------------------

    .
    . xtreg ln_emissions ln_population ln_GDP ln_urban ln_energyi ln_energyc ln_freigh
    > t ln_passenger i.year, fe vce(cluster country1)

    Fixed-effects (within) regression Number of obs = 644
    Group variable: country1 Number of groups = 23

    R-squared: Obs per group:
    Within = 0.7975 min = 28
    Between = 0.9367 avg = 28.0
    Overall = 0.8924 max = 28

    F(22, 22) = .
    corr(u_i, Xb) = 0.8698 Prob > F = .

    (Std. err. adjusted for 23 clusters in country1)
    -------------------------------------------------------------------------------
    | Robust
    ln_emissions | Coefficient std. err. t P>|t| [95% conf. interval]
    --------------+----------------------------------------------------------------
    ln_population | -.0337926 .3019467 -0.11 0.912 -.6599918 .5924066
    ln_GDP | .6707038 .1556004 4.31 0.000 .3480084 .9933992
    ln_urban | -.6823813 .36935 -1.85 0.078 -1.448366 .0836038
    ln_energyi | .2863301 .112803 2.54 0.019 .052391 .5202693
    ln_energyc | .6587665 .4708758 1.40 0.176 -.3177701 1.635303
    ln_freight | .0753019 .054206 1.39 0.179 -.0371145 .1877183
    ln_passenger | .2911854 .109376 2.66 0.014 .0643534 .5180173
    |
    year |
    1996 | .0212138 .0166292 1.28 0.215 -.013273 .0557006
    1997 | .0225933 .0190104 1.19 0.247 -.016832 .0620185
    1998 | .0375484 .0290602 1.29 0.210 -.0227187 .0978155
    1999 | .0229932 .0326031 0.71 0.488 -.0446214 .0906079
    2000 | .0058723 .0349706 0.17 0.868 -.0666522 .0783968
    2001 | .0277172 .0379029 0.73 0.472 -.0508885 .1063229
    2002 | .032074 .0404138 0.79 0.436 -.0517392 .1158872
    2003 | .0351375 .0445973 0.79 0.439 -.0573516 .1276267
    2004 | .0396721 .0483981 0.82 0.421 -.0606994 .1400437
    2005 | .0420939 .0510843 0.82 0.419 -.0638486 .1480363
    2006 | .045472 .0521962 0.87 0.393 -.0627762 .1537203
    2007 | .0555367 .0554875 1.00 0.328 -.0595373 .1706107
    2008 | .0557996 .0553746 1.01 0.325 -.0590403 .1706394
    2009 | .0711214 .0534839 1.33 0.197 -.0397975 .1820403
    2010 | .0555851 .0524591 1.06 0.301 -.0532085 .1643786
    2011 | .0379912 .05559 0.68 0.501 -.0772954 .1532778
    2012 | .0231495 .0602469 0.38 0.704 -.101795 .148094
    2013 | .0108011 .0630046 0.17 0.865 -.1198625 .1414647
    2014 | .0285997 .0688644 0.42 0.682 -.1142163 .1714158
    2015 | .0412954 .0682816 0.60 0.552 -.1003119 .1829028
    2016 | .0457002 .0678447 0.67 0.508 -.0950012 .1864015
    2017 | .0359183 .0690491 0.52 0.608 -.1072808 .1791174
    2018 | .0396046 .0729832 0.54 0.593 -.1117534 .1909626
    2019 | .0416776 .0764724 0.55 0.591 -.1169164 .2002716
    2020 | .0160818 .077312 0.21 0.837 -.1442535 .176417
    2021 | .0191024 .0787538 0.24 0.811 -.144223 .1824279
    2022 | .0259837 .083765 0.31 0.759 -.1477344 .1997017
    |
    _cons | 2.045922 1.992457 1.03 0.316 -2.086181 6.178025
    --------------+----------------------------------------------------------------
    sigma_u | .79042426
    sigma_e | .07992255
    rho | .98987953 (fraction of variance due to u_i)
    -------------------------------------------------------------------------------

    .
    . xtreg ln_emissions ln_population ln_GDP ln_urban ln_energyi ln_energyc ln_freigh
    > t ln_passenger i.year, fe vce(hc2 country1)

    Computing degrees of freedom ...

    Fixed-effects (within) regression Number of obs = 644
    Group variable: country1 Number of groups = 23

    R-squared: Obs per group:
    Within = 0.7975 min = 28
    Between = 0.9367 avg = 28.0
    Overall = 0.8924 max = 28

    F(23, 22) = .
    corr(u_i, Xb) = 0.8698 Prob > F = .

    (Std. err. adjusted for 23 clusters in country1)
    -------------------------------------------------------------------------------
    | Robust HC2
    ln_emissions | Coefficient std. err. t P>|t| [95% conf. interval]
    --------------+----------------------------------------------------------------
    ln_population | -.0337926 .3537916 -0.10 0.925 -.7675115 .6999263
    ln_GDP | .6707038 .1853579 3.62 0.002 .286295 1.055113
    ln_urban | -.6823813 .42527 -1.60 0.123 -1.564337 .1995746
    ln_energyi | .2863301 .129096 2.22 0.037 .0186015 .5540587
    ln_energyc | .6587665 .5648875 1.17 0.256 -.5127384 1.830271
    ln_freight | .0753019 .0618003 1.22 0.236 -.0528641 .2034678
    ln_passenger | .2911854 .1255014 2.32 0.030 .0309115 .5514593
    |
    year |
    1996 | .0212138 .0163743 1.30 0.209 -.0127444 .055172
    1997 | .0225933 .0188484 1.20 0.243 -.016496 .0616825
    1998 | .0375484 .0290171 1.29 0.209 -.0226295 .0977262
    1999 | .0229932 .0326513 0.70 0.489 -.0447213 .0907078
    2000 | .0058723 .0363021 0.16 0.873 -.0694137 .0811582
    2001 | .0277172 .0395199 0.70 0.490 -.0542421 .1096765
    2002 | .032074 .0424947 0.75 0.458 -.0560547 .1202027
    2003 | .0351375 .0465707 0.75 0.459 -.0614441 .1317192
    2004 | .0396721 .0508121 0.78 0.443 -.0657056 .1450499
    2005 | .0420939 .0540982 0.78 0.445 -.0700989 .1542866
    2006 | .045472 .0561603 0.81 0.427 -.0709973 .1619413
    2007 | .0555367 .0604622 0.92 0.368 -.0698542 .1809276
    2008 | .0557996 .0609454 0.92 0.370 -.0705935 .1821926
    2009 | .0711214 .05901 1.21 0.241 -.0512579 .1935006
    2010 | .0555851 .0582626 0.95 0.350 -.0652441 .1764142
    2011 | .0379912 .0626277 0.61 0.550 -.0918907 .1678731
    2012 | .0231495 .0677652 0.34 0.736 -.117387 .163686
    2013 | .0108011 .071034 0.15 0.881 -.1365143 .1581165
    2014 | .0285997 .0773641 0.37 0.715 -.1318437 .1890431
    2015 | .0412954 .0769903 0.54 0.597 -.1183727 .2009636
    2016 | .0457002 .0762284 0.60 0.555 -.112388 .2037883
    2017 | .0359183 .0779478 0.46 0.649 -.1257354 .1975721
    2018 | .0396046 .0828428 0.48 0.637 -.1322007 .21141
    2019 | .0416776 .0871142 0.48 0.637 -.1389863 .2223414
    2020 | .0160818 .0884969 0.18 0.857 -.1674497 .1996132
    2021 | .0191024 .0910732 0.21 0.836 -.1697718 .2079767
    2022 | .0259837 .0968669 0.27 0.791 -.1749059 .2268733
    |
    _cons | 2.045922 2.290856 0.89 0.381 -2.705023 6.796866
    --------------+----------------------------------------------------------------
    sigma_u | .79042426
    sigma_e | .07992255
    rho | .98987953 (fraction of variance due to u_i)
    -------------------------------------------------------------------------------
    Last edited by Conor Denis OMalley; 24 May 2025, 15:58.

  • #2
    robust and cluster (on the id) are the same in xtreg.

    from help: "Specifying vce(robust) is equivalent to specifying vce(cluster panelvar); see xtreg, re in Methods and formulas of
    [XT] xtreg."

    Comment


    • #3
      Conor:
      while 23 panels are probably not enough to be confident that bob-default standard errors work at their best, if you detected both heteroskedasticity and autocorrelation, you should definitely apply them and trust the resulting coefficients.
      Just out of curiosity: what does:
      Code:
      testparm i.year
      tell you?
      Kind regards,
      Carlo
      (Stata 19.0)

      Comment


      • #4
        I'd switch to reghdfe to absorb both id and year to clean up the output and save a few degrees of freedom.

        How correlated are the X's? A lot of level variables all scaling with GDP/pop.

        Comment

        Working...
        X