Reference
Estimation
SynthDiD.synthdid_estimate — Function
synthdid_estimate(Y, N0, T0; kwargs...)Compute the synthetic diff-in-diff estimate (Algorithm 1 of Arkhangelsky et al. 2021).
Arguments
Y: N×T outcome matrix. Rows 1:N0 are control units, rows N0+1:N are treated.N0: number of control units.T0: number of pre-treatment periods.X: optional N×T×C covariate array.eta_omega: regularization parameter for omega. Default: (N1*T1)^(1/4).eta_lambda: regularization for lambda. Default: 1e-6.omega_intercept,lambda_intercept: whether to demean when estimating weights.omega,lambda,beta: optional pre-specified values.min_decrease: convergence tolerance.max_iter: maximum iterations.do_sparsify: whether to sparsify weights. Default: true.max_iter_pre_sparsify: iterations before sparsification. Default: 100.units,times: optional vectors of unit/time labels (used for plotting/diagnostics).
SynthDiD.sc_estimate — Function
sc_estimate(Y, N0, T0; kwargs...)Synthetic control estimator. Uses zero time weights and no unit intercept.
SynthDiD.did_estimate — Function
did_estimate(Y, N0, T0; kwargs...)Standard diff-in-diff estimator. Uses uniform weights.
Data Preparation
SynthDiD.panel_matrices — Function
panel_matrices(panel, unit, time, outcome, treatment; covariates=Symbol[], treated_last=true)Convert a long balanced panel DataFrame to matrix format. Returns a NamedTuple (Y, N0, T0, W, X, units, times) where Y is N×T and X is N×T×C.
SynthDiD.california_prop99 — Function
california_prop99()Load the California Proposition 99 dataset (Abadie, Diamond & Hainmueller 2010). Returns a DataFrame with columns: State, Year, PacksPerCapita, treated.
Inference and Diagnostics
SynthDiD.vcov — Function
vcov(est::SynthDiDEstimate; method=:bootstrap, replications=200)Estimate variance. Methods: :bootstrap, :jackknife, :placebo.
SynthDiD.se — Function
se(est::SynthDiDEstimate; method=:bootstrap, replications=200)Standard error of the estimate.
SynthDiD.effect_curve — Function
effect_curve(est::SynthDiDEstimate)Return the per-period treatment effect curve that was averaged to produce the estimate.
SynthDiD.placebo — Function
placebo(est::SynthDiDEstimate; treated_fraction=nothing)Compute a placebo estimate using pre-treatment data only.
SynthDiD.synthdid_controls — Function
synthdid_controls(estimates; sort_by=1, mass=0.9, weight_type="omega")Return a DataFrame of control weights, sorted by magnitude.
weight_type: "omega" for unit weights, "lambda" for time weightsmass: retains controls with cumulative weight ≥ mass (default 90%)sort_by: which estimate to sort by (1-indexed)