Announcement

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

  • Fixed effects regression

    Dear Stata Community,

    I am new to Stata and attempting to use the command reghdfe to run a fixed effects regression model.

    I have panel data and I am trying to identify if I have a problem with my model.

    From my understanding, model (1) has FUNDID and year fixed effects, while model (2) has FUNDID and industry-year fixed effects.

    I am not able to derive any meaningful results, is this due to an error in my Stata commands or my model?

    Thanks in advance

    Code:
    . gen did = post*buyout
    
    . 
    . xtset FUNDID year
    
    Panel variable: FUNDID (unbalanced)
     Time variable: year, 2004 to 2022, but with gaps
             Delta: 1 unit
    
    . 
    . reghdfe abnormal_return did FEDFUNDS CAPITALCALLED, absorb(FUNDID year) vce (cluster FUNDID)
    (MWFE estimator converged in 5 iterations)
    
    HDFE Linear regression                            Number of obs   =      6,798
    Absorbing 2 HDFE groups                           F(   3,    400) =       1.98
    Statistics robust to heteroskedasticity           Prob > F        =     0.1158
                                                      R-squared       =     0.7408
                                                      Adj R-squared   =     0.7237
                                                      Within R-sq.    =     0.0023
    Number of clusters (FUNDID)  =        401         Root MSE        =     8.9595
    
                                    (Std. err. adjusted for 401 clusters in FUNDID)
    -------------------------------------------------------------------------------
                  |               Robust
    abnormal_re~n | Coefficient  std. err.      t    P>|t|     [95% conf. interval]
    --------------+----------------------------------------------------------------
              did |   .1660538   .5897697     0.28   0.778    -.9933817    1.325489
         FEDFUNDS |  -.2892291   .2423715    -1.19   0.233    -.7657101     .187252
    CAPITALCALLED |   .0218505   .0391232     0.56   0.577    -.0550622    .0987632
            _cons |  -1.808622   3.930622    -0.46   0.646    -9.535882    5.918637
    -------------------------------------------------------------------------------
    
    Absorbed degrees of freedom:
    -----------------------------------------------------+
     Absorbed FE | Categories  - Redundant  = Num. Coefs |
    -------------+---------------------------------------|
          FUNDID |       401         401           0    *|
            year |        19           0          19     |
    -----------------------------------------------------+
    * = FE nested within cluster; treated as redundant for DoF computation
    
    . 
    . xtset FUNDID
    
    Panel variable: FUNDID (unbalanced)
    
    . 
    . egen industry_year = group(INDUSTRYCODE year)
    
    . 
    . reghdfe abnormal_return did FEDFUNDS CAPITALCALLED, absorb(FUNDID industry_year) vce (cluster FUNDID)
    (dropped 12 singleton observations)
    (MWFE estimator converged in 6 iterations)
    
    HDFE Linear regression                            Number of obs   =      6,786
    Absorbing 2 HDFE groups                           F(   3,    400) =       1.57
    Statistics robust to heteroskedasticity           Prob > F        =     0.1954
                                                      R-squared       =     0.7439
                                                      Adj R-squared   =     0.7175
                                                      Within R-sq.    =     0.0019
    Number of clusters (FUNDID)  =        401         Root MSE        =     9.0533
    
                                    (Std. err. adjusted for 401 clusters in FUNDID)
    -------------------------------------------------------------------------------
                  |               Robust
    abnormal_re~n | Coefficient  std. err.      t    P>|t|     [95% conf. interval]
    --------------+----------------------------------------------------------------
              did |   .2627558   .5985009     0.44   0.661    -.9138445    1.439356
         FEDFUNDS |  -.2742179   .2503795    -1.10   0.274     -.766442    .2180062
    CAPITALCALLED |   .0190326   .0399639     0.48   0.634    -.0595328    .0975981
            _cons |  -1.611685   4.010707    -0.40   0.688    -9.496384    6.273014
    -------------------------------------------------------------------------------
    
    Absorbed degrees of freedom:
    -------------------------------------------------------+
       Absorbed FE | Categories  - Redundant  = Num. Coefs |
    ---------------+---------------------------------------|
            FUNDID |       401         401           0    *|
     industry_year |       231           0         231     |
    -------------------------------------------------------+
    * = FE nested within cluster; treated as redundant for DoF computation

  • #2
    Luke:
    welcome to this forum.
    What if you type:
    Code:
     
     xtset FUNDID year xtreg abnormal_return did FEDFUNDS CAPITALCALLED i.year, fe vce(cluster FUNDID)
    Kind regards,
    Carlo
    (Stata 19.0)

    Comment


    • #3
      Hi Carlo,

      Doing so gives me the following output. Now the overall F-score of my model has more merit yet none of the variables are significant. I suppose then this is due to my variables and not due to a code error. Thanks

      Code:
      xtset FUNDID year
      
      Panel variable: FUNDID (unbalanced)
       Time variable: year, 2004 to 2022, but with gaps
               Delta: 1 unit
      
      . xtreg abnormal_return did FEDFUNDS CAPITALCALLED i.year, fe vce(cluster FUNDID) 
      
      Fixed-effects (within) regression               Number of obs     =      6,798
      Group variable: FUNDID                          Number of groups  =        401
      
      R-squared:                                      Obs per group:
           Within  = 0.0098                                         min =         12
           Between = 0.0094                                         avg =       17.0
           Overall = 0.0003                                         max =         19
      
                                                      F(21,400)         =       3.42
      corr(u_i, Xb) = -0.0453                         Prob > F          =     0.0000
      
                                      (Std. err. adjusted for 401 clusters in FUNDID)
      -------------------------------------------------------------------------------
                    |               Robust
      abnormal_re~n | Coefficient  std. err.      t    P>|t|     [95% conf. interval]
      --------------+----------------------------------------------------------------
                did |   .1660538   .5897697     0.28   0.778    -.9933817    1.325489
           FEDFUNDS |  -.2892291   .2423715    -1.19   0.233    -.7657101     .187252
      CAPITALCALLED |   .0218505   .0391232     0.56   0.577    -.0550622    .0987632
                    |
               year |
              2005  |   .8537296   1.326926     0.64   0.520    -1.754891     3.46235
              2006  |   2.326355   1.936318     1.20   0.230    -1.480277    6.132987
              2007  |   2.316565   2.567059     0.90   0.367    -2.730047    7.363178
              2008  |   .2185709   1.502132     0.15   0.884    -2.734489    3.171631
              2009  |  -.5192825   1.291294    -0.40   0.688    -3.057853    2.019288
              2010  |  -.6224706   1.202564    -0.52   0.605    -2.986606    1.741664
              2011  |  -.8063109   1.167206    -0.69   0.490    -3.100935    1.488313
              2012  |  -.8605964   1.139029    -0.76   0.450    -3.099828    1.378635
              2013  |  -1.429499   1.114672    -1.28   0.200    -3.620846     .761848
              2014  |  -1.490262    1.11356    -1.34   0.182    -3.679423    .6988998
              2015  |  -1.476638   1.118525    -1.32   0.188     -3.67556    .7222831
              2016  |  -1.717135   1.127025    -1.52   0.128    -3.932767    .4984966
              2017  |  -1.928417   1.157323    -1.67   0.096    -4.203613    .3467779
              2018  |  -1.753435   1.196415    -1.47   0.144    -4.105481    .5986117
              2019  |  -1.483103   1.233243    -1.20   0.230     -3.90755     .941344
              2020  |  -1.716439   1.199587    -1.43   0.153    -4.074723    .6418446
              2021  |  -1.872876   1.181229    -1.59   0.114    -4.195068    .4493156
              2022  |  -2.011249   1.216988    -1.65   0.099     -4.40374    .3812425
                    |
              _cons |  -.9358723   3.720549    -0.25   0.802    -8.250146    6.378401
      --------------+----------------------------------------------------------------
            sigma_u |  14.638165
            sigma_e |  8.9587972
                rho |  .72750337   (fraction of variance due to u_i)
      -------------------------------------------------------------------------------

      Comment


      • #4
        Luke:
        I'm under the impression that your dataset has little within-panel variation.
        I would go -xtreg,re- and then test which ine is the right speciifcation via the community-contributed module -xtoverid-.
        Kind regards,
        Carlo
        (Stata 19.0)

        Comment


        • #5
          Hi Carlo,

          After running xtoverid (also needing to add xi: before the xtreg), the value is significant which I assume would suggest fixed effects are appropriate.

          Comment


          • #6
            Luke:
            see if the functional form of your regression model is correctly specified via the following procedure:
            Code:
            . use "https://www.stata-press.com/data/r17/nlswork.dta"
            (National Longitudinal Survey of Young Women, 14-24 years old in 1968)
            
            
            . xtreg ln_wage c.age##c.age, fe vce(cluster idcode)
            
            Fixed-effects (within) regression               Number of obs     =     28,510
            Group variable: idcode                          Number of groups  =      4,710
            
            R-squared:                                      Obs per group:
                 Within  = 0.1087                                         min =          1
                 Between = 0.1006                                         avg =        6.1
                 Overall = 0.0865                                         max =         15
            
                                                            F(2,4709)         =     507.42
            corr(u_i, Xb) = 0.0440                          Prob > F          =     0.0000
            
                                         (Std. err. adjusted for 4,710 clusters in idcode)
            ------------------------------------------------------------------------------
                         |               Robust
                 ln_wage | Coefficient  std. err.      t    P>|t|     [95% conf. interval]
            -------------+----------------------------------------------------------------
                     age |   .0539076    .004307    12.52   0.000     .0454638    .0623515
                         |
             c.age#c.age |  -.0005973    .000072    -8.30   0.000    -.0007384   -.0004562
                         |
                   _cons |    .639913   .0624195    10.25   0.000     .5175415    .7622845
            -------------+----------------------------------------------------------------
                 sigma_u |   .4039153
                 sigma_e |  .30245467
                     rho |  .64073314   (fraction of variance due to u_i)
            ------------------------------------------------------------------------------
            
            . predict fitted, xb
            (24 missing values generated)
            
            . g sq_fitted=fitted^2
            (24 missing values generated)
            
            . xtreg ln_wage fitted sq_fitted , fe vce(cluster idcode)
            
            Fixed-effects (within) regression               Number of obs     =     28,510
            Group variable: idcode                          Number of groups  =      4,710
            
            R-squared:                                      Obs per group:
                 Within  = 0.1092                                         min =          1
                 Between = 0.1033                                         avg =        6.1
                 Overall = 0.0881                                         max =         15
            
                                                            F(2,4709)         =     523.09
            corr(u_i, Xb) = 0.0467                          Prob > F          =     0.0000
            
                                         (Std. err. adjusted for 4,710 clusters in idcode)
            ------------------------------------------------------------------------------
                         |               Robust
                 ln_wage | Coefficient  std. err.      t    P>|t|     [95% conf. interval]
            -------------+----------------------------------------------------------------
                  fitted |   2.569185   .7085064     3.63   0.000     1.180181    3.958189
               sq_fitted |    -.47432   .2153021    -2.20   0.028    -.8964128   -.0522272
                   _cons |  -1.290258    .580562    -2.22   0.026    -2.428431   -.1520844
            -------------+----------------------------------------------------------------
                 sigma_u |    .403403
                 sigma_e |  .30238578
                     rho |  .64025357   (fraction of variance due to u_i)
            ------------------------------------------------------------------------------
            
            . test sq_fitted
            
             ( 1)  sq_fitted = 0
            
                   F(  1,  4709) =    4.85
                        Prob > F =    0.0276
            
            .
            In this case, the model is (as expected) misspecified, as the -test- outcome reaches statistical significance.
            Kind regards,
            Carlo
            (Stata 19.0)

            Comment


            • #7
              Hi Carlo,

              I have followed the above procedure and ended here:
              Code:
              test sq_fitted
              
               ( 1)  sq_fitted = 0
              
                     F(  1,   400) =    0.34
                          Prob > F =    0.5598
              I suppose my model is not misspecified as this is not significant.

              Comment


              • #8
                Luke:
                you're right.
                I fear that you have to live with your results.
                Kind regards,
                Carlo
                (Stata 19.0)

                Comment

                Working...
                X