diff_diff.StackedDiDResults

class diff_diff.StackedDiDResults[source]

Bases: object

Results from Stacked DiD estimation (Wing, Freedman & Hollingsworth 2024).

overall_att

Overall average treatment effect on the treated (average of post-treatment event-study coefficients).

Type:

float

overall_se

Standard error of overall ATT (delta method on VCV).

Type:

float

overall_t_stat

T-statistic for overall ATT.

Type:

float

overall_p_value

P-value for overall ATT.

Type:

float

overall_conf_int

Confidence interval for overall ATT.

Type:

tuple

event_study_effects

Dictionary mapping event time h to effect dict with keys: ‘effect’, ‘se’, ‘t_stat’, ‘p_value’, ‘conf_int’, ‘n_obs’.

Type:

dict, optional

group_effects

Dictionary mapping cohort g to effect dict.

Type:

dict, optional

stacked_data

Full stacked dataset with _sub_exp, _event_time, _D_sa, _Q_weight columns. Accessible for custom analysis.

Type:

pd.DataFrame

groups

Adoption events in the trimmed set (Omega_kappa).

Type:

list

trimmed_groups

Adoption events excluded by IC1/IC2.

Type:

list

time_periods

All time periods in the original data.

Type:

list

n_obs

Number of observations in the original data.

Type:

int

n_stacked_obs

Number of observations in the stacked dataset.

Type:

int

n_sub_experiments

Number of sub-experiments in the stack.

Type:

int

n_treated_units

Distinct treated units across trimmed set.

Type:

int

n_control_units

Distinct control units across trimmed set.

Type:

int

kappa_pre

Pre-treatment event-time window size.

Type:

int

kappa_post

Post-treatment event-time window size.

Type:

int

weighting

Weighting scheme used.

Type:

str

clean_control

Clean control definition used.

Type:

str

alpha

Significance level used.

Type:

float

__init__(overall_att, overall_se, overall_t_stat, overall_p_value, overall_conf_int, event_study_effects, group_effects, stacked_data, groups=<factory>, trimmed_groups=<factory>, time_periods=<factory>, n_obs=0, n_stacked_obs=0, n_sub_experiments=0, n_treated_units=0, n_control_units=0, kappa_pre=1, kappa_post=1, weighting='aggregate', clean_control='not_yet_treated', alpha=0.05)
Parameters:
Return type:

None

Methods

__init__(overall_att, overall_se, ...[, ...])

print_summary([alpha])

Print summary to stdout.

summary([alpha])

Generate formatted summary of estimation results.

to_dataframe([level])

Convert results to DataFrame.

Attributes

alpha

clean_control

is_significant

Check if overall ATT is significant.

kappa_post

kappa_pre

n_control_units

n_obs

n_stacked_obs

n_sub_experiments

n_treated_units

significance_stars

Significance stars for overall ATT.

weighting

overall_att

overall_se

overall_t_stat

overall_p_value

overall_conf_int

event_study_effects

group_effects

stacked_data

groups

trimmed_groups

time_periods

overall_att: float
overall_se: float
overall_t_stat: float
overall_p_value: float
overall_conf_int: Tuple[float, float]
event_study_effects: Dict[int, Dict[str, Any]] | None
group_effects: Dict[Any, Dict[str, Any]] | None
stacked_data: DataFrame
groups: List[Any]
trimmed_groups: List[Any]
time_periods: List[Any]
n_obs: int = 0
n_stacked_obs: int = 0
n_sub_experiments: int = 0
n_treated_units: int = 0
n_control_units: int = 0
kappa_pre: int = 1
kappa_post: int = 1
weighting: str = 'aggregate'
clean_control: str = 'not_yet_treated'
alpha: float = 0.05
__repr__()[source]

Concise string representation.

Return type:

str

summary(alpha=None)[source]

Generate formatted summary of estimation results.

Parameters:

alpha (float, optional) – Significance level. Defaults to alpha used in estimation.

Returns:

Formatted summary.

Return type:

str

print_summary(alpha=None)[source]

Print summary to stdout.

Parameters:

alpha (float | None)

Return type:

None

to_dataframe(level='event_study')[source]

Convert results to DataFrame.

Parameters:

level (str, default="event_study") – Level of aggregation: - “event_study”: Event study effects by relative time - “group”: Group (cohort) effects

Returns:

Results as DataFrame.

Return type:

pd.DataFrame

property is_significant: bool

Check if overall ATT is significant.

property significance_stars: str

Significance stars for overall ATT.

__init__(overall_att, overall_se, overall_t_stat, overall_p_value, overall_conf_int, event_study_effects, group_effects, stacked_data, groups=<factory>, trimmed_groups=<factory>, time_periods=<factory>, n_obs=0, n_stacked_obs=0, n_sub_experiments=0, n_treated_units=0, n_control_units=0, kappa_pre=1, kappa_post=1, weighting='aggregate', clean_control='not_yet_treated', alpha=0.05)
Parameters:
Return type:

None