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.

Type:

float

critical_value

Critical value for the pre-trends test.

Type:

float

noncentrality

Non-centrality parameter under the alternative hypothesis.

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

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

None

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 dictionary.

Attributes

is_informative

Check if the pre-trends test is informative.

original_results

power_adequate

Check if power meets the target threshold.

power

mdv

violation_magnitude

violation_type

alpha

target_power

n_pre_periods

test_statistic

critical_value

noncentrality

pre_period_effects

pre_period_ses

vcov

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 = None
property is_informative: bool

Check if the pre-trends test is informative.

A pre-trends test is considered informative if the MDV is reasonably small relative to typical effect sizes. This is a heuristic check; see the summary for interpretation guidance.

property power_adequate: bool

Check if power meets the target threshold.

summary()[source]

Generate formatted summary of pre-trends power analysis.

Returns:

Formatted summary.

Return type:

str

print_summary()[source]

Print summary to stdout.

Return type:

None

to_dict()[source]

Convert results to dictionary.

Return type:

Dict[str, Any]

to_dataframe()[source]

Convert results to DataFrame.

Return type:

DataFrame

power_at(M)[source]

Compute power to detect a specific violation magnitude.

This method allows computing power at different M values without re-fitting the model, using the stored variance-covariance matrix.

Parameters:

M (float) – Violation magnitude to evaluate.

Returns:

Power to detect violation of magnitude M.

Return type:

float

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

None