Reference
Types
MSC.MSCFit — Type
MSCFitFitted multivariate synthetic-control model. theta is an n_controls x n_treated matrix mapping control outcomes to treated counterfactual outcomes.
MSC.MSCEstimate — Type
MSCEstimatePoint estimate and fitted object for an MSC ATT analysis. Rows of counterfactual are post-treatment periods and columns are treated units.
MSC.MSCPanel — Type
MSCPanelBalanced panel in matrix form. Rows 1:N0 are controls, rows N0+1:end are treated, columns 1:T0 are pre-treatment periods, and remaining columns are post-treatment periods.
Estimation
MSC.fit_msc — Function
fit_msc(Xpre, Ypre; kwargs...)Fit the multivariate synthetic-control model from pre-treatment matrices.
Xpre is T0 x n_controls; Ypre is T0 x n_treated. The returned coefficient matrix maps controls to treated counterfactuals.
MSC.msc_estimate — Function
msc_estimate(Y, N0, T0; kwargs...)Estimate ATT from an outcome panel matrix. Rows 1:N0 are controls, remaining rows are treated. Columns 1:T0 are pre-treatment periods.
MSC.predict_counterfactual — Function
predict_counterfactual(fit, Xpost)Predict untreated counterfactual outcomes for treated units. Xpost is Tpost x n_controls; the result is Tpost x n_treated.
MSC.att — Function
att(fit, Xpost, Ytreated_post)Estimate ATT from a fitted MSC model and post-treatment outcomes.
MSC.objective — Function
objective(X, Y, theta, lambda)Evaluate the MSC objective (1 / sqrt(size(X, 1))) * ||Y - X * theta||_* + lambda * ||theta||_1.
MSC.coef — Function
coef(fit)Return the n_controls x n_treated MSC weight matrix.
Panel Helpers and Simulation
MSC.panel_matrices — Function
panel_matrices(table, unit, time, outcome, treatment; treated_last=true)Convert a balanced long panel to MSCPanel. Treatment must follow a common-adoption design: controls are never treated, treated units are untreated through T0 and treated in every post-treatment period.
MSC.simulate_msc — Function
simulate_msc(; kwargs...)Generate a low-dimensional synthetic-control simulation with many treated units. Returns a named tuple with Y, N0, T0, true theta, untreated counterfactuals, and metadata.
Diagnostics
MSC.fitted_pre — Function
fitted_pre(fit, Xpre)Return fitted treated-unit outcomes in the pre-treatment period.
MSC.residuals — Function
residuals(fit, Xpre, Ypre)Return pre-treatment residuals Ypre - fitted_pre(fit, Xpre).
MSC.prefit_rmse — Function
prefit_rmse(fit, Xpre, Ypre)Root mean squared pre-treatment fitting error.
MSC.effect_matrix — Function
effect_matrix(est)Return post-treatment effects by period and treated unit.
MSC.effect_curve — Function
effect_curve(est)Average treatment effect by post-treatment period.
MSC.unit_effects — Function
unit_effects(est)Average treatment effect by treated unit.
MSC.weights_table — Function
weights_table(fit; units=nothing, treated_units=nothing)Return the estimated weight matrix as a DataFrame with one row per nonzero control-treated pair.
MSC.cv_table — Function
cv_table(fit)Return cross-validation errors by lambda. If the model was fit without CV, the error column is missing.
Placebos
MSC.placebo — Function
placebo(est; T0_placebo=nothing, kwargs...)Move the treatment date into the pre-treatment period and estimate a placebo ATT.
placebo(Y, N0, T0; T0_placebo=floor(Int, T0/2), kwargs...)Estimate a time-placebo effect using only the original pre-treatment periods.
MSC.placebo_distribution — Function
placebo_distribution(Y, N0, T0; replications=100, ntreated=nothing, kwargs...)Randomly assign control units to placebo treatment groups and estimate MSC effects using the original treatment date. This is most useful when N0 is much larger than the number of treated units.
MSC.placebo_se — Function
placebo_se(Y, N0, T0; kwargs...)Standard deviation of placebo_distribution.