
Synthetic Difference-in-Differences (Arkhangelsky et al., 2021)
Source:R/did.R
morie_did_synthetic.RdNative synthetic difference-in-differences estimator (the
Arkhangelsky et al. 2021 algorithm: ridge-regularized unit weights,
simplex time weights, weighted DiD) with bootstrap inference. The
engine lives in R/synth_native.R; see also
morie_synth_control for the classic Abadie synthetic
control with placebo inference.
Usage
morie_did_synthetic(
data,
outcome,
unit,
time,
treatment_time,
treated_units = NULL,
zeta = NULL,
n_bootstrap = 200L,
seed = 42L,
alpha = 0.05
)Arguments
- data
Balanced panel.
- outcome, unit, time, treatment_time
Column names.
- treated_units
Optional explicit list of treated unit IDs.
- zeta
Retained for back-compat; ignored (the engine derives the SDID regularisation from the data).
- n_bootstrap
Bootstrap replications for the SE / CI.
- seed
RNG seed.
- alpha
Significance level.
Value
A result list; see morie_did_2x2.
References
Arkhangelsky, D., et al. (2021). Synthetic difference-in-differences. American Economic Review, 111(12), 4088–4118.
Examples
set.seed(3)
df <- expand.grid(unit = 1:30, time = 1:8)
df$treat_time <- ifelse(df$unit <= 5, 6, Inf)
df$d <- as.integer(df$time >= df$treat_time)
df$y <- 0.1 * df$time + 0.5 * df$d + rnorm(nrow(df), sd = 0.3)
out <- morie_did_synthetic(df, "y", "unit", "time", "treat_time",
n_bootstrap = 50L, seed = 3)
str(out, max.level = 1)
#> List of 10
#> $ estimate : num 0.598
#> $ std_error: num 0.0726
#> $ t_stat : num 8.25
#> $ p_value : num 1.65e-16
#> $ ci_lower : num 0.456
#> $ ci_upper : num 0.741
#> $ n_treated: int 5
#> $ n_control: int 25
#> $ method : chr "synthetic_did (rmorie native)"
#> $ details :List of 3