Statistical Power & Sample Size
Calculate required sample size, power, or MDE for the planned analysis. For a fixed
test and its assumptions, sample size, effect size, significance level (α), and
power (1 − β) determine one another. State assumptions and report sensitivity to
plausible effects rather than presenting an unsupported single sample size.
Choose the study structure with experimental-design before calculating power;
return to it when laying out the final allocation. Analysis of collected data is
a separate workflow; use the relevant analysis skill if available.
The one decision that drives everything: the effect size
Power calculations are only as trustworthy as the effect size you feed them. Do not invent a number. Use, in rough order of preference:
- A minimally important effect — the smallest effect that would actually change a decision or matter scientifically/clinically (the "smallest effect size of interest", SESOI). This is the most defensible basis: you power to detect what matters, not what you hope to see.
- A pilot or prior-study estimate, but shrink it — published and pilot effects are inflated by publication bias and the winner's curse. Powering on a raw pilot estimate routinely underpowers the real study.
- A convention (Cohen's small/medium/large) only as a last resort, and say so explicitly.
Whatever you pick, run a sensitivity analysis: report how required n changes across a plausible range of effect sizes, not a single point. A power analysis presented as one number hides its biggest source of uncertainty. See references/effect_sizes.md for benchmarks and conversions between d, f, r, η², odds ratios, and Cohen's h/w.
Avoid post-hoc ("observed") power. Computing power from the effect size you just estimated is circular: it is a deterministic function of the p-value and tells you nothing new. If a study is already done and you want to know what it could have detected, report a sensitivity analysis (MDE at the achieved n) or, better, the confidence interval around the observed effect. This is a common reviewer complaint — do not produce observed power even if asked without flagging the issue.
Select the calculation
| Task |
Read |
| Choose or convert an effect size |
Effect sizes |
| Standard t-tests, ANOVA, proportions, correlations, chi-square, or linear regression |
Closed-form argument tables and recipes |
| GLMs, mixed/repeated-measures models, cluster trials, survival, mediation, interactions, or other nonstandard analyses |
Simulation-based power |
Install dependencies or call bundled power.py / simulate_power.py |
Calculation setup and examples |
| Write or audit a sample-size justification |
Reporting template, pitfalls, and sources |
For simulation, generate realistic data and analyze each replicate with the exact
planned test/model. Report assumptions, simulation count, and the Monte Carlo
confidence interval; small power differences may be simulation noise.
Adjustments people forget
These routinely make the difference between an adequately powered study and an underpowered one. Apply them explicitly and state that you did.
- Multiple comparisons. If the analysis tests m hypotheses with a Bonferroni-style correction, power each test at the corrected α (e.g. α/m), which raises n. Better: power on the family-wise or FDR-controlled procedure directly via simulation. Ignoring this silently underpowers every secondary endpoint.
- Attrition / dropout / unusable samples. Power gives the n you need analyzed. Inflate the enrolled n:
n_enroll = ceil(n_analyzed / (1 − dropout_rate)). A 20% dropout rate means enrolling 25% more than the formula returns.
- Clustering (design effect). When observations are nested (patients within clinics, cells within animals, repeated measures within subject), the effective sample size is smaller than the raw count. Inflate by the design effect
DEFF = 1 + (m − 1)·ICC, where m is cluster size and ICC the intraclass correlation. Treating clustered data as independent is pseudoreplication and badly overstates power — for cluster-randomized designs, simulate instead.
- One- vs. two-sided. Two-sided is the default and almost always the right choice; a one-sided test buys power only by refusing to detect an effect in the unexpected direction. Justify any one-sided test.
- Unequal allocation. Equal groups are most efficient for a fixed total n. If allocation is fixed by design (e.g. 2:1 treatment:control), pass
ratio= so the calculation reflects it.
Workflow
- State the design and the planned analysis. The test you will run determines the power method. If the analysis is a mixed model or GLM, go straight to simulation.
- Choose the effect size on a defensible basis (SESOI > shrunk pilot > convention) and write down the justification.
- Set α and target power. Conventional defaults are α = 0.05 (two-sided) and power = 0.80; 0.90 is common for confirmatory/clinical work. State them.
- Compute with
scripts/power.py (closed-form) or scripts/simulate_power.py (simulation).
- Sensitivity analysis. Recompute across a range of plausible effect sizes and produce a power curve. This is the deliverable, not a single number.
- Apply adjustments for dropout, clustering, and multiplicity.
- Report with the inputs and reproducibility details in the reporting template.
Scripts and completion
scripts/power.py: sample_size, power, mde, and power_curve for standard tests.
scripts/simulate_power.py: simulate_power and find_sample_size, with worked
two-group, logistic, cluster-randomized, and linear mixed-model examples.
The deliverable includes the planned analysis, justified effect-size range, α and
sidedness, target power, allocation, required analyzed/enrolled sample sizes,
dropout/clustering/multiplicity adjustments, and sensitivity results. Include the
data-generating assumptions and Monte Carlo interval for simulations.
When this skill materially contributes to a manuscript, report, presentation, or
code release, follow the current-version citation procedure.
1---2name: statistical-power3description: Calculate study sample size, power, minimum detectable effects, and sensitivity curves for a planned analysis. Use experimental-design to choose or lay out the study; use an analysis workflow for collected data.4license: MIT license5---67# Statistical Power & Sample Size89Calculate required sample size, power, or MDE for the planned analysis. For a fixed10test and its assumptions, sample size, effect size, significance level (α), and11power (1 − β) determine one another. State assumptions and report sensitivity to12plausible effects rather than presenting an unsupported single sample size.1314Choose the study structure with **experimental-design** before calculating power;15return to it when laying out the final allocation. Analysis of collected data is16a separate workflow; use the relevant analysis skill if available.1718## The one decision that drives everything: the effect size1920Power calculations are only as trustworthy as the effect size you feed them. **Do not invent a number.** Use, in rough order of preference:21221. A **minimally important effect** — the smallest effect that would actually change a decision or matter scientifically/clinically (the "smallest effect size of interest", SESOI). This is the most defensible basis: you power to detect what matters, not what you hope to see.232. A **pilot or prior-study estimate**, but shrink it — published and pilot effects are inflated by publication bias and the winner's curse. Powering on a raw pilot estimate routinely underpowers the real study.243. A **convention** (Cohen's small/medium/large) only as a last resort, and say so explicitly.2526Whatever you pick, run a **sensitivity analysis**: report how required n changes across a plausible range of effect sizes, not a single point. A power analysis presented as one number hides its biggest source of uncertainty. See `references/effect_sizes.md` for benchmarks and conversions between d, f, r, η², odds ratios, and Cohen's h/w.2728> **Avoid post-hoc ("observed") power.** Computing power from the effect size you just estimated is circular: it is a deterministic function of the p-value and tells you nothing new. If a study is already done and you want to know what it could have detected, report a **sensitivity analysis** (MDE at the achieved n) or, better, the confidence interval around the observed effect. This is a common reviewer complaint — do not produce observed power even if asked without flagging the issue.2930---3132## Select the calculation3334| Task | Read |35| --- | --- |36| Choose or convert an effect size | [Effect sizes](references/effect_sizes.md) |37| Standard t-tests, ANOVA, proportions, correlations, chi-square, or linear regression | [Closed-form argument tables and recipes](references/closed_form_recipes.md) |38| GLMs, mixed/repeated-measures models, cluster trials, survival, mediation, interactions, or other nonstandard analyses | [Simulation-based power](references/simulation_based_power.md) |39| Install dependencies or call bundled `power.py` / `simulate_power.py` | [Calculation setup and examples](references/calculation_workflow.md) |40| Write or audit a sample-size justification | [Reporting template, pitfalls, and sources](references/reporting.md) |4142For simulation, generate realistic data and analyze each replicate with the exact43planned test/model. Report assumptions, simulation count, and the Monte Carlo44confidence interval; small power differences may be simulation noise.4546## Adjustments people forget4748These routinely make the difference between an adequately powered study and an underpowered one. Apply them explicitly and state that you did.4950- **Multiple comparisons.** If the analysis tests *m* hypotheses with a Bonferroni-style correction, power each test at the corrected α (e.g. α/m), which raises n. Better: power on the family-wise or FDR-controlled procedure directly via simulation. Ignoring this silently underpowers every secondary endpoint.51- **Attrition / dropout / unusable samples.** Power gives the n you need *analyzed*. Inflate the *enrolled* n: `n_enroll = ceil(n_analyzed / (1 − dropout_rate))`. A 20% dropout rate means enrolling 25% more than the formula returns.52- **Clustering (design effect).** When observations are nested (patients within clinics, cells within animals, repeated measures within subject), the effective sample size is smaller than the raw count. Inflate by the design effect `DEFF = 1 + (m − 1)·ICC`, where *m* is cluster size and ICC the intraclass correlation. Treating clustered data as independent is **pseudoreplication** and badly overstates power — for cluster-randomized designs, simulate instead.53- **One- vs. two-sided.** Two-sided is the default and almost always the right choice; a one-sided test buys power only by refusing to detect an effect in the unexpected direction. Justify any one-sided test.54- **Unequal allocation.** Equal groups are most efficient for a fixed total n. If allocation is fixed by design (e.g. 2:1 treatment:control), pass `ratio=` so the calculation reflects it.5556---5758## Workflow59601. **State the design and the planned analysis.** The test you will run determines the power method. If the analysis is a mixed model or GLM, go straight to simulation.612. **Choose the effect size** on a defensible basis (SESOI > shrunk pilot > convention) and write down the justification.623. **Set α and target power.** Conventional defaults are α = 0.05 (two-sided) and power = 0.80; 0.90 is common for confirmatory/clinical work. State them.634. **Compute** with `scripts/power.py` (closed-form) or `scripts/simulate_power.py` (simulation).645. **Sensitivity analysis.** Recompute across a range of plausible effect sizes and produce a power curve. This is the deliverable, not a single number.656. **Apply adjustments** for dropout, clustering, and multiplicity.667. **Report** with the inputs and reproducibility details in [the reporting template](references/reporting.md).6768---6970## Scripts and completion7172- `scripts/power.py`: `sample_size`, `power`, `mde`, and `power_curve` for standard tests.73- `scripts/simulate_power.py`: `simulate_power` and `find_sample_size`, with worked74 two-group, logistic, cluster-randomized, and linear mixed-model examples.7576The deliverable includes the planned analysis, justified effect-size range, α and77sidedness, target power, allocation, required analyzed/enrolled sample sizes,78dropout/clustering/multiplicity adjustments, and sensitivity results. Include the79data-generating assumptions and Monte Carlo interval for simulations.8081When this skill materially contributes to a manuscript, report, presentation, or82code release, follow [the current-version citation procedure](references/reporting.md#citing-scientific-agent-skills).