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 periodsTherefore, the link between DiD and ES/CS is:
a full DiD is equal to the average ES when the ES is computed
against all pre periods (argument trim_low
)
a truncated DiD is equal to the average ES when the DiD’s input contains only one pre period
The Chaisemartin and Haultfeuille (2023) gives the ES coefficients (against the -1 period) BUT:
coefficients are rounded to digits=5
The CH ATE is therefore equal to the EC/CS coefficients.
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)))
#> [1] TRUE
all.equal(coef(reg_DD_trunc)[[1]],
mean(coef(reg_ES)[4:9]))
#> [1] TRUE
aggte(CS)
all.equal(coef(reg_DD_trunc)[[1]],
suppressWarnings(did::aggte(reg_CS)$overall.att))
#> [1] TRUE
base_period = "universal"
all.equal(coef(reg_ES)[4:9],
reg_CS$att[5:10], check.attributes = FALSE)
#> [1] TRUE
all.equal(round(coef(reg_ES)[4:9],5),
reg_CH_24_effct_6$results$Effects[,"Estimate"], check.attributes = FALSE)
#> [1] TRUE
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.