diff_diff.SyntheticDiDResults#
- class diff_diff.SyntheticDiDResults[source]#
Bases:
objectResults from a Synthetic Difference-in-Differences estimation.
Combines DiD with synthetic control by re-weighting control units to match pre-treatment trends of treated units.
- unit_weights#
Dictionary mapping control unit IDs to their synthetic weights. When survey weights are used, these are the composed effective weights (omega_eff = raw Frank-Wolfe * survey, renormalized) that were applied to produce the ATT, not the raw Frank-Wolfe solution.
- Type:
- variance_method#
Method used for variance estimation:
"bootstrap"(paper-faithful pairs bootstrap re-estimating ω and λ via Frank-Wolfe on each draw; Arkhangelsky et al. 2021 Algorithm 2 step 2, and R’s defaultsynthdid::vcov(method="bootstrap")),"jackknife", or"placebo".- Type:
- placebo_effects#
Method-specific per-iteration estimates: placebo treatment effects (for
"placebo"), bootstrap ATT estimates with re-estimated weights per draw (for"bootstrap"), or leave-one-out estimates (for"jackknife"). Thevariance_methodfield disambiguates the contents.- Type:
np.ndarray, optional
- synthetic_pre_trajectory#
Synthetic control trajectory in pre-treatment periods, shape
(n_pre,). Equal toY_pre_control @ omega_effwhereomega_effis the composed effective weight vector.- Type:
np.ndarray, optional
- synthetic_post_trajectory#
Synthetic control trajectory in post-treatment periods, shape
(n_post,).- Type:
np.ndarray, optional
- treated_pre_trajectory#
Treated-unit mean trajectory in pre-treatment periods, shape
(n_pre,). Survey-weighted when the fit used survey weights.- Type:
np.ndarray, optional
- treated_post_trajectory#
Treated-unit mean trajectory in post-treatment periods, shape
(n_post,).- Type:
np.ndarray, optional
- time_weights_array#
The Frank-Wolfe time weights as a 1-D array (same values as the
time_weightsdict but order-stable and usable for re-estimation by sensitivity methods). Shape(n_pre,).- Type:
np.ndarray, optional
Methods
__init__(att, se, t_stat, p_value, conf_int, ...)get_loo_effects_df()Per-unit leave-one-out ATT from the jackknife variance pass.
get_time_weights_df()Get time weights as a pandas DataFrame.
get_unit_weights_df()Get unit weights as a pandas DataFrame.
get_weight_concentration([top_k])Concentration metrics for the control unit weights.
in_time_placebo([fake_treatment_periods, ...])Re-estimate the ATT on shifted fake treatment periods within the original pre-treatment window.
print_summary([alpha])Print the summary to stdout.
sensitivity_to_zeta_omega([zeta_grid, ...])Re-estimate the ATT across a grid of
zeta_omegavalues to show how sensitive the estimate is to the unit-weight regularization.summary([alpha])Generate a formatted summary of the estimation results.
to_dataframe()Convert results to a pandas DataFrame.
to_dict()Convert results to a dictionary.
Attributes
alphacoef_varSE / abs(ATT).
is_significantCheck if the ATT is statistically significant at the alpha level.
n_bootstrapnoise_levelpre_treatment_fitsignificance_starsReturn significance stars based on p-value.
survey_metadatazeta_lambdazeta_omega- __init__(att, se, t_stat, p_value, conf_int, n_obs, n_treated, n_control, unit_weights, time_weights, pre_periods, post_periods, alpha=0.05, variance_method='placebo', noise_level=None, zeta_omega=None, zeta_lambda=None, pre_treatment_fit=None, placebo_effects=None, n_bootstrap=None, survey_metadata=None, synthetic_pre_trajectory=None, synthetic_post_trajectory=None, treated_pre_trajectory=None, treated_post_trajectory=None, time_weights_array=None)#
- Parameters:
att (float)
se (float)
t_stat (float)
p_value (float)
n_obs (int)
n_treated (int)
n_control (int)
alpha (float)
variance_method (str)
noise_level (float | None)
zeta_omega (float | None)
zeta_lambda (float | None)
pre_treatment_fit (float | None)
placebo_effects (ndarray | None)
n_bootstrap (int | None)
survey_metadata (Any | None)
synthetic_pre_trajectory (ndarray | None)
synthetic_post_trajectory (ndarray | None)
treated_pre_trajectory (ndarray | None)
treated_post_trajectory (ndarray | None)
time_weights_array (ndarray | None)
- Return type:
None
- classmethod __new__(*args, **kwargs)#