I am working with the did package performing an estimation using the conditional parallel trends assumption with only one treated group (and 7 control groups that are never treated), so only one treatment adoption time.
I use the aggte() function with type = "simple" to compute the ATT. R then displays confidence bands for the MP-object. If I however try to access the estimate, standard error and the confidence bands with the function tidy() on the same MP-object, tidy() returns different confidence bands.
I tried setting type= "group", but still the confidence bands are different.
Any help is appreciated!
library(did)
data(mpdta)
mw.attgt.X <- att_gt(yname = "lemp",
gname = "first.treat",
idname = "countyreal",
tname = "year",
xformla = ~lpop,
data = mpdta,
)
mw.attgt.X
aggte(mw.attgt.X, type = "simple")
tidy(aggte(mw.attgt.X, type = "simple"))
aggte(mw.attgt.X, type = "group")
tidy(aggte(mw.attgt.X, type = "group"))
You can see the discrepancy in the confidence intervals.
The
tidyfunction is one that originally comes from the package{broom}that now lives in the tidymodels universe. It's goal is to tidy-up (hence broom, for sweeping and cleaning) model objects. The model object is reshaped into a data frame so that, say you're doing this programmatically with a 100 models they can be squished together into a dataframe and analysed together.It looks like the
didpackage reexports thetidygeneric function frombroomand adds its own methods. Taking a look at the source code of thetidymethod can be quite informative. The function definition is quite verbose so I'm going to truncate it to what really matters for your use case.Created on 2023-04-20 with reprex v2.0.2
Note how
conf.lowandconf.highare calculated. Compare this to how the AAGTEobj is printed itself. After some sleuthing you can see that thedid:::summary.AGGTEobjfunction is called. Again, truncating for brevity.Here you can see how the confidence bands are calculated. I'm no expert in difference in difference but it looks like the way that they are calculated for both methods are different.
Created on 2023-04-20 with reprex v2.0.2
Personally, I think the difference is worth a bug report.