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 | |
}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
So, I don't have too much time to dig into this all right now, buttttt
event_study
, so I think that might be user-errorsource: https://github.com/kylebutts/didimputation/blob/0330e81be3267d8c759297b0dd1ebc3480aac7db/R/did_imputation.R#L270
I think that is causing the weird level shift, but can't really place a finger on what the problem is there