Announcement

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

  • Save the residuals from a regression with industry and year fixed effects

    Dear Stata Users,

    I am trying to estimate a model with industry and year fixed effects with standard errors clustered at the firm level. From this regression I need to save the residuals. For this I use the code below. Please, correct me if I am wrong:

    Code:
    reghdfe y x1 x2 x3 x4, absorb(industry year) vce(cluster firm_ID)
    
    predict e, residuals

  • #2
    Alberto:
    not quite, I think.
    You should try something along the following toy-example, instead:
    Code:
    . use "http://www.stata-press.com/data/r15/nlswork.dta"
    (National Longitudinal Survey.  Young Women 14-26 years of age in 1968)
    
    . reghdfe ln_wage hours, absorb(FE_ID_CODE=idcode FE_YEAR=i.year) vce(cluster idcode)
    (dropped 550 singleton observations)
    (converged in 8 iterations)
    (converged in 10 iterations)
    
    HDFE Linear regression                            Number of obs   =     27,917
    Absorbing 2 HDFE groups                           F(   1,   4159) =       2.35
    Statistics robust to heteroskedasticity           Prob > F        =     0.1257
                                                      R-squared       =     0.6555
                                                      Adj R-squared   =     0.5949
                                                      Within R-sq.    =     0.0004
    Number of clusters (idcode)  =      4,160         Root MSE        =     0.3030
    
                                 (Std. Err. adjusted for 4,160 clusters in idcode)
    ------------------------------------------------------------------------------
                 |               Robust
         ln_wage |      Coef.   Std. Err.      t    P>|t|     [95% Conf. Interval]
    -------------+----------------------------------------------------------------
           hours |    .000749    .000489     1.53   0.126    -.0002097    .0017076
    ------------------------------------------------------------------------------
    
    Absorbed degrees of freedom:
    ---------------------------------------------------------------+
     Absorbed FE |  Num. Coefs.  =   Categories  -   Redundant     |
    -------------+-------------------------------------------------|
          idcode |            0            4160           4160 *   |
            year |           14              15              1     |
    ---------------------------------------------------------------+
    * = fixed effect nested within cluster; treated as redundant for DoF computation
    
    . predict e, residuals
    (617 missing values generated)
    
    .
    Kind regards,
    Carlo
    (Stata 19.0)

    Comment


    • #3
      Dear Carlo,

      Thank you very much! It worked.

      Comment

      Working...
      X