Skip to content

latent.stats.power

Post-hoc power analysis.

Reference: Standard MDE formula for two-sample proportion test, z-scores via scipy.stats.norm.ppf.

Functions

post_hoc_power

post_hoc_power(sample_size: int, observed_effect: float | None = None, baseline_rate: float = 0.5, alpha: float = 0.05, power: float = 0.8) -> PowerAnalysis

Post-hoc power analysis reporting minimum detectable effect.

Reference: Standard MDE formula for two-sample proportion test. Z-scores via scipy.stats.norm.ppf.

Reports: "With n=X you can detect effects larger than Y% at 80% power."

Args: sample_size: Actual sample size. observed_effect: Observed effect size (optional, for underpowered warning). baseline_rate: Baseline success rate (for binary metrics). alpha: Significance level. power: Desired statistical power.

Returns: PowerAnalysis with MDE and optional warning.