diff_diff.SyntheticDiDResults#

class diff_diff.SyntheticDiDResults[source]#

Bases: BaseResults

Results 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.

att#

Average Treatment effect on the Treated (ATT).

Type:

float

se#

Standard error of the ATT estimate (bootstrap, jackknife, or placebo-based).

Type:

float

t_stat#

T-statistic for the ATT estimate.

Type:

float

p_value#

P-value for the null hypothesis that ATT = 0.

Type:

float

conf_int#

Confidence interval for the ATT.

Type:

tuple[float, float]

n_obs#

Number of observations used in estimation.

Type:

int

n_treated#

Number of treated units/observations.

Type:

int

n_control#

Number of control units/observations.

Type:

int

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:

dict

time_weights#

Dictionary mapping pre-treatment periods to their time weights.

Type:

dict

pre_periods#

List of pre-treatment period identifiers.

Type:

list

post_periods#

List of post-treatment period identifiers.

Type:

list

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 default synthdid::vcov(method="bootstrap")), "jackknife", or "placebo".

Type:

str

variance_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"). The variance_method field disambiguates the contents. (The deprecated read-only alias placebo_effects returns this array and is removed in v4.0.0.)

Type:

np.ndarray, optional

pre_treatment_fit#

Shape-only pre-treatment fit: the RMSE of the pre-period residual (treated mean minus synthetic control) after removing its mean. The Frank-Wolfe unit weights are fit on column-centered outcomes, so a constant level gap is not a fit failure (SDID differences it out) and is excluded here. NaN with a single pre-period.

Type:

float, optional

pre_treatment_level_gap#

Signed mean pre-period gap, treated minus synthetic control. This is the constant offset absorbed by the DiD step; it is reported for inspection and never enters the poor-fit warning.

Type:

float, optional

pre_fit_placebo_rmse#

Reference distribution for pre_treatment_fit: the shape-only pre-fit RMSE of each placebo fit in which a random set of n_treated control units is treated as if treated and the unit weights are re-estimated on the remaining controls (Algorithm 4 draws, fit-time zeta). At most 20 draws (min(n_bootstrap, 20)); None when no placebo fit is possible (no pseudo-control left, or a single pre-period).

Type:

np.ndarray, optional

pre_fit_placebo_pvalue#

(1 + #{placebo RMSE >= treated RMSE}) / (1 + n_draws): the plus-one-adjusted rank of the treated units’ fit among the placebo fits — a fit diagnostic, not a treatment-effect p-value. The poor-fit warning fires at <= 0.05 (in-space placebo fit assessment, Abadie, Diamond & Hainmueller 2010; Abadie 2021), which needs at least 19 successful draws to be reachable.

Type:

float, optional

synthetic_pre_trajectory#

Synthetic control trajectory in pre-treatment periods, shape (n_pre,). Equal to Y_pre_control @ omega_eff where omega_eff is 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_weights dict 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_omega values 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

alpha

coef_var

SE / abs(ATT).

is_significant

Check if the ATT is statistically significant at the alpha level.

n_bootstrap

noise_level

placebo_effects

Deprecated alias for variance_effects (removed in v4.0.0).

pre_fit_placebo_pvalue

pre_fit_placebo_rmse

pre_treatment_fit

pre_treatment_level_gap

significance_stars

Return significance stars based on p-value.

survey_metadata

synthetic_post_trajectory

synthetic_pre_trajectory

time_weights_array

treated_post_trajectory

treated_pre_trajectory

variance_effects

variance_method

zeta_lambda

zeta_omega

att

se

t_stat

p_value

conf_int

n_obs

n_treated

n_control

unit_weights

time_weights

pre_periods

post_periods

__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, pre_treatment_level_gap=None, pre_fit_placebo_rmse=None, pre_fit_placebo_pvalue=None, variance_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:
Return type:

None

classmethod __new__(*args, **kwargs)#