Announcement

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

  • reghdfe with nocons option

    Dear statalist,

    I want to run a regression with firm and year fixed effects, with firm-clustered standard errors, and without the constant term, I believe -reghdfe- can be combined with -nocons-, but why when I run the code below, stata says "invalid options: nocons"?
    Code:
    reghdfe y x1 x2 x3 x4 x5 x6, absorb(firm year) nocons vce(cluster firm)
    Thanks a lot for any suggestion!

  • #2
    Lucy:
    works for me in the following toy-example:
    Code:
    use "https://www.stata-press.com/data/r17/nlswork.dta"
    . reghdfe ln_wage c.age##c.age , abs(idcode year) vce(cluster idcode) nocons
    (dropped 551 singleton observations)
    (MWFE estimator converged in 8 iterations)
    
    HDFE Linear regression                            Number of obs   =     27,959
    Absorbing 2 HDFE groups                           F(   2,   4158) =      44.91
    Statistics robust to heteroskedasticity           Prob > F        =     0.0000
                                                      R-squared       =     0.6593
                                                      Adj R-squared   =     0.5995
                                                      Within R-sq.    =     0.0115
    Number of clusters (idcode)  =      4,159         Root MSE        =     0.3013
    
                                 (Std. err. adjusted for 4,159 clusters in idcode)
    ------------------------------------------------------------------------------
                 |               Robust
         ln_wage | Coefficient  std. err.      t    P>|t|     [95% conf. interval]
    -------------+----------------------------------------------------------------
             age |   .0728746   .0136873     5.32   0.000     .0460402    .0997089
                 |
     c.age#c.age |  -.0010113   .0001076    -9.39   0.000    -.0012224   -.0008003
    ------------------------------------------------------------------------------
    
    Absorbed degrees of freedom:
    -----------------------------------------------------+
     Absorbed FE | Categories  - Redundant  = Num. Coefs |
    -------------+---------------------------------------|
          idcode |      4159        4159           0    *|
            year |        15           0          15     |
    -----------------------------------------------------+
    * = FE nested within cluster; treated as redundant for DoF computation
    
    .
    Kind regards,
    Carlo
    (StataNow 18.5)

    Comment


    • #3
      Hi Carlo,

      Thanks a lot for your reply. How strange! My code is similar to yours, except for I have 6 IVs and some control variables, and I don't have the interaction term. To be more specific, my 6 IVs are 6 time dummies, which represents 3 years before an event (enforcement of a law) happens, 2 years before, 1 year before, the event year, 1 year after, and 2 years after (pre3, pre2, pre1, event, post1, post2); the DV, error, is a continuous variable that measures analyst forecast error.
      Code:
      reghdfe error pre3 pre2 pre1 event post1 post2 controls, absorb(firm year) vce(cluster firm) nocons
      And stata says
      Code:
      invalid options: nocons
      r(198);

      I could use -nocons- if I use reg instead.
      Code:
      reg error pre3 pre2 pre1 event post1 post2 controls i.firm i.year ,vce(cluster firm) nocons
      Code:
      ------------------------------------------------------------------------------------
                         |               Robust
                   error |      Coef.   Std. Err.      t    P>|t|     [95% Conf. Interval]
      -------------------+----------------------------------------------------------------
                    pre3 |   -1.43105   2.077697    -0.69   0.491    -5.510459    2.648359
                    pre2 |  -2.310634   2.163936    -1.07   0.286    -6.559368    1.938099
                    pre1 |  -1.541373   2.072042    -0.74   0.457    -5.609679    2.526933
                   event |  -1.890391   2.030509    -0.93   0.352    -5.877149    2.096368
                   post1 |  -1.700703   2.093798    -0.81   0.417    -5.811725     2.41032
                   post2 |  -1.620117   1.934716    -0.84   0.403    -5.418793    2.178558
      Can you spot anything wrong with the code using -reghdfe-? Why it doesn't work the same way as using reg?

      Thanks!
      Last edited by Lucy Garcia; 20 Apr 2022, 19:54.

      Comment


      • #4

        Code:
        ssc install reghdfe, replace
        Originally posted by Lucy Garcia View Post
        To be more specific, my 6 IVs are 6 time dummies, which represents 3 years before an event (enforcement of a law) happens, 2 years before, 1 year before, the event year, 1 year after, and 2 years after (pre3, pre2, pre1, event, post1, post2); the DV, error, is a continuous variable that measures analyst forecast error.
        If the event occurs at the same year for all units (analysts) in your panel, then the event, pre and post dummies are collinear with the year dummies. In any case, if your goal is to estimate these coefficients, then they are not identified in the case that they are collinear with the year effects. The -nocons- option in reghdfe is essentially a "hide cons" option, and will not affect what is omitted from the estimation. You have to go back and respecify the model. If your intention is, e.g., to examine the impact of the enforcement of the law on the outcome variable, then define a treatment dummy (=1 if analyst \(i\) in year \(t\) was subject to the law, and 0 otherwise) and then estimate the regression:

        Code:
        xtset analyst_id year
        xtreg outcome treatment controls i.year, fe robust
        Last edited by Andrew Musau; 21 Apr 2022, 01:08.

        Comment


        • #5
          Hi Andrew,

          Thanks for your help! The event doesn't occur in the same year for all firms; the enforcement of law is a staggered implementation, firms in different industries have enforcement in different years (sorry that I should make this clear earlier).

          I think my -reghdfe- if not up to date. When I ssc install reghdfe, replace, it works.

          Comment

          Working...
          X