Announcement

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

  • The syntax of reghdfe

    Hi all.

    I use the next command to estimate what called in the economic literature the "child penalty", following Kleven, Landais and Sogaard (AEJ: Applied Economics, 2019):

    Code:
    reg wage ib(6).year_relative_to_first_child_birth_adj i.year i.age, robust
    But i heard the the command
    Code:
    reghdfe
    is better to use since it's standard errors are more accurate. What id the parallel syntax that I should use?

    Thanks,

    Fitzgerald
    Last edited by FitzGerald Blindman; 06 Jan 2026, 00:47.

  • #2

    reghdfe wage ib(6).year_relative_to_first_child_birth_adj , absorb(year age) //cluster(x) or vce(robust)

    Comment


    • #3
      I fear that the community-contributed module -reghdfe- does not support -robust- standard errors:
      Code:
      sysuse auto
      . reghdfe price weight length, absorb(rep78) robust
      options robust not allowed
      r(198);
      
      . reghdfe price weight length, absorb(rep78) vce(cluster rep78)
      (MWFE estimator converged in 1 iterations)
      
      HDFE Linear regression                            Number of obs   =         69
      Absorbing 1 HDFE group                            F(   2,      4) =      21.65
      Statistics robust to heteroskedasticity           Prob > F        =     0.0072
                                                        R-squared       =     0.4341
                                                        Adj R-squared   =     0.3793
                                                        Within R-sq.    =     0.4258
      Number of clusters (rep78)   =          5         Root MSE        =  2294.5106
      
                                        (Std. err. adjusted for 5 clusters in rep78)
      ------------------------------------------------------------------------------
                   |               Robust
             price | Coefficient  std. err.      t    P>|t|     [95% conf. interval]
      -------------+----------------------------------------------------------------
            weight |   5.478309   .8536918     6.42   0.003     3.108081    7.848538
            length |  -109.5065   25.31469    -4.33   0.012    -179.7914   -39.22167
             _cons |   10154.62   4209.396     2.41   0.073     -1532.54    21841.77
      ------------------------------------------------------------------------------
      
      Absorbed degrees of freedom:
      -----------------------------------------------------+
       Absorbed FE | Categories  - Redundant  = Num. Coefs |
      -------------+---------------------------------------|
             rep78 |         5           5           0    *|
      -----------------------------------------------------+
      * = FE nested within cluster; treated as redundant for DoF computation
      
      .
      Kind regards,
      Carlo
      (Stata 19.0)

      Comment


      • #4
        Originally posted by Carlo Lazzaro View Post
        I fear that the community-contributed module -reghdfe- does not support -robust- standard errors:
        Carlo Lazzaro, for Huber-White standard errors, you want the option -vce(robust)-. Alternatively, you could cluster at the observation level. Consider:

        Code:
        sysuse auto, clear
        areg price weight length, absorb(rep78) robust
        reghdfe price weight length, absorb(rep78) vce(robust)
        reghdfe price weight length, absorb(rep78) vce(cluster make)
        Res.:

        Code:
        . areg price weight length, absorb(rep78) robust
        
        Linear regression, absorbing indicators          Number of obs     =        69
        Absorbed variable: rep78                         No. of categories =         5
                                                         F(2, 62)          =     17.75
                                                         Prob > F          =    0.0000
                                                         R-squared         =    0.4341
                                                         Adj R-squared     =    0.3793
                                                         Root MSE          = 2294.5106
        
        ------------------------------------------------------------------------------
                     |               Robust
               price | Coefficient  std. err.      t    P>|t|     [95% conf. interval]
        -------------+----------------------------------------------------------------
              weight |   5.478309   1.903131     2.88   0.005     1.674004    9.282614
              length |  -109.5065   60.82641    -1.80   0.077    -231.0968    12.08375
               _cons |   10154.62   6010.797     1.69   0.096    -1860.795    22170.03
        ------------------------------------------------------------------------------
        
        . 
        . reghdfe price weight length, absorb(rep78) vce(robust)
        (MWFE estimator converged in 1 iterations)
        
        HDFE Linear regression                            Number of obs   =         69
        Absorbing 1 HDFE group                            F(   2,     62) =      17.75
                                                          Prob > F        =     0.0000
                                                          R-squared       =     0.4341
                                                          Adj R-squared   =     0.3793
                                                          Within R-sq.    =     0.4258
                                                          Root MSE        =  2294.5106
        
        ------------------------------------------------------------------------------
                     |               Robust
               price | Coefficient  std. err.      t    P>|t|     [95% conf. interval]
        -------------+----------------------------------------------------------------
              weight |   5.478309   1.903131     2.88   0.005     1.674004    9.282614
              length |  -109.5065   60.82641    -1.80   0.077    -231.0968    12.08375
               _cons |   10154.62   6010.797     1.69   0.096    -1860.795    22170.03
        ------------------------------------------------------------------------------
        
        Absorbed degrees of freedom:
        -----------------------------------------------------+
         Absorbed FE | Categories  - Redundant  = Num. Coefs |
        -------------+---------------------------------------|
               rep78 |         5           0           5     |
        -----------------------------------------------------+
        
        . 
        . reghdfe price weight length, absorb(rep78) vce(cluster make)
        (MWFE estimator converged in 1 iterations)
        
        HDFE Linear regression                            Number of obs   =         69
        Absorbing 1 HDFE group                            F(   2,     62) =      17.75
        Statistics robust to heteroskedasticity           Prob > F        =     0.0000
                                                          R-squared       =     0.4341
                                                          Adj R-squared   =     0.3793
                                                          Within R-sq.    =     0.4258
        Number of clusters (make)    =         69         Root MSE        =  2294.5106
        
                                          (Std. err. adjusted for 69 clusters in make)
        ------------------------------------------------------------------------------
                     |               Robust
               price | Coefficient  std. err.      t    P>|t|     [95% conf. interval]
        -------------+----------------------------------------------------------------
              weight |   5.478309   1.903131     2.88   0.005     1.674004    9.282614
              length |  -109.5065   60.82641    -1.80   0.077    -231.0968    12.08375
               _cons |   10154.62   6010.797     1.69   0.096    -1860.795    22170.03
        ------------------------------------------------------------------------------
        
        Absorbed degrees of freedom:
        -----------------------------------------------------+
         Absorbed FE | Categories  - Redundant  = Num. Coefs |
        -------------+---------------------------------------|
               rep78 |         5           0           5     |
        -----------------------------------------------------+
        
        .

        Comment


        • #5
          Thanks, Andrew!
          Kind regards,
          Carlo
          (Stata 19.0)

          Comment

          Working...
          X