Friday, August 27, 2021

Use of indicator variables along with year fixed effects in panel regression framework by employing xtreg versus reghdfe

Dear Stata members
First, thanks for this wonderful platform to ask queries and clear doubts. I have read a few threads and based on some of those threads, I am posting my doubts

Code:
* Example generated by -dataex-. For more info, type help dataex
clear
input long co_code int year float(lever_w size_w dummy trade_credit_w)
  11 2011    .5504084  7.692159 0      .0919173
  11 2012    .5697871  7.931967 0     .08887213
  11 2013    .5391156  8.025386 0     .06992412
  11 2014   .51597077  8.138857 0    .027474463
  11 2015    .4759782  8.160204 0    -.05730373
  11 2016    .4625662  8.169874 0    .008463308
  11 2017   .39045715  8.268808 1    .023023874
  11 2018   .33070305  8.310906 1    .018141583
  11 2019    .2839154  8.385649 1      .0127974
 289 2011   .54094803  7.413488 0      .3342782
 289 2012    .5555683  7.465369 0     .28388202
 289 2013   .51333773  7.327781 0      .3884363
 289 2014   .48577145  7.207416 0      .4057359
 363 2011    .4761355  9.358657 0     .04327172
 363 2012    .4731195  9.282261 0    .065523885
 363 2013   .53195494  9.338382 0     .04692944
 363 2014    .4994195  9.323365 0 -.00004465878
 363 2015   .51551414   9.20133 0    .008859474
 363 2016    .5284721   9.21132 0    -.02343703
 363 2017    .5849603  9.158089 1    -.02696266
 363 2018    .4416465  9.171402 1     -.1686716
 363 2019     .689352   9.14435 1    .033798363
 414 2016    .4542443  6.180017 0     .40248445
 414 2017  .006420134  5.964607 1      .0811505
 414 2018  .005577936  5.776723 1       .213511
 415 2018           .  7.591811 1      .2690852
 415 2019           .  7.536204 1     .11372487
 771 2013    .4651715  6.630683 0     .18166228
 771 2014    .5203515  6.897806 0     .24957076
 771 2015     .461695  7.113387 0      .2509973
 771 2016    .5473848  7.495042 0      .2136068
 771 2017    .5459776  7.675732 1      .5205994
 771 2018    .4951338  7.772121 1      .5433114
 771 2019    .4645513  7.871731 1     .53449523
 783 2011   .19831736  7.452112 0      .1440673
 783 2012    .2092255  7.504777 0      .1442726
 783 2013   .19775394  7.699978 0      .1591269
 783 2014   .13007422  7.688272 0     .10547055
 783 2015   .08677534  7.688822 0     .13824525
 783 2016  .033318035  7.686621 0     .13262965
 783 2017  .025697127  7.672339 1     .13933243
 783 2018  .014560171  7.673084 1     .14108947
 783 2019 .0009790963  7.622028 1     .16375385
1120 2011  .016338103   9.46848 0     .17673732
1120 2012  .032134537   9.61161 0     .18890423
1120 2013   .08688986  9.826855 0     .12449393
1120 2014   .05394961 10.014935 0     .13960168
1120 2015   .03865692  10.14689 0     .12071372
1120 2016   .06567325 10.239388 0     .11970769
1120 2017     .043705  10.37602 1      .1161778
1120 2018   .03458266 10.482662 1     .12359595
1120 2019  .031668555 10.609154 1     .13287362
2248 2017    .1482503  7.934478 1     .05025253
2248 2018   .15626974   8.00933 1     .04204195
2717 2011    .3987688 10.212482 0     -.1650117
2717 2012    .5396248 10.179546 0    -.06461293
2717 2013     .521483 10.359493 0    -.11464672
2717 2014    .5139446 10.229534 0    -.05649667
2717 2015    .4747386  10.36415 0    -.08115133
2717 2016   .31001255 10.589538 0    -.11957822
2717 2017   .26234335 10.676764 1    -.10998888
2717 2018    .2209677  11.94411 1   -.032753333
2717 2019   .19191967 11.893708 1   -.008160293
2842 2011   .24950735  6.491785 0      .3027133
2842 2012    .3842184  6.770675 0      .3133387
2842 2013    .3622974  6.984253 0     .21834183
2842 2014    .3780394  7.066552 0      .2918693
2842 2015    .3651952  7.071573 0     .27504244
2842 2016   .19154836  6.804171 0      .3693434
2842 2017  .012137886  6.426327 1      .2519825
2842 2018   .11468551  6.541318 1     .29500863
2842 2019    .1701168  6.762383 1      .2371921
3335 2011    .3992996  7.243656 0      .3574185
3335 2012    .1974824  7.581821 0      .1959026
3335 2013   .15542907  7.733684 0     .14128721
3335 2014   .02286336  7.778254 0     .07554123
3335 2015  .028543843  7.775822 0     .12504724
3335 2016   .03890818  7.826403 0      .1643721
3335 2017   .05525101  7.927613 1     .14483556
3335 2018   .10858244  8.108293 1      .0895572
3335 2019    .2077677 8.2735405 1     .14501888
3990 2011    .5109358  8.563141 0     .10884224
3990 2015    .4456229  9.215437 0      .1399847
3990 2016   .43831205  9.308274 0     .12745605
3990 2017    .4056455  9.385167 1      .0745315
3990 2018    .3955588   9.53976 1     .07392676
3990 2019    .3502277  9.585972 1     .14768772
3998 2011   .37776425  9.546169 0     .15586448
3998 2012    .3780212  9.717851 0      .1495952
3998 2013   .39086115  9.987824 0     .10335066
3998 2014    .3920296 10.192468 0     .03823784
3998 2015     .409129  10.28826 0     .07513884
3998 2016    .4354037 10.297828 0     .07631767
3998 2017    .4468606 10.463384 1     .06948911
3998 2018    .4743695     10.69 1     .07081716
3998 2019    .4099103 10.978138 1     .08838603
4024 2018    .4125189  9.126492 1     .09601225
4024 2019    .4504824  9.173573 1     .09431474
4030 2016   .17944816   6.26435 0      .3450047
4030 2017    .1738609  6.726233 1     .27482015
end
Code:
**Here Dummmy takes the value 1 if year falls in range 2017-2019 and 0 otherwise
**Setting the panel 
xtset co_code year

*1. Running regression with firm and year fixed effects (xtreg)
xtreg lever_w dummy i.year,fe vce(r)
/*. xtreg lever_w dummy i.year,fe vce(r)
note: 2019.year omitted because of collinearity.

Fixed-effects (within) regression               Number of obs     =         98
Group variable: co_code                         Number of groups  =         15

R-squared:                                      Obs per group:
     Within  = 0.2477                                         min =          2
     Between = 0.0748                                         avg =        6.5
     Overall = 0.0669                                         max =          9

                                                F(8,14)           =       1.78
corr(u_i, Xb) = 0.0080                          Prob > F          =     0.1639

                               (Std. err. adjusted for 15 clusters in co_code)
------------------------------------------------------------------------------
             |               Robust
     lever_w | Coefficient  std. err.      t    P>|t|     [95% conf. interval]
-------------+----------------------------------------------------------------
       dummy |  -.0949773   .0485165    -1.96   0.071    -.1990348    .0090803
             |
        year |
       2012  |   .0128236   .0322462     0.40   0.697    -.0563376    .0819848
       2013  |  -.0024029   .0361445    -0.07   0.948    -.0799252    .0751194
       2014  |   -.027591   .0464378    -0.59   0.562    -.1271902    .0720083
       2015  |  -.0452929   .0456127    -0.99   0.338    -.1431224    .0525365
       2016  |  -.0478451   .0488754    -0.98   0.344    -.1526725    .0569822
       2017  |  -.0147827   .0322477    -0.46   0.654    -.0839471    .0543817
       2018  |  -.0287685   .0300549    -0.96   0.355    -.0932299     .035693
       2019  |          0  (omitted)
             |
       _cons |   .3690917   .0315912    11.68   0.000     .3013354     .436848
-------------+----------------------------------------------------------------
     sigma_u |  .16558787
     sigma_e |  .08819011
         rho |  .77902858   (fraction of variance due to u_i)
------------------------------------------------------------------------------

*/
*2. Running regression with firm and year fixed effects by using user written command reghdfe without absorbing 
reghdfe lever_w dummy i.year i.co_code , noabsorb vce(r)
/*

. reghdfe lever_w dummy i.year i.co_code , noabsorb vce(r)
(MWFE estimator converged in 1 iterations)
note: 2019.year omitted because of collinearity

HDFE Linear regression                            Number of obs   =         98
Absorbing 1 HDFE group                            F(  22,     75) =      96.26
                                                  Prob > F        =     0.0000
                                                  R-squared       =     0.8369
                                                  Adj R-squared   =     0.7890
                                                  Within R-sq.    =     0.8369
                                                  Root MSE        =     0.0882

------------------------------------------------------------------------------
             |               Robust
     lever_w | Coefficient  std. err.      t    P>|t|     [95% conf. interval]
-------------+----------------------------------------------------------------
       dummy |  -.0949773   .0484797    -1.96   0.054    -.1915539    .0015993
             |
        year |
       2012  |   .0128236   .0427197     0.30   0.765    -.0722784    .0979257
       2013  |  -.0024029   .0383865    -0.06   0.950    -.0788729     .074067
       2014  |   -.027591   .0412448    -0.67   0.506    -.1097548    .0545729
       2015  |  -.0452929   .0395357    -1.15   0.256    -.1240521    .0334662
       2016  |  -.0478451   .0405997    -1.18   0.242    -.1287239    .0330336
       2017  |  -.0147827   .0453062    -0.33   0.745    -.1050373    .0754719
       2018  |  -.0287685   .0404742    -0.71   0.479    -.1093971    .0518602
       2019  |          0  (omitted)
             |
     co_code |
        289  |   .0217886   .0238414     0.91   0.364     -.025706    .0692832
        363  |   .0690747   .0424434     1.63   0.108    -.0154769    .1536264
        414  |  -.2572126   .1201764    -2.14   0.036    -.4966163   -.0178089
        771  |    .058144   .0336722     1.73   0.088    -.0089344    .1252224
        783  |  -.3580223   .0259388   -13.80   0.000    -.4096951   -.3063496
       1120  |  -.4128115    .027637   -14.94   0.000    -.4678672   -.3577558
       2248  |  -.2373975   .0281001    -8.45   0.000    -.2933757   -.1814193
       2717  |  -.0761221   .0406344    -1.87   0.065    -.1570699    .0048257
       2842  |  -.2101284   .0405275    -5.18   0.000    -.2908633   -.1293935
       3335  |  -.3227527   .0457242    -7.06   0.000      -.41384   -.2316654
       3990  |  -.0117564   .0250256    -0.47   0.640    -.0616099    .0380971
       3998  |  -.0449503   .0357334    -1.26   0.212    -.1161349    .0262343
       4024  |   .0344518   .0316169     1.09   0.279    -.0285323    .0974359
       4030  |  -.2509533   .0336681    -7.45   0.000    -.3180236    -.183883
             |
       _cons |   .5064104   .0359909    14.07   0.000     .4347129    .5781079
------------------------------------------------------------------------------
*/



*3. Running regression with firm and year fixed effects (reghdfe) with absorbing co_codes only
reghdfe lever_w dummy i.year, a(co_code ) vce(r)  
/*

. reghdfe lever_w dummy i.year, a(co_code ) vce(r)
(MWFE estimator converged in 1 iterations)
note: 2019.year omitted because of collinearity

HDFE Linear regression                            Number of obs   =         98
Absorbing 1 HDFE group                            F(   8,     75) =       3.00
                                                  Prob > F        =     0.0057
                                                  R-squared       =     0.8369
                                                  Adj R-squared   =     0.7890
                                                  Within R-sq.    =     0.2477
                                                  Root MSE        =     0.0882

------------------------------------------------------------------------------
             |               Robust
     lever_w | Coefficient  std. err.      t    P>|t|     [95% conf. interval]
-------------+----------------------------------------------------------------
       dummy |  -.0949773   .0484797    -1.96   0.054    -.1915539    .0015993
             |
        year |
       2012  |   .0128236   .0427197     0.30   0.765    -.0722784    .0979257
       2013  |  -.0024029   .0383865    -0.06   0.950    -.0788729     .074067
       2014  |   -.027591   .0412448    -0.67   0.506    -.1097548    .0545729
       2015  |  -.0452929   .0395357    -1.15   0.256    -.1240521    .0334662
       2016  |  -.0478451   .0405997    -1.18   0.242    -.1287239    .0330336
       2017  |  -.0147827   .0453062    -0.33   0.745    -.1050373    .0754719
       2018  |  -.0287685   .0404742    -0.71   0.479    -.1093971    .0518602
       2019  |          0  (omitted)
             |
       _cons |   .3690917   .0327578    11.27   0.000     .3038348    .4343486
------------------------------------------------------------------------------

Absorbed degrees of freedom:
-----------------------------------------------------+
 Absorbed FE | Categories  - Redundant  = Num. Coefs |
-------------+---------------------------------------|
     co_code |        15           0          15     |
-----------------------------------------------------+
*/

*4. Running regression with firm and year fixed effects (reghdfe) with absorbing both co_codes and year

reghdfe lever_w dummy , a(co_code year ) vce(r) 
/*
reghdfe lever_w dummy , a(co_code year ) vce(r)  //absorbing co_codes and year 
note: dummy is probably collinear with the fixed effects (all partialled-out values are close to zero; tol = 1.0e-
> 09)
(MWFE estimator converged in 6 iterations)
note: dummy omitted because of collinearity

HDFE Linear regression                            Number of obs   =         98
Absorbing 2 HDFE groups                           F(   0,     75) =          .
                                                  Prob > F        =          .
                                                  R-squared       =     0.8369
                                                  Adj R-squared   =     0.7890
                                                  Within R-sq.    =     0.0000
                                                  Root MSE        =     0.0882

------------------------------------------------------------------------------
             |               Robust
     lever_w | Coefficient  std. err.      t    P>|t|     [95% conf. interval]
-------------+----------------------------------------------------------------
       dummy |          0  (omitted)
       _cons |   .3150925   .0089085    35.37   0.000     .2973458    .3328393
------------------------------------------------------------------------------

Absorbed degrees of freedom:
-----------------------------------------------------+
 Absorbed FE | Categories  - Redundant  = Num. Coefs |
-------------+---------------------------------------|
     co_code |        15           0          15     |
        year |         9           1           8     |
-----------------------------------------------------+

. 
*/
My Doubts
1. Why the year 2019 got omitted in 1,2, &3? Is it to avoid the issue of dummy variable trap? Why 2019 and not some other year?
2. Point estimates of 1 & 2 are the same but robust standard errors are different, why is it so?
3. What is the difference between 3 & 4? Why 'dummy' variable got omitted in (4) which was there in 2 & 3.
4. When and under what conditions we should invoke the 'absorb' option
5. Finally, if it makes sense to say a 'good estimation method' in the above, which one is it? Apologies for such a mundane question

Can someone take the trouble to help me here?

No comments:

Post a Comment