Created
February 21, 2022 01:29
-
-
Save grantmcdermott/60fcb75261ae99d43377b3ab0d71c590 to your computer and use it in GitHub Desktop.
Generate the "Baker" simulated dataset for staggered treatment effects
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
set.seed(1234) | |
# Create the base dataset as a cross-join of 1,000 firms over 30 periods | |
baker = expand.grid(n = 1:30, id = 1:1000) | |
# Add additional columns | |
baker = | |
baker |> | |
within({ | |
year = n + 1980 - 1 | |
state = 1 + (id-1) %/% 25 | |
firms = runif(id*year, 0, 5) | |
group = 1 + (state-1) %/% 10 | |
treat_date = 1980 + group*6 | |
time_til = year - treat_date | |
treat = time_til>=0 | |
e = rnorm(id*year, 0, 0.5^2) | |
te = rnorm(id*year, 10-2*(group-1), 0.2^2) | |
y = firms + n + treat*te*(year - treat_date + 1) + e | |
y2 = firms + n + te*treat + e | |
}) |
So, I don't have too much time to dig into this all right now, buttttt
- I think my Sun and Abraham code is wrong and it's on my todo list to fix for
event_study
, so I think that might be user-error - BJS and did2s will produce identical estimates in the post-period. I'm not sure exactly the reason, but BJS estimates the pre-period in a separate regression:
pre_est <- fixest::feols(pre_formula, data[data$zz000treat == 0, ], weights = weights_vector[data$zz000treat == 0], warn=FALSE, notes=FALSE)
I think that is causing the weird level shift, but can't really place a finger on what the problem is there
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Estimation and plot step using @kylebutts 's excellent
did2s
:Are the BJS + SA estimators doing something unexpected here? Non-negligible biases (unless i messed something up in the DGP / subsetting).