Announcement

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

  • Comparing coefficients of interaction term across subgroups (reghdfe)

    Hi, is there any way to compare the coefficients of interaction term across different subgroups using reghdfe?

    Suppose I'm interested in the effects of union in the city on wage (ln_wage), which makes me interact "union" with "city" variable. In addition, I'd like to do subgroup analysis by marriage (msp) and test whether the coefficients of interaction term (union#c_city) in two groups, which are -0.0196 and -0.0298 in the example code below, are significantly different to each other. How can I compare these two interaction coefficients?

    Code:
    webuse nlswork, clear
    
    reghdfe ln_wage union##c_city if msp==1, absorb(idcode year)
    
    ------------------------------------------------------------------------------
         ln_wage | Coefficient  Std. err.      t    P>|t|     [95% conf. interval]
    -------------+----------------------------------------------------------------
         1.union |   .1045442    .011149     9.38   0.000     .0826896    .1263987
        1.c_city |   .0331573   .0132385     2.50   0.012     .0072068    .0591078
                 |
    union#c_city |
            1 1  |  -.0196805   .0190602    -1.03   0.302    -.0570431     .017682
                 |
           _cons |    1.72928   .0048373   357.49   0.000     1.719798    1.738763
    ------------------------------------------------------------------------------
    
    
    reghdfe ln_wage union##c_city if msp==0, absorb(idcode year)
    ------------------------------------------------------------------------------
         ln_wage | Coefficient  Std. err.      t    P>|t|     [95% conf. interval]
    -------------+----------------------------------------------------------------
         1.union |   .1249048    .015938     7.84   0.000     .0936593    .1561504
        1.c_city |   .0331801   .0160409     2.07   0.039     .0017327    .0646274
                 |
    union#c_city |
            1 1  |  -.0298477   .0213081    -1.40   0.161     -.071621    .0119256
                 |
           _cons |    1.72628   .0083392   207.01   0.000     1.709931    1.742628
    ------------------------------------------------------------------------------

  • #2
    reghdfe is from https://github.com/sergiocorreia/reghdfe (FAQ Advice #12).

    Code:
    webuse nlswork, clear
    reghdfe ln_wage union##c_city if msp==1, absorb(idcode year)
    reghdfe ln_wage union##c_city if !msp, absorb(idcode year)
    
    *JOINT ESTIMATION
    reghdfe ln_wage i.msp#(c.union##c.c_city), absorb(i.msp#idcode i.msp#year) cluster(idcode) nocons
    *WALD TEST
    test _b[0b.msp#c.union#c.c_city] = _b[1.msp#c.union#c.c_city]
    Res.:

    Code:
    . reghdfe ln_wage union##c_city if msp==1, absorb(idcode year)
    (dropped 686 singleton observations)
    (MWFE estimator converged in 8 iterations)
    
    HDFE Linear regression                            Number of obs   =     11,225
    Absorbing 2 HDFE groups                           F(   3,   8758) =      38.06
                                                      Prob > F        =     0.0000
                                                      R-squared       =     0.7484
                                                      Adj R-squared   =     0.6776
                                                      Within R-sq.    =     0.0129
                                                      Root MSE        =     0.2597
    
    ------------------------------------------------------------------------------
         ln_wage | Coefficient  Std. err.      t    P>|t|     [95% conf. interval]
    -------------+----------------------------------------------------------------
         1.union |   .1045442    .011149     9.38   0.000     .0826896    .1263987
        1.c_city |   .0331573   .0132385     2.50   0.012     .0072068    .0591078
                 |
    union#c_city |
            1 1  |  -.0196805   .0190602    -1.03   0.302    -.0570431     .017682
                 |
           _cons |    1.72928   .0048373   357.49   0.000     1.719798    1.738763
    ------------------------------------------------------------------------------
    
    Absorbed degrees of freedom:
    -----------------------------------------------------+
     Absorbed FE | Categories  - Redundant  = Num. Coefs |
    -------------+---------------------------------------|
          idcode |      2453           0        2453     |
            year |        12           1          11     |
    -----------------------------------------------------+
    
    . 
    . reghdfe ln_wage union##c_city if !msp, absorb(idcode year)
    (dropped 764 singleton observations)
    (MWFE estimator converged in 9 iterations)
    
    HDFE Linear regression                            Number of obs   =      6,549
    Absorbing 2 HDFE groups                           F(   3,   4932) =      31.94
                                                      Prob > F        =     0.0000
                                                      R-squared       =     0.8017
                                                      Adj R-squared   =     0.7367
                                                      Within R-sq.    =     0.0191
                                                      Root MSE        =     0.2444
    
    ------------------------------------------------------------------------------
         ln_wage | Coefficient  Std. err.      t    P>|t|     [95% conf. interval]
    -------------+----------------------------------------------------------------
         1.union |   .1249048    .015938     7.84   0.000     .0936593    .1561504
        1.c_city |   .0331801   .0160409     2.07   0.039     .0017327    .0646274
                 |
    union#c_city |
            1 1  |  -.0298477   .0213081    -1.40   0.161     -.071621    .0119256
                 |
           _cons |    1.72628   .0083392   207.01   0.000     1.709931    1.742628
    ------------------------------------------------------------------------------
    
    Absorbed degrees of freedom:
    -----------------------------------------------------+
     Absorbed FE | Categories  - Redundant  = Num. Coefs |
    -------------+---------------------------------------|
          idcode |      1603           0        1603     |
            year |        12           1          11     |
    -----------------------------------------------------+
    
    . 
    . 
    . 
    . *JOINT ESTIMATION
    
    . 
    . reghdfe ln_wage i.msp#(c.union##c.c_city), absorb(i.msp#idcode i.msp#year) cluster(idcode) nocons
    (dropped 1450 singleton observations)
    (MWFE estimator converged in 10 iterations)
    
    HDFE Linear regression                            Number of obs   =     17,774
    Absorbing 2 HDFE groups                           F(   6,   3392) =      18.68
    Statistics robust to heteroskedasticity           Prob > F        =     0.0000
                                                      R-squared       =     0.7691
                                                      Adj R-squared   =     0.7002
                                                      Within R-sq.    =     0.0149
    Number of clusters (idcode)  =      3,393         Root MSE        =     0.2543
    
                                         (Std. err. adjusted for 3,393 clusters in idcode)
    --------------------------------------------------------------------------------------
                         |               Robust
                 ln_wage | Coefficient  std. err.      t    P>|t|     [95% conf. interval]
    ---------------------+----------------------------------------------------------------
             msp#c.union |
                      0  |   .1249048   .0203871     6.13   0.000     .0849326    .1648771
                      1  |   .1045442   .0149483     6.99   0.000     .0752356    .1338528
                         |
            msp#c.c_city |
                      0  |   .0331801   .0231686     1.43   0.152    -.0122458     .078606
                      1  |   .0331573   .0186464     1.78   0.075    -.0034021    .0697167
                         |
    msp#c.union#c.c_city |
                      0  |  -.0298477   .0257005    -1.16   0.246    -.0802378    .0205424
                      1  |  -.0196805   .0228557    -0.86   0.389    -.0644928    .0251317
    --------------------------------------------------------------------------------------
    
    Absorbed degrees of freedom:
    ------------------------------------------------------+
      Absorbed FE | Categories  - Redundant  = Num. Coefs |
    --------------+---------------------------------------|
       msp#idcode |      4056        4056           0    *|
         msp#year |        24           1          23     |
    ------------------------------------------------------+
    * = FE nested within cluster; treated as redundant for DoF computation
    
    . 
    . *WALD TEST
    
    . 
    . test _b[0b.msp#c.union#c.c_city] = _b[1.msp#c.union#c.c_city]
    
     ( 1)  0b.msp#c.union#c.c_city - 1.msp#c.union#c.c_city = 0
    
           F(  1,  3392) =    0.09
                Prob > F =    0.7648
    Last edited by Andrew Musau; 20 Apr 2024, 10:54.

    Comment


    • #3
      Awesome! Thank you so much, Andrew Musau. It totally works.

      Comment

      Working...
      X