-
Notifications
You must be signed in to change notification settings - Fork 169
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Event study in Stata #145
Comments
I think you're correct. It doesn't make sense to have Taking a higher-level look at this event study page, there are several other things we could change. We shouldn't be using a proprietary data format ( |
I've pushed a couple of updates. But really I think this page needs a closer look. I just ran the Stata implementation of Sun Abraham and got different results to the R version... I don't have time to troubleshoot now and it might just be a copy-paste error on my side. But I'm hoping @pdeffebach or @NickCH-K can double check. Similarly, I tried the Callaway-Sant'Anna estimator and got different results once again. I spoke v. briefly to Pedro and he thinks it's likely due to covariates, which SA don't handle in their paper. Again, though, it could be user error on my part. Here's the code I was trying locally: library(did)
## Change never treated to zero
dat[, year_treated := ifelse(treat==0, 0, `_nfd`)]
mod_cs = att_gt(yname = "asmrs",
gname = "year_treated",
idname = "stfips",
tname = "year",
xformla = ~ pcinc + asmrh + cases,
data = dat)
summary(mod_cs)
cs = aggte(mod_cs, type = "dynamic", na.rm = TRUE)
cs
ggdid(cs) |
I'll look at this when I get a chance |
Shifting the untreated treated-time to a big positive number seems fine to me; I do like the logic that the zeroes there let things drop out. On the R side the |
Yes. You have to assign to very positive number that is not included in the wanted interval. Keeping this as it is will apply the regression for states that treat=0 while we just want to include states with treat=1. I tried it and got different results. |
@aalamer1 do you have a fixed version of the code? |
@NickCH-K I am working on my own dataset but modified replace time_to_treat = 0 if missing(_nfd) Did you try in R code they posted? I tried to replicate it but generate errors of collinearity it is not working. I do not know how did they generate the graph and confirmed the results? |
Hi all: In the code: Shouldnt there be the interaction term of " treat## ib Thanks in advance! |
Yes, I believe you're right |
First of all, thank you for this wonderful resource!
I am confused by the Stata event study code, and think it might not be totally correct. For reference, here it is
My problem stems from the line
This means that states which are not treated are given
0
, meaning they are treated in that year. This gives the followingIt's possible that because in control units,
time_to_treat
does not vary across years, the state (stfips
) fixed effects "take care" of this. But I can't intuitively reason about what's really happening given0
stands for both untreated andtreated
, but year0
.I would recommend making the
time_to_treat
variable100
or the maximum plus100
, to avoid this confusion. The values don't matter since they are used as fixed effects anyways.The text was updated successfully, but these errors were encountered: