diff_diff.SyntheticDiDResults#

class diff_diff.SyntheticDiDResults[source]#

Bases: object

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

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"). The variance_method field disambiguates the contents.

Type:

np.ndarray, 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

pre_treatment_fit

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_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, 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:
Return type:

None

classmethod __new__(*args, **kwargs)#