diff_diff.MultiPeriodDiDResults
- class diff_diff.MultiPeriodDiDResults[source]
Bases:
objectResults from a Multi-Period Difference-in-Differences estimation.
Provides access to period-specific treatment effects as well as an aggregate average treatment effect.
- period_effects
Dictionary mapping period identifiers to their PeriodEffect objects. Contains all estimated period effects (pre and post, excluding the reference period which is normalized to zero).
- Type:
dict[any, PeriodEffect]
- reference_period
The reference (omitted) period. Its coefficient is zero by construction and it is excluded from
period_effects.- Type:
any, optional
- interaction_indices
Mapping from period identifier to column index in the full variance-covariance matrix. Used internally for sub-VCV extraction (e.g., by HonestDiD and PreTrendsPower).
- Type:
dict, optional
- __init__(period_effects, avg_att, avg_se, avg_t_stat, avg_p_value, avg_conf_int, n_obs, n_treated, n_control, pre_periods, post_periods, alpha=0.05, coefficients=None, vcov=None, residuals=None, fitted_values=None, r_squared=None, reference_period=None, interaction_indices=None)
- Parameters:
period_effects (Dict[Any, PeriodEffect])
avg_att (float)
avg_se (float)
avg_t_stat (float)
avg_p_value (float)
n_obs (int)
n_treated (int)
n_control (int)
alpha (float)
vcov (ndarray | None)
residuals (ndarray | None)
fitted_values (ndarray | None)
r_squared (float | None)
reference_period (Any | None)
- Return type:
None
Methods
__init__(period_effects, avg_att, avg_se, ...)get_effect(period)Get the treatment effect for a specific period.
print_summary([alpha])Print the summary to stdout.
summary([alpha])Generate a formatted summary of the estimation results.
Convert period-specific effects to a pandas DataFrame.
to_dict()Convert results to a dictionary.
Attributes
Check if the average ATT is statistically significant at the alpha level.
Post-period effects only.
Pre-period effects only (for parallel trends assessment).
Return significance stars for the average ATT based on p-value.
- period_effects: Dict[Any, PeriodEffect]
- property pre_period_effects: Dict[Any, PeriodEffect]
Pre-period effects only (for parallel trends assessment).
- property post_period_effects: Dict[Any, PeriodEffect]
Post-period effects only.
- print_summary(alpha=None)[source]
Print the summary to stdout.
- Parameters:
alpha (float | None)
- Return type:
None
- get_effect(period)[source]
Get the treatment effect for a specific period.
- Parameters:
period (any) – The period identifier.
- Returns:
The treatment effect for the specified period.
- Return type:
- Raises:
KeyError – If the period is not found in post-treatment periods.
- to_dict()[source]
Convert results to a dictionary.
- Returns:
Dictionary containing all estimation results.
- Return type:
Dict[str, Any]
- to_dataframe()[source]
Convert period-specific effects to a pandas DataFrame.
- Returns:
DataFrame with one row per estimated period (pre and post).
- Return type:
pd.DataFrame
- property is_significant: bool
Check if the average ATT is statistically significant at the alpha level.
- __init__(period_effects, avg_att, avg_se, avg_t_stat, avg_p_value, avg_conf_int, n_obs, n_treated, n_control, pre_periods, post_periods, alpha=0.05, coefficients=None, vcov=None, residuals=None, fitted_values=None, r_squared=None, reference_period=None, interaction_indices=None)
- Parameters:
period_effects (Dict[Any, PeriodEffect])
avg_att (float)
avg_se (float)
avg_t_stat (float)
avg_p_value (float)
n_obs (int)
n_treated (int)
n_control (int)
alpha (float)
vcov (ndarray | None)
residuals (ndarray | None)
fitted_values (ndarray | None)
r_squared (float | None)
reference_period (Any | None)
- Return type:
None