understudy fits the synthetic difference-in-differences (SDID)
estimator of Arkhangelsky et al. (2021) with the Frank-Wolfe weight
solver written in Rust (via
extendr) and an lm()-style
interface. Beyond the core estimator it adds:
- staggered adoption with cohort aggregation, and event-study
dynamic effects (
event_study()); - conformal inference for the per-period counterfactual
(
augment(),conformal_test()), valid with a single treated unit; - two covariate-adjustment methods (
projected, andoptimized).
Point estimates are validated to match the reference implementations
exactly: the R packages
synthdid and
xsynthdid, and the Stata
sdid library.
Installation compiles Rust, so a Rust
toolchain (cargo, rustc)
is required. Then, from
GitHub:
# install.packages("pak")
pak::pak("belian-earth/understudy")Estimate the effect of California’s Proposition 99 on cigarette sales,
and read off a check_model()-style diagnostic.
library(understudy)
fit <- sdid(california_prop99, outcome = PacksPerCapita, unit = State,
time = Year, treatment = treated)
fit
#> ── Synthetic diff-in-diff ──────────────────────────────────────────────────────
#> Call `sdid(data = california_prop99, outcome = PacksPerCapita, unit = State,
#> time = Year, treatment = treated)`
#> Estimate: -15.6
#> Treated: 1 unit × 12 post-periods
#> Controls: 38 units (effective 16.4)
#> Pre-periods: 19 (effective 2.8)
#> Top units: Nevada 0.12, New Hampshire 0.11, Connecticut 0.08 (+25 more)
#> Top periods: 1988 0.43, 1986 0.37, 1987 0.21
#> Standard errors via `summary()` or `vcov()`plot(fit, type = "diagnostic")The panels show the treated-vs-synthetic trajectory, the per-period
effect with a conformal band, each control’s weighted contribution, and
the unit weights. See vignette("getting-started"),
vignette("inference"), vignette("covariates"), and
vignette("staggered") for more.
- Arkhangelsky, Athey, Hirshberg, Imbens & Wager (2021), “Synthetic Difference-in-Differences,” American Economic Review. Reference R package: synthdid.
- Clarke, Pailanir, Athey & Imbens (2023), the Stata sdid command (staggered adoption).
- Kranz (2022), covariate projection, R package xsynthdid.
- Chernozhukov, Wuthrich & Zhu (2021), conformal inference for synthetic controls.
- Greathouse, mlsynth
(Python): the reference implementation for the spatial estimator
(
spatial_sdid()), and the source of the power-analysis and balance diagnostics.
