Announcement

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

  • Options in a Panel data regression using Sergio Correia's ''reghdfe''

    Hello,

    I am currently working with a panel, using Correia's reghdfe command. Suppose I have a panel of firms with quarterly observations. If I only wanted to include firm specific fixed effects, then the code would be

    reghdfe Y X1 X2 X3 , absorb(firm_id)

    The above equation runs nicely. I only have a very silly question: how do I ask the program to get the residuals from this procedure and also, how do I specify no-intercept in the equation?
    I know that Correia's procedure allows for both options: residuals(newvar) and noconstant. But I'm having trouble with the syntax (how to properly include those two statements in the code)


    can anyone help me on this? I'm sorry for the sloppiness (I'm quite new with stata)

    Thank you

  • #2
    Tochi:
    welcome to this forum.
    - constant in -fe- does not matter; that's way the community-contributed command -reghdfe- doesn't report it (see -reghdfe- help file);
    - saving residuals requires that -absorb()- is coded in the following standard way:
    Code:
    use "https://www.stata-press.com/data/r16/nlswork.dta"
    . reghdfe ln_wage,abs(FE_Firm=idcode)
    (dropped 547 singleton observations)
    (converged in 1 iterations)
    (converged in 2 iterations)
    
    HDFE Linear regression                            Number of obs   =     27,987
    Absorbing 1 HDFE group                            F(   0,  23823) =       0.00
                                                      Prob > F        =          .
                                                      R-squared       =     0.6147
                                                      Adj R-squared   =     0.5473
                                                      Within R-sq.    =     0.0000
                                                      Root MSE        =     0.3203
    
    ------------------------------------------------------------------------------
         ln_wage |      Coef.   Std. Err.      t    P>|t|     [95% Conf. Interval]
    -------------+----------------------------------------------------------------
        Absorbed |    F(4163, 23823) =      9.128   0.000             (Joint test)
    ------------------------------------------------------------------------------
    
    Absorbed degrees of freedom:
    ---------------------------------------------------------------+
     Absorbed FE |  Num. Coefs.  =   Categories  -   Redundant     |
    -------------+-------------------------------------------------|
          idcode |         4164            4164              0     |
    ---------------------------------------------------------------+
    
    . predict res, res
    (547 missing values generated)
    
    . list idcode year res in 1/10
    
         +---------------------------+
         | idcode   year         res |
         |---------------------------|
      1. |      1     70   -.5892196 |
      2. |      1     71   -1.011814 |
      3. |      1     72   -.4504561 |
      4. |      1     73   -.2601607 |
      5. |      1     75   -.2634219 |
         |---------------------------|
      6. |      1     77    -.261753 |
      7. |      1     78    .4535424 |
      8. |      1     80    .5112819 |
      9. |      1     83    .3798279 |
     10. |      1     85    .5737389 |
         +---------------------------+
    
    .
    Kind regards,
    Carlo
    (Stata 19.0)

    Comment


    • #3
      Thank you very much Carlo. I tried your suggestion and it worked just fine!

      Comment

      Working...
      X