knitr::opts_chunk$set( collapse = TRUE, comment = "#>" )
library(multiDiff)
Preview this file with: link
In summary, in a non-staggered case:
base_period = "universal"
did::aggte
function gives the average of the post periods against a single pre periodstrim_low
)digits=5
Simulate data with common treatment (= non-staggered). Treatment happens at T=5.
dat_common <- sim_dat_common(timing_treatment = 5:10, as_mdd = TRUE, seed=123)
Estimate the standard DiD, and a truncated DiD, where we remove all pre-treatment periods except the last one
reg_DD <- mdd_DD_simple(dat_common) reg_DD_trunc <- mdd_DD_simple(dat_common |>subset(Time>=4))
Estimate the ES coefficents
reg_ES <- mdd_event_study(dat_common) reg_ES_trunc <- mdd_event_study(dat_common, trim_low = -1)
Estimate the CS coefficients
reg_CS <- mdd_CS(dat_common, base_period = "universal")
Estimate the CH coefficient
reg_CH_24_effct_1 <- mdd_estim_CH(mdd_dat = dat_common, graph_off=TRUE) reg_CH_24_effct_6 <- mdd_estim_CH(mdd_dat = dat_common, effects =6, placebo=3, graph_off=TRUE)
trim_low = -1
)all.equal(coef(reg_DD)[[1]], mean(coef(reg_ES_trunc)))
all.equal(coef(reg_DD_trunc)[[1]], mean(coef(reg_ES)[4:9]))
aggte(CS)
all.equal(coef(reg_DD_trunc)[[1]], suppressWarnings(did::aggte(reg_CS)$overall.att))
base_period = "universal"
all.equal(coef(reg_ES)[4:9], reg_CS$att[5:10], check.attributes = FALSE)
all.equal(round(coef(reg_ES)[4:9],5), reg_CH_24_effct_6$results$Effects[,"Estimate"], check.attributes = FALSE)
~~~{=comment}
rmarkdown::render('vignettes/Event_study_vs_Callaway_vs_Chaisemartin.Rmd', output_format= c("md_document", "html_document")) ~~~
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.