diff_diff.PowerResults

class diff_diff.PowerResults[source]

Bases: object

Results from analytical power analysis.

power

Statistical power (probability of rejecting H0 when effect exists).

Type:

float

mde

Minimum detectable effect size.

Type:

float

required_n

Required total sample size (treated + control).

Type:

int

effect_size

Effect size used in calculation.

Type:

float

alpha

Significance level.

Type:

float

alternative

Alternative hypothesis (‘two-sided’, ‘greater’, ‘less’).

Type:

str

n_treated

Number of treated units.

Type:

int

n_control

Number of control units.

Type:

int

n_pre

Number of pre-treatment periods.

Type:

int

n_post

Number of post-treatment periods.

Type:

int

sigma

Residual standard deviation.

Type:

float

rho

Intra-cluster correlation (for panel data).

Type:

float

design

Study design type (‘basic_did’, ‘panel’, ‘staggered’).

Type:

str

__init__(power, mde, required_n, effect_size, alpha, alternative, n_treated, n_control, n_pre, n_post, sigma, rho=0.0, design='basic_did')
Parameters:
Return type:

None

Methods

__init__(power, mde, required_n, ...[, rho, ...])

print_summary()

Print the summary to stdout.

summary()

Generate a formatted summary of power analysis results.

to_dataframe()

Convert results to a pandas DataFrame.

to_dict()

Convert results to a dictionary.

Attributes

design

rho

power

mde

required_n

effect_size

alpha

alternative

n_treated

n_control

n_pre

n_post

sigma

power: float
mde: float
required_n: int
effect_size: float
alpha: float
alternative: str
n_treated: int
n_control: int
n_pre: int
n_post: int
sigma: float
rho: float = 0.0
design: str = 'basic_did'
__repr__()[source]

Concise string representation.

Return type:

str

summary()[source]

Generate a formatted summary of power analysis results.

Returns:

Formatted summary table.

Return type:

str

print_summary()[source]

Print the summary to stdout.

Return type:

None

to_dict()[source]

Convert results to a dictionary.

Returns:

Dictionary containing all power analysis results.

Return type:

Dict[str, Any]

to_dataframe()[source]

Convert results to a pandas DataFrame.

Returns:

DataFrame with power analysis results.

Return type:

pd.DataFrame

__init__(power, mde, required_n, effect_size, alpha, alternative, n_treated, n_control, n_pre, n_post, sigma, rho=0.0, design='basic_did')
Parameters:
Return type:

None