diff_diff.PreTrendsPowerResults#

class diff_diff.PreTrendsPowerResults[source]#

Bases: object

Results from pre-trends power analysis.

power#

Power to detect the specified violation pattern at given alpha.

Type:

float

mdv#

Minimum detectable violation (smallest M detectable at target power).

Type:

float

violation_magnitude#

The magnitude of violation tested (M parameter).

Type:

float

violation_type#

Type of violation pattern (‘linear’, ‘constant’, ‘last_period’, ‘custom’).

Type:

str

alpha#

Significance level for the pre-trends test.

Type:

float

target_power#

Target power level used for MDV calculation.

Type:

float

n_pre_periods#

Number of pre-treatment periods in the event study.

Type:

int

test_statistic#

Expected test statistic under the specified violation (Wald only; NaN for NIS fits).

Type:

float

critical_value#

Critical value for the pre-trends test.

Type:

float

noncentrality#

Non-centrality parameter under the alternative hypothesis (Wald only; NaN for NIS fits).

Type:

float

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 form delta' Sigma_22^{-1} delta — paper-supported alternative, retained for backwards compatibility with shipped numerical baselines).

Type:

str

nis_box_probability#

Acceptance probability P(beta_hat_pre in B_NIS(Sigma)) under the alternative M * weights. NIS-only; NaN for Wald fits.

Type:

float

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 M always matches the documented per-pattern contract:

  • linear threaded with relative_times (post PR-B Step 4): |t| directly, NOT L2-normalized, so δ_t = M·|t| and the reported MDV equals Roth’s γ exactly.

  • linear without relative_times (legacy): [n_pre-1, ..., 0] L2-normalized.

  • constant (post PR-B R13): [1, ..., 1] directly, NOT L2-normalized, so δ_t = M is 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 None here; power_at() falls back to reconstruction in that case (with the PR-A NotImplementedError guard retained only for violation_type='custom' with violation_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_source

is_informative

Check if the pre-trends test is informative.

max_abs_pre_violation

Largest level-scale pre-period deviation under the MDV.

nis_box_probability

original_results

power_adequate

Check if power meets the target threshold.

pretest_form

violation_weights

power

mdv

violation_magnitude

violation_type

alpha

target_power

n_pre_periods

test_statistic

critical_value

noncentrality

pre_period_effects

pre_period_ses

vcov

__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:
Return type:

None

classmethod __new__(*args, **kwargs)#