Implements multiple difference-in-differences (DiD) estimators under a unified interface, supporting overall ATT and event-study estimates across staggered adoption settings.
did_wrapper(
data,
Y,
D,
X = NULL,
index,
method = c("twfe", "st", "iw", "cs_never", "cs_notyet", "didm"),
se = c("default", "boot", "bootstrap", "jackknife"),
nboots = 200,
parallel = TRUE,
core = NULL,
time_to_treat_var = "Time_to_Treatment",
treat_indicator = "treat",
csdid.base_period = "universal",
didm.effects = NA,
didm.placebo = NA
)
A list of class "did_wrapper"
:
Data frame with overall ATT, standard error, confidence interval, and p-value.
Event-study ATT estimates by relative period, including standard errors and confidence intervals.
Input data frame.
Outcome variable name (string).
Treatment indicator variable name (string).
Optional covariate vector for adjustment.
Character vector of unit and time variable names, e.g., c("id", "time")
.
DiD method: "twfe"
, "st"
, "iw"
, "cs_never"
, "cs_notyet"
, or "didm"
.
Standard error method: "default"
, "boot"
, "bootstrap"
, or "jackknife"
.
Number of bootstrap replications (if applicable).
Logical; use parallel computation for bootstrapping.
Number of CPU cores to use if parallel = TRUE
.
Name of time-to-treatment variable; used internally.
Name of treatment cohort indicator variable; used internally.
Baseline period choice for Callaway–Sant'Anna estimators.
Effects vector for didm
; required if method = "didm"
.
Placebo vector for didm
; required if method = "didm"
.
Rivka Lipkovitz
This function:
Drops always-treated units.
Constructs event time and cohort variables.
Computes ATT using the specified DiD method.
Constructs event-study ATT curves.
Optionally estimates bootstrap or jackknife standard errors.
Supported methods include TWFE, stacked DiD, interaction-weighted DiD, Callaway–Sant'Anna estimators, placebo DiD, and DIDmultiplegt.
if (FALSE) {
result_twfe <- did_wrapper(
data = df,
Y = "outcome",
D = "treat",
index = c("id", "time"),
method = "twfe"
)
result_twfe$est.avg
result_twfe$est.att
}
Run the code above in your browser using DataLab