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 it's 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. 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.)

Array Array

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 1bmedicareimpactwq2 coefficients.

I try a simplified version:

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))
Array


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
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


Code:
* Example generated by -dataex-. To install: ssc install dataex
clear
input float mort_res_pt0 byte(mcareimpactwq2 first_it) float firstyear double fips float year double pop_icpsr0
        . . 0    .   36 1962                  .
        . . 0    .   36 1963                  .
        . . 0    .   36 1964                  .
        . . 0    .   36 1965                  .
        . . 0    .   36 1966                  .
        . . 0    .   36 1967                  .
        . . 0    .   36 1968                  .
        . . 0    .   36 1969                  .
        . . 0    .   36 1970                  .
        . . 0    .   36 1971                  .
        . . 0    .   36 1972                  .
        . . 0    .   36 1973                  .
        . . 0    .   36 1974                  .
        . . 0    .   36 1975                  .
        . 2 0    . 1001 1927 19458.199999999983
        . 2 0    . 1001 1928  19536.79999999999
        . 2 0    . 1001 1929 19615.399999999994
        . 2 0    . 1001 1930              19694
        . 2 0    . 1001 1931  19822.29999999999
        . 2 0    . 1001 1932 19950.600000000006
        . 2 0    . 1001 1933 20078.899999999994
        . 2 0    . 1001 1934 20207.199999999983
        . 2 0    . 1001 1935            20335.5
        . 2 0    . 1001 1936  20463.79999999999
10.635146 2 0    . 1001 1937 20592.100000000006
 9.217969 2 0    . 1001 1938 20720.399999999994
 9.640889 2 0    . 1001 1939 20848.699999999983
10.916718 2 0    . 1001 1940              20977
10.725726 2 0    . 1001 1941 20697.899999999907
 8.913354 2 0    . 1001 1942  20418.79999999993
 9.583062 2 0    . 1001 1943 20139.699999999953
 10.12054 2 0    . 1001 1944 19860.599999999977
 9.294487 2 0    . 1001 1945            19581.5
 7.771054 2 0    . 1001 1946 19302.399999999907
 9.987752 2 0    . 1001 1947  19023.29999999993
10.830017 2 0    . 1001 1948 18744.199999999953
10.127213 2 0    . 1001 1949 18465.099999999977
11.327394 2 0    . 1001 1950              18186
 9.703256 2 0    . 1001 1951  18241.29999999999
10.657718 2 0    . 1001 1952  18296.59999999999
 9.481307 2 0    . 1001 1953 18351.899999999994
 9.724456 2 0    . 1001 1954 18407.199999999997
 9.803656 2 0    . 1001 1955            18462.5
 9.072352 2 0    . 1001 1956  18517.79999999999
10.122166 2 0    . 1001 1957  18573.09999999999
10.736295 2 0    . 1001 1958 18628.399999999994
 8.403047 2 0    . 1001 1959 18683.699999999997
 9.552271 2 0    . 1001 1960              18739
 9.217497 2 0    . 1001 1961 19311.100000000093
 9.807275 2 0    . 1001 1962 19883.199999999953
12.368433 2 0    . 1001 1963 20455.300000000047
 11.55635 2 0    . 1001 1964  21027.40000000014
10.231718 2 0    . 1001 1965            21599.5
 9.381371 2 0    . 1001 1966 22171.600000000093
 9.321262 2 0    . 1001 1967 22743.699999999953
 9.692998 2 0    . 1001 1968 23315.800000000047
 8.018808 2 0    . 1001 1969              23819
 8.272171 2 0    . 1001 1970              24661
 8.979336 2 0    . 1001 1971              25503
 7.585801 2 0    . 1001 1972              27156
 9.032439 2 0    . 1001 1973              28453
 7.552715 2 0    . 1001 1974              29261
 6.595773 2 0    . 1001 1975              29716
 7.828181 2 0    . 1001 1976              29892
 7.354631 2 0    . 1001 1977              30457
 7.124583 2 0    . 1001 1978              30879
 7.020281 2 0    . 1001 1979              32050
 6.859733 2 0    . 1001 1980              32217
 7.097077 2 0    . 1001 1981              31985
 6.523503 2 0    . 1001 1982              32038
 8.328914 2 0    . 1001 1983              32057
 9.088079 2 0    . 1001 1984              32130
 8.062515 2 0    . 1001 1985              32248
 8.542332 2 0    . 1001 1986              32895
 8.386942 2 0    . 1001 1987              33266
  8.23498 2 0    . 1001 1988              33637
        . 2 0    . 1001 1989              33996
        . 2 0    . 1001 1990              34353
        . 2 0    . 1001 1991              35010
        . 2 0    . 1001 1992              35985
        . 2 0    . 1001 1993              36953
        . 2 0    . 1001 1994              38186
        . 2 0    . 1001 1995              39112
        . 2 0    . 1001 1996              40207
        . 2 0    . 1001 1997              41238
        . 2 0    . 1001 1998              42106
        . 2 0    . 1001 1999              42963
        . 2 0    . 1001 2000              44021
        . 2 0    . 1001 2001              44889
 8.451502 2 0    . 1001 2002              45909
8.5470085 2 0    . 1001 2003              46800
 7.794732 2 0    . 1001 2004              48366
 9.139222 2 0    . 1001 2005              49676
8.9035225 2 0    . 1001 2006              51328
 7.747352 2 0    . 1001 2007              52405
        . 2 0 1956 1003 1927 26021.300000000047
        . 2 0 1956 1003 1928 26777.199999999953
        . 2 0 1956 1003 1929  27533.09999999986
        . 2 0 1956 1003 1930              28289
        . 2 0 1956 1003 1931            28692.5
end