Closed jtorcasso closed 2 years ago
Hi Jake,
Thanks for sending this. I think it was a bug for the case with a universal base period. But I think I have it fixed now if you update to the new version on github. Here is some demo code:
library(did)
sp <- reset.sim(time.periods=10)
data <- build_sim_dataset(sp)
data <- subset(data, G != 0) # drop never treated
data <- subset(data, G > 6)
data <- subset(data, period > 5)
data$Y[(data$period < data$G)] <- 0 # set pre-treatment = 0
res <- att_gt(yname="Y",
tname="period",
idname="id",
gname="G",
data=data,
control_group = "notyettreated",
base_period="universal")
#> No pre-treatment periods to test
res
#>
#> Call:
#> att_gt(yname = "Y", tname = "period", idname = "id", gname = "G",
#> data = data, control_group = "notyettreated", base_period = "universal")
#>
#> Reference: Callaway, Brantly and Pedro H.C. Sant'Anna. "Difference-in-Differences with Multiple Time Periods." Journal of Econometrics, Vol. 225, No. 2, pp. 200-230, 2021. <https://doi.org/10.1016/j.jeconom.2020.12.001>, <https://arxiv.org/abs/1803.09015>
#>
#> Group-Time Average Treatment Effects:
#> Group Time ATT(g,t) Std. Error [95% Simult. Conf. Band]
#> 7 6 0.0000 NA NA NA
#> 7 7 13.7827 0.3654 12.9246 14.6408 *
#> 7 8 14.9262 0.4144 13.9530 15.8995 *
#> 7 9 15.9908 0.4357 14.9675 17.0142 *
#> 8 6 0.0000 NA NA NA
#> 8 7 0.0000 NA NA NA
#> 8 8 15.0873 0.4157 14.1111 16.0635 *
#> 8 9 16.1022 0.4640 15.0125 17.1919 *
#> 9 6 0.0000 NA NA NA
#> 9 7 0.0000 NA NA NA
#> 9 8 0.0000 NA NA NA
#> 9 9 16.4631 0.4750 15.3474 17.5787 *
#> ---
#> Signif. codes: `*' confidence band does not cover 0
#>
#> Control Group: Not Yet Treated, Anticipation Periods: 0
#> Estimation Method: Doubly Robust
Awesome. Thanks for looking into this. Will update and follow up if necessary.
Not sure if this is a bug. But sometimes when I compute estimates on a variable with no variation (in this case it is 0 prior to the event) I still get non-zero effects estimated in the pre-period. Shouldn't these estimates be exactly 0? I can try to produce mwe with data I can share, but in the meantime, any thoughts?