diff_diff.SyntheticControlResults#
- class diff_diff.SyntheticControlResults[source]#
Bases:
objectResults from a classic Synthetic Control Method (SCM) estimation.
Implements Abadie, Diamond & Hainmueller (2010), “Synthetic Control Methods for Comparative Case Studies.” A single treated unit’s counterfactual is the convex combination
Σ_j w_j · Y_jtof donor units chosen to match the treated unit’s pre-period outcomes and predictors; the treatment effect path is the gapα̂_1t = Y_1t − Σ_j w_j · Y_jtover the post periods.- att#
Average post-period gap (the reported point estimate). The per-period gaps are in
gap_path.- Type:
- se#
Always NaN — classic SCM has no analytical standard error (inference is permutation/placebo based; see Abadie-Diamond-Hainmueller 2010 §2.4).
- Type:
- t_stat, p_value
Always NaN (no analytical SE).
- Type:
- donor_weights#
Mapping
{donor_unit_id: weight}on the unit simplex. Weights below the interpretability floor (1e-6) are dropped.- Type:
- v_weights#
Mapping
{predictor_label: v}— the diagonal predictor-importance matrix V, trace-normalized to sum to 1. On the degenerate single-donor path (one donor forcesw=[1]) V is unidentified — every V yields the same synthetic — sov_weightsis uniform for everyv_method(includingcv/inverse_variance), with aUserWarningemitted at fit time.- Type:
- predictor_balance#
Predictor-balance table: for each predictor, the treated value, the synthetic value (donor-weighted), and the donor-pool mean. Under
v_method="cv"the reporteddonor_weightscome from the ADH-2015 step-4 refit on the validation-window re-aggregated predictors, so thetreated/synthetic/donor_meanvalues are reported on that same validation-window basis (each spec re-aggregated overpre[v_cv_t0:]) — the row’spredictorlabel remains the full spec identity, so it stays aligned withv_weights. For every otherv_methodthe values are the full-pre-period predictor aggregates.- Type:
- gap_path#
Mapping
{period: gap}for ALL periods (pre periods carry the fit residual used forpre_rmspe; post periods carry the effect path).- Type:
- pre_rmspe#
Root mean squared prediction error over the pre-treatment periods (the primary fit diagnostic).
- Type:
- mspe_v#
The outer-objective value of the selected
V: the pre-period outcome MSPE ofW*(V*)underv_method="nested", or the held-out validation-window outcome MSPE underv_method="cv"(the CV selection criterion). None when there is no outer search — thev_method="custom"and"inverse_variance"paths and the degenerate single-donor path. Not comparable acrossv_methodvalues (different objective windows).- Type:
float, optional
- treated_unit#
The treated unit’s identifier.
- Type:
Any
- pre_periods, post_periods
Calendar-sorted pre / post period values.
- Type:
- v_method#
"nested"(data-driven V),"custom"(user-supplied V),"cv"(out-of-sample cross-validation V), or"inverse_variance"(closed-form1/Var(X)V).- Type:
- v_cv_t0#
The training/validation split index actually used under
v_method="cv"(the resolved value — equalsn_pre_periods // 2when the constructor’sv_cv_t0was None). None for every otherv_method. Survives pickling.- Type:
int, optional
- rmspe_ratio#
The treated unit’s post/pre RMSPE ratio =
sqrt(MSPE_post / MSPE_pre)— the in-space placebo test statistic (ADH 2010 §2.4), computed at fit time.- Type:
- placebo_p_value#
In-space placebo permutation p-value (
rank / (n_placebos + 1)), NaN untilin_space_placebo()is run. SEPARATE from the (always-NaN) analyticalp_value;is_significantstays bound top_value.- Type:
- n_placebos, n_failed
Donor placebos that entered the permutation reference set / were excluded for non-convergence. Both 0 until
in_space_placebo()is run.- Type:
- survey_metadata#
Reserved; always None in this release.
- Type:
Any, optional
- Significance for classic SCM comes from :meth:`in_space_placebo` (opt-in
- in-space placebo permutation inference); :meth:`get_placebo_df` returns the
- per-unit RMSPE-ratio table used for the rank.
Methods
__init__(att, se, t_stat, p_value, conf_int, ...)get_gap_df()Get the gap (effect) path as a DataFrame, in calendar order.
get_in_time_placebo_df()Get the in-time placebo table (see
in_time_placebo()).get_in_time_placebo_gaps()Long-form in-time placebo gap paths, for the backdating overlay plot.
get_leave_one_out_df()Get the leave-one-out donor-robustness table (see
leave_one_out()).get_leave_one_out_gaps()Long-form leave-one-out gap paths, for the overlay ("spaghetti") plot.
get_placebo_df()Get the in-space placebo distribution as a DataFrame (one row per unit).
get_weights_df()Get donor weights as a DataFrame, sorted by weight descending.
in_space_placebo([n_starts])In-space placebo permutation inference (Abadie-Diamond-Hainmueller 2010, Section 2.4).
in_time_placebo([placebo_periods, n_starts])In-time (backdating) placebo (Abadie-Diamond-Hainmueller 2015, Section 4).
leave_one_out([n_starts])Leave-one-out donor robustness (Abadie-Diamond-Hainmueller 2015, Section 4).
print_summary([alpha])Print the summary to stdout.
summary([alpha])Generate a formatted summary of the estimation results.
to_dataframe()Convert scalar results to a single-row pandas DataFrame.
to_dict()Convert scalar results to a dictionary.
Attributes
coef_varSE / abs(ATT).
is_significantAlways False — classic SCM produces no analytical p-value.
n_failedn_placebossignificance_starsSignificance stars based on p-value (empty here — p_value is NaN).
t_statp_valuepre_periodspost_periods- __init__(att, se, t_stat, p_value, conf_int, n_obs, n_donors, n_pre_periods, n_post_periods, donor_weights, v_weights, predictor_balance, gap_path, pre_rmspe, treated_unit, pre_periods, post_periods, v_method, standardize, alpha=0.05, mspe_v=None, v_cv_t0=None, survey_metadata=None, placebo_p_value=nan, rmspe_ratio=nan, n_placebos=0, n_failed=0)#
- Parameters:
att (float)
se (float)
t_stat (float)
p_value (float)
n_obs (int)
n_donors (int)
n_pre_periods (int)
n_post_periods (int)
predictor_balance (DataFrame)
pre_rmspe (float)
treated_unit (Any)
v_method (str)
standardize (str)
alpha (float)
mspe_v (float | None)
v_cv_t0 (int | None)
survey_metadata (Any | None)
placebo_p_value (float)
rmspe_ratio (float)
n_placebos (int)
n_failed (int)
- Return type:
None
- classmethod __new__(*args, **kwargs)#