diff_diff.ImputationDiDResults

class diff_diff.ImputationDiDResults[source]

Bases: object

Results from Borusyak-Jaravel-Spiess (2024) imputation DiD estimation.

treatment_effects

Unit-level treatment effects with columns: unit, time, tau_hat, weight.

Type:

pd.DataFrame

overall_att

Overall average treatment effect on the treated.

Type:

float

overall_se

Standard error of overall ATT.

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 relative 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

groups

List of treatment cohorts.

Type:

list

time_periods

List of all time periods.

Type:

list

n_obs

Total number of observations.

Type:

int

n_treated_obs

Number of treated observations (|Omega_1|).

Type:

int

n_untreated_obs

Number of untreated observations (|Omega_0|).

Type:

int

n_treated_units

Number of ever-treated units.

Type:

int

n_control_units

Number of units contributing to Omega_0.

Type:

int

alpha

Significance level used.

Type:

float

pretrend_results

Populated by pretrend_test().

Type:

dict, optional

bootstrap_results

Bootstrap inference results.

Type:

ImputationBootstrapResults, optional

__init__(treatment_effects, overall_att, overall_se, overall_t_stat, overall_p_value, overall_conf_int, event_study_effects, group_effects, groups, time_periods, n_obs, n_treated_obs, n_untreated_obs, n_treated_units, n_control_units, alpha=0.05, pretrend_results=None, bootstrap_results=None, _estimator_ref=None)
Parameters:
Return type:

None

Methods

__init__(treatment_effects, overall_att, ...)

pretrend_test([n_leads])

Run a pre-trend test (Equation 9 of Borusyak et al. 2024).

print_summary([alpha])

Print summary to stdout.

summary([alpha])

Generate formatted summary of estimation results.

to_dataframe([level])

Convert results to DataFrame.

Attributes

alpha

bootstrap_results

is_significant

Check if overall ATT is significant.

pretrend_results

significance_stars

Significance stars for overall ATT.

treatment_effects

overall_att

overall_se

overall_t_stat

overall_p_value

overall_conf_int

event_study_effects

group_effects

groups

time_periods

n_obs

n_treated_obs

n_untreated_obs

n_treated_units

n_control_units

treatment_effects: DataFrame
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
groups: List[Any]
time_periods: List[Any]
n_obs: int
n_treated_obs: int
n_untreated_obs: int
n_treated_units: int
n_control_units: int
alpha: float = 0.05
pretrend_results: Dict[str, Any] | None = None
bootstrap_results: ImputationBootstrapResults | None = None
__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='observation')[source]

Convert results to DataFrame.

Parameters:

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

Returns:

Results as DataFrame.

Return type:

pd.DataFrame

pretrend_test(n_leads=None)[source]

Run a pre-trend test (Equation 9 of Borusyak et al. 2024).

Adds pre-treatment lead indicators to the Step 1 OLS and tests their joint significance via a cluster-robust Wald F-test.

Parameters:

n_leads (int, optional) – Number of pre-treatment leads to include. If None, uses all available pre-treatment periods minus one (for the reference period).

Returns:

Dictionary with keys: ‘f_stat’, ‘p_value’, ‘df’, ‘n_leads’, ‘lead_coefficients’.

Return type:

dict

property is_significant: bool

Check if overall ATT is significant.

property significance_stars: str

Significance stars for overall ATT.

__init__(treatment_effects, overall_att, overall_se, overall_t_stat, overall_p_value, overall_conf_int, event_study_effects, group_effects, groups, time_periods, n_obs, n_treated_obs, n_untreated_obs, n_treated_units, n_control_units, alpha=0.05, pretrend_results=None, bootstrap_results=None, _estimator_ref=None)
Parameters:
Return type:

None