Announcement

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

  • Trying to Plot Coefficients of Interactions with Event Study Indicators

    Hi all,

    I am plotting event study coefficients by running coefplot after reghdfe. Coefplot is a very nice community-contributed command for plotting regression results. This has worked pretty well, but I have a problem when I interact event study leads/lags with a categorical variable and try to plot coefficients from those interactions.

    (Conceptually, my specification is doing what's explained in Example 1.2 in this UCLA IDRE tutorial on interactions in Stata, but interacting a group category with event study leads and lags instead of with a female indicator.)

    I would like to look for heterogeneous treatment effects, between the two levels of this categorical variable, mcareimpactwq2. The variable indicating treatment is called first_it. This is my main regression:

    Code:
    reghdfe mort_res_pt0 i.mcareimpactwq2#i.treat_prelead_10_100 i.mcareimpactwq2#i.F(9/2).first_it ///
     zero_lead1 i.mcareimpactwq2#i.L(0/20).first_it i.mcareimpactwq2#i.treat_postlag ///
     i.mcareimpactwq2 ///
     state*t_trend ///
    $lincontrols $sqcontrols ///
    if firstyear>1964 /*include treateds after 1964 and never-treateds */ ///
     [aw=pop_icpsr0], absorb(fips year) cluster(fips)
     
    forvalue i = 1/2 {
        coefplot, omitted keep( `i'*mcare*#1*first_it zero_lead1 ) vertical xlabel(,angle(90)) /*xlabel(10 "0" 5 "-5" 15 "5" 20 "10" 25 "15" 30 "20")*/ xline(10) yline(0) ///
            xtitle("Years from Treatment") ytitle("Effect on Mortality" "OLS Estimate and 95CI") ///
            caption("Run on quartile `i' of Blue Cross Uninsured Rate")
        graph export "output/23_18_heterog_fullinteract/reg05_qis`i'.png", as(png) replace
    (zero_leads 1 is just a column of zeros, so its coefficient is omitted from the regression. It's purpose is to make sure coefplot puts a dot at zero for the reference event time, which is event time=-1. The variable treat_prelead_10_100 just bins up all the lead indicators before lead 9, and treat_postlag bins up all lag indicators after 20.)

    This produces the desired graph for 2.mcareimpact#1*first_it (i.e., the coefficients for the group mcareimpact=2) but not for 1b.mcareimpact#1*first_it. (Obviously, the plot in the second graph is not interpretable because the labels are so long. I am keeping these long labels for now in order to diagnose why coefplot isn't behaving as I thought it would.)
    Click image for larger version

Name:	reg05_qis1.png
Views:	1
Size:	16.4 KB
ID:	1528733

    Click image for larger version

Name:	reg05_qis2.png
Views:	1
Size:	44.2 KB
ID:	1528734





    All the interaction coefficients for 2.mcareimpact appear, but none of the coefficients for 1b.mcareimpact# appear. I check to make sure the names of the stored values are compatible with my code:

    Code:
    . reghdfe, coeflegend noheader
                                                      (Std. Err. adjusted for 943 clusters in fips)
    -----------------------------------------------------------------------------------------------
                     mort_res_pt0 |      Coef.  Legend
    ------------------------------+----------------------------------------------------------------
                   mcareimpactwq2#|
             treat_prelead_10_100 |
                             1 1  |  -.1309679  _b[1b.mcareimpactwq2#1.treat_prelead_10_100]
                             2 1  |   .0781197  _b[2.mcareimpactwq2#1.treat_prelead_10_100]
                                  |
       mcareimpactwq2#F9.first_it |
                             1 1  |  -.0113029  _b[1b.mcareimpactwq2#1F9.first_it]
                             2 1  |   -.287819  _b[2.mcareimpactwq2#1F9.first_it]
                                  |
       mcareimpactwq2#F8.first_it |
                             1 1  |   .1529969  _b[1b.mcareimpactwq2#1F8.first_it]
                             2 1  |  -.0102849  _b[2.mcareimpactwq2#1F8.first_it]
                                  |
       mcareimpactwq2#F7.first_it |
                             1 1  |  -.0435848  _b[1b.mcareimpactwq2#1F7.first_it]
                             2 1  |  -.1261294  _b[2.mcareimpactwq2#1F7.first_it]
                                  |
    ... etc..

    The names look like they are compatible with my code: coefplot should get the coefficients I want. So I don't know why coefplot doesn't plot the 1b.medicareimpactwq2 coefficients.

    I try a simplified version, to get a better sense of what coefplot does:

    Code:
    reghdfe mort_res_pt0 i.mcareimpactwq2#i.F(2).first_it ///
     i.mcareimpactwq2 ///
    if firstyear>1964 /*include treateds after 1964 and never-treateds */ ///
     [aw=pop_icpsr0], absorb(fips year) cluster(fips)
                
        coefplot, nolabels  vertical xlabel(,angle(90))
    Click image for larger version

Name:	reg06_2.png
Views:	1
Size:	11.8 KB
ID:	1528737






    As you can see, it plots the estimate for 2.mcareimpactwq2#F2.first_it, but not for 1bmcareimpactwq2#F2.first_it.

    Here are the regression results and stored values. There you can see that Stata does in fact have stored estimates for both of these:

    Code:
    note: 2.mcareimpactwq2 omitted because of collinearity
    
    HDFE Linear regression                            Number of obs   =     62,137
    Absorbing 2 HDFE groups                           F(   2,   1106) =       0.42
    Statistics robust to heteroskedasticity           Prob > F        =     0.6577
                                                      R-squared       =     0.6761
                                                      Adj R-squared   =     0.6699
                                                      Within R-sq.    =     0.0000
    Number of clusters (fips)    =      1,107         Root MSE        =     1.5525
    
                                                 (Std. Err. adjusted for 1,107 clusters in fips)
    --------------------------------------------------------------------------------------------
                               |               Robust
                  mort_res_pt0 |      Coef.   Std. Err.      t    P>|t|     [95% Conf. Interval]
    ---------------------------+----------------------------------------------------------------
    mcareimpactwq2#F2.first_it |
                          1 1  |   .1030809   .1801463     0.57   0.567    -.2503861    .4565479
                          2 1  |  -.0973199    .116785    -0.83   0.405     -.326465    .1318252
                               |
              2.mcareimpactwq2 |          0  (omitted)
                         _cons |   9.656954   .0005526  1.7e+04   0.000      9.65587    9.658039
    --------------------------------------------------------------------------------------------
    
    Absorbed degrees of freedom:
    -----------------------------------------------------+
     Absorbed FE | Categories  - Redundant  = Num. Coefs |
    -------------+---------------------------------------|
            fips |      1107        1107           0    *|
            year |        69           0          69     |
    -----------------------------------------------------+
    * = FE nested within cluster; treated as redundant for DoF computation
    
    .
    end of do-file
    Stored values:

    Code:
    . mat list e(b)
    
    e(b)[1,7]
         1b.mcareim~2#  1b.mcareim~2#  2o.mcareim~2#  2.mcareimp~2#            1b.            2o.              
         0bF2.firs~it   1F2.first_it   0bF2.firs~it   1F2.first_it   mcareimpac~2   mcareimpac~2          _cons
    y1              0       .1030809              0     -.09731989              0              0      9.6569545
    Code:
    . reghdfe, coeflegend noheader
                                                 (Std. Err. adjusted for 1,107 clusters in fips)
    --------------------------------------------------------------------------------------------
                  mort_res_pt0 |      Coef.  Legend
    ---------------------------+----------------------------------------------------------------
    mcareimpactwq2#F2.first_it |
                          1 1  |   .1030809  _b[1b.mcareimpactwq2#1F2.first_it]
                          2 1  |  -.0973199  _b[2.mcareimpactwq2#1F2.first_it]
                               |
              2.mcareimpactwq2 |          0  _b[2o.mcareimpactwq2]
                         _cons |   9.656954  _b[_cons]
    --------------------------------------------------------------------------------------------
    
    Absorbed degrees of freedom:
    -----------------------------------------------------+
     Absorbed FE | Categories  - Redundant  = Num. Coefs |
    -------------+---------------------------------------|
            fips |      1107        1107           0    *|
            year |        69           0          69     |
    -----------------------------------------------------+
    * = FE nested within cluster; treated as redundant for DoF computation
    I'm on Stata 16.

    If anyone has any ideas as to why coefplot is not recognizing stored values from the regression which clearly are in fact stored, I would greatly appreciate it!

    Thanks,
    Nate
    Last edited by Nate Breg; 15 Dec 2019, 09:37.

  • #2
    Correction: my regression spec follows example 1.1, not example 1.2, in the IDRE tutorial.

    Also, I should note that -reghdfe- is also a nice community contributed command available through ssc install reghdfe.

    Comment

    Working...
    X