diff_diff.PreTrendsPowerResults#
- class diff_diff.PreTrendsPowerResults[source]#
Bases:
objectResults from pre-trends power analysis.
- violation_type#
Type of violation pattern (‘linear’, ‘constant’, ‘last_period’, ‘custom’).
- Type:
- test_statistic#
Expected test statistic under the specified violation (Wald only; NaN for NIS fits).
- Type:
- noncentrality#
Non-centrality parameter under the alternative hypothesis (Wald only; NaN for NIS fits).
- Type:
- pre_period_effects#
Estimated pre-period effects from the event study.
- Type:
np.ndarray
- pre_period_ses#
Standard errors of pre-period effects.
- Type:
np.ndarray
- vcov#
Variance-covariance matrix of pre-period effects.
- Type:
np.ndarray
- pretest_form#
Pretest acceptance-region form used:
'nis'(no-individually- significant box probability — Roth 2022 Section II.A-B, default for new fits) or'wald'(noncentral-chi-squared on the quadratic formdelta' Sigma_22^{-1} delta— paper-supported alternative, retained for backwards compatibility with shipped numerical baselines).- Type:
- nis_box_probability#
Acceptance probability
P(beta_hat_pre in B_NIS(Sigma))under the alternativeM * weights. NIS-only; NaN for Wald fits.- Type:
- violation_weights#
The violation-direction vector used at fit time. Populated for all violation types on fresh fits. Normalization depends on the type so that
Malways matches the documented per-pattern contract:linearthreaded withrelative_times(post PR-B Step 4):|t|directly, NOT L2-normalized, soδ_t = M·|t|and the reported MDV equals Roth’s γ exactly.linearwithoutrelative_times(legacy):[n_pre-1, ..., 0]L2-normalized.constant(post PR-B R13):[1, ..., 1]directly, NOT L2-normalized, soδ_t = Mis a true per-period level shift.last_period:[0, ..., 0, 1](already unit-norm).custom: user vector L2-normalized to unit norm.
Old serialized results may have
Nonehere;power_at()falls back to reconstruction in that case (with the PR-ANotImplementedErrorguard retained only forviolation_type='custom'withviolation_weights=None).- Type:
np.ndarray, optional
Methods
__init__(power, mdv, violation_magnitude, ...)power_at(M)Compute power to detect a specific violation magnitude.
print_summary()Print summary to stdout.
summary()Generate formatted summary of pre-trends power analysis.
to_dataframe()Convert results to DataFrame.
to_dict()Convert results to JSON-serializable dictionary.
Attributes
covariance_sourceis_informativeCheck if the pre-trends test is informative.
max_abs_pre_violationLargest level-scale pre-period deviation under the MDV.
original_resultspower_adequateCheck if power meets the target threshold.
- __init__(power, mdv, violation_magnitude, violation_type, alpha, target_power, n_pre_periods, test_statistic, critical_value, noncentrality, pre_period_effects, pre_period_ses, vcov, original_results=None, pretest_form='wald', nis_box_probability=nan, violation_weights=None, covariance_source='unknown')#
- Parameters:
power (float)
mdv (float)
violation_magnitude (float)
violation_type (str)
alpha (float)
target_power (float)
n_pre_periods (int)
test_statistic (float)
critical_value (float)
noncentrality (float)
pre_period_effects (ndarray)
pre_period_ses (ndarray)
vcov (ndarray)
original_results (Any | None)
pretest_form (Literal['nis', 'wald'])
nis_box_probability (float)
violation_weights (ndarray | None)
covariance_source (str)
- Return type:
None
- classmethod __new__(*args, **kwargs)#