| did_wrapper | R Documentation |
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
)
data |
Input data frame. |
Y |
Outcome variable name (string). |
D |
Treatment indicator variable name (string). |
X |
Optional covariate vector for adjustment. |
index |
Character vector of unit and time variable names, e.g., |
method |
DiD method: |
se |
Standard error method: |
nboots |
Number of bootstrap replications (if applicable). |
parallel |
Logical; use parallel computation for bootstrapping. |
core |
Number of CPU cores to use if |
time_to_treat_var |
Name of time-to-treatment variable; used internally. |
treat_indicator |
Name of treatment cohort indicator variable; used internally. |
csdid.base_period |
Baseline period choice for Callaway–Sant'Anna estimators. |
didm.effects |
Effects vector for |
didm.placebo |
Placebo vector for |
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.
A list of class "did_wrapper":
est.avg |
Data frame with overall ATT, standard error, confidence interval, and p-value. |
est.att |
Event-study ATT estimates by relative period, including standard errors and confidence intervals. |
Rivka Lipkovitz
## Not run:
result_twfe <- did_wrapper(
data = df,
Y = "outcome",
D = "treat",
index = c("id", "time"),
method = "twfe"
)
result_twfe$est.avg
result_twfe$est.att
## End(Not run)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.