Created
April 12, 2021 11:33
-
-
Save scunning1975/eaf107cbd8a3a5baec5d62b128549e49 to your computer and use it in GitHub Desktop.
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
library(readstata13) | |
library(ggplot2) | |
library(did) # Callaway & Sant'Anna | |
castle <- data.frame(read.dta13('https://github.com/scunning1975/mixtape/raw/master/castle.dta')) | |
castle$effyear[is.na(castle$effyear)] <- 0 # untreated units have effective year of 0 | |
# Estimating the effect on log(homicide) | |
atts <- att_gt(yname = "l_homicide", # LHS variable | |
tname = "year", # time variable | |
idname = "sid", # id variable | |
gname = "effyear", # first treatment period variable | |
data = castle, # data | |
xformla = NULL, # no covariates | |
#xformla = ~ l_police, # with covariates | |
est_method = "dr", # "dr" is doubly robust. "ipw" is inverse probability weighting. "reg" is regression | |
control_group = "nevertreated", # set the comparison group which is either "nevertreated" or "notyettreated" | |
bstrap = TRUE, # if TRUE compute bootstrapped SE | |
biters = 1000, # number of bootstrap iterations | |
print_details = FALSE, # if TRUE, print detailed results | |
clustervars = "sid", # cluster level | |
panel = TRUE) # whether the data is panel or repeated cross-sectional |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment