-
-
Save scunning1975/bbb067f34d7cfd8421bfb827c2b744cf to your computer and use it in GitHub Desktop.
R code for Sun and Abraham
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
# Sun and Abraham (SA20) | |
unique(baker$treat_date) | |
# This time, our SA implementation is a little different because we don't have a | |
# "never treated" group. (Everyone get's treated eventually.) So, we'll use our | |
# last treated cohort (i.e. 2004) as the control group. In practice this means | |
# that we have to subset our data by dropping all observations after this final | |
# treatment year. You could create a new dataset, but here we'll just use the | |
# `subset` argument to drop these observations on the fly. | |
res_cohort = feols(y ~ sunab(treat_date, year) | id + year, | |
baker, subset = ~year<2004, ## NB: subset! | |
vcov = ~state) | |
summary(res_cohort) | |
iplot(res_cohort, ref.line = -1, main = "Sun & Abraham") | |
# Can also use iplot to plot them together | |
iplot(list(res_naive, res_cohort), ref.line = -1, | |
main = "Treatment's effect on y") | |
legend("topright", col = c(1, 2), pch = c(20, 17), | |
legend = c("TWFE", "Sun & Abraham")) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment