Statistical Power & Sample Size
Plan studies with defensible sample sizes, minimum detectable effects, and power curves using both closed-form formulas and Monte Carlo simulation.
Data & AnalyticsIntermediate★ 33,030⑂ 3,248AI score 9/10Last updated: Aug 9, 2026
What it does
- A priori power analysis: give an effect size, α, and target power (typically 0.80/0.90) and get the required n per group and total.
- Closed-form solvers: independent/paired t-tests, one-way ANOVA, one/two proportions, correlation, chi-square (effect size w), and regression R² increments, all through one interface in
scripts/power.py(sample_size,power,mde,power_curve). - Simulation-based power: for designs with no formula — logistic/Poisson regression, mixed-effects models, cluster-randomized trials with an ICC, survival analysis, mediation, interactions — via simulate → fit the planned model → repeat (≥1,000 reps) with a reported Monte Carlo CI.
- Real-world adjustments: multiplicity (α/m or FDR by simulation), attrition (
n_enroll = n/(1−dropout)), clustering design effect (DEFF = 1+(m−1)·ICC), and unequal allocation ratios. - Effect-size guidance and reporting: prefers SESOI over shrunken pilot estimates over Cohen conventions, provides d/f/r/η²/OR/h/w conversions, insists on sensitivity analysis rather than a single number, and explicitly warns against circular post-hoc "observed" power.
Who it's for
- Graduate students and researchers who must justify a sample size in a thesis or paper
- Anyone writing an IRB protocol, grant application, or pre-registration
- Clinical and epidemiological researchers needing enrollment numbers that account for dropout and clustering
- Data analysts sizing A/B tests or computing MDE for a fixed traffic budget
Examples
- "How many per group to detect d = 0.5 at 80% power, α = 0.05?" → returns n per group and total, inflates for 20% attrition, and drafts the reporting paragraph.
- "I can only recruit 30 per group — what can I detect?" → computes the MDE at that n and generates a power-vs-effect-size curve figure for the grant.
- "20 clinics randomized, 30 patients each, ICC = 0.05 — what's my power?" → writes a cluster-simulation script, runs 5,000 replicates, and reports power with a Monte Carlo 95% CI.
· · · Install guide · · ·
Install in the Claude app (no terminal)
- Download the ZIP with the button below.
- In Claude, open Settings → Capabilities and turn on 'Code execution and file creation'. (one time)
- Go to Customize → Skills → + → 'Upload a skill' and upload the ZIP.
Install in Claude Code
Let Claude do it — paste this into Claude Code
Install the skill I found on Claude Skill Mart. Copy the skills/statistical-power folder from the GitHub repo K-Dense-AI/scientific-agent-skills into my ~/.claude/skills/statistical-power/. When it's done, tell me in one line what this skill can do.
Install with a command instead
git clone https://github.com/K-Dense-AI/scientific-agent-skills.git && mkdir -p ~/.claude/skills && cp -r scientific-agent-skills/skills/statistical-power ~/.claude/skills/⚠ This is a third-party skill. Check the source repository before installing.
- Check prerequisites: run
python3 --versionand confirm Python 3.10 or newer; have Claude Code installed. - Create the skills folder:
mkdir -p ~/.claude/skills - Clone the repository:
git clone https://github.com/K-Dense-AI/scientific-agent-skills.git - Copy the skill:
cp -r scientific-agent-skills/skills/statistical-power ~/.claude/skills/ - Install Python packages:
uv pip install "statsmodels>=0.14.6" "scipy>=1.11" "pingouin>=0.6" "numpy>=1.26" matplotlib pandas, plusuv pip install lifelinesif you need survival simulations. Usepip installif you don't have uv. - Verify: restart Claude Code and ask something like "run an a priori power analysis for 80% power" — the skill should trigger automatically.
- Troubleshooting: if you hit a
_lazywhereimport error, upgrade to statsmodels >= 0.14.6 with scipy >= 1.11.
View source on GitHub ↗License: MIT