home / skills / dkyazzentwatwa / chatgpt-skills / statistical-power-calculator

statistical-power-calculator skill

/statistical-power-calculator

This skill helps you plan experiments and compute statistical power and sample sizes for t-tests, ANOVA, and more.

npx playbooks add skill dkyazzentwatwa/chatgpt-skills --skill statistical-power-calculator

Review the files below or copy the command above to add this skill to your agents.

Files (3)
SKILL.md
1.4 KB
---
name: statistical-power-calculator
description: Use when asked to calculate statistical power, determine sample size, or plan experiments for hypothesis testing.
---

# Statistical Power Calculator

Calculate statistical power and determine required sample sizes for hypothesis testing and experimental design.

## Purpose

Experiment planning for:
- Clinical trial design
- A/B test planning
- Research study sizing
- Survey sample size determination
- Power analysis and validation

## Features

- **Power Calculation**: Calculate statistical power for tests
- **Sample Size**: Determine required sample size for desired power
- **Effect Size**: Estimate detectable effect size
- **Multiple Tests**: t-test, proportion test, ANOVA, chi-square
- **Visualizations**: Power curves, sample size charts
- **Reports**: Detailed analysis reports with recommendations

## Quick Start

```python
from statistical_power_calculator import PowerCalculator

# Calculate required sample size
calc = PowerCalculator()
result = calc.sample_size_ttest(
    effect_size=0.5,
    alpha=0.05,
    power=0.8
)
print(f"Required n per group: {result.n_per_group}")

# Calculate power
power = calc.power_ttest(n_per_group=100, effect_size=0.5, alpha=0.05)
```

## CLI Usage

```bash
# Calculate sample size for t-test
python statistical_power_calculator.py --test ttest --effect-size 0.5 --power 0.8

# Calculate power
python statistical_power_calculator.py --test ttest --n 100 --effect-size 0.5
```

Overview

This skill calculates statistical power, estimates detectable effect sizes, and determines required sample sizes for hypothesis tests and experiments. It supports common test types and produces numeric results, charts, and concise recommendations to guide study design. Use it to validate experiment sensitivity before data collection and to document design choices for review or ethics submissions.

How this skill works

The tool implements standard power-analysis formulas and numerical solvers for t-tests, proportion tests, ANOVA, and chi-square tests. You provide test type, alpha, desired power, effect size (or range), and design parameters; the skill returns power, required sample sizes, or the minimum detectable effect. It can also generate power curves and sample-size charts to visualize trade-offs and produce a short report with recommended settings.

When to use it

  • Planning sample sizes for clinical trials, surveys, A/B tests, or lab experiments
  • Estimating how large an effect a study can reliably detect given current sample sizes
  • Validating that proposed study designs meet regulatory or institutional power requirements
  • Comparing alternative designs (e.g., 2-group vs. multi-arm) to minimize cost while maintaining power
  • Generating visuals and numbers for grant applications or ethics approvals

Best practices

  • Specify realistic effect sizes based on prior studies or pilot data rather than optimistic guesses
  • Include expected attrition or nonresponse when computing required sample sizes
  • Report alpha, power, assumed variance/proportions, and one- or two-sided test choice transparently
  • Run sensitivity analyses across a range of effect sizes and variances to show robustness
  • Prefer visual power curves to single-number outputs when discussing trade-offs with stakeholders

Example use cases

  • Compute per-group sample size for a two-sample t-test with effect size d=0.5, alpha=0.05, power=0.8
  • Estimate power for an A/B test with 10,000 users per arm and a 1.5% conversion lift
  • Generate a power curve for ANOVA across varying group sizes to choose an efficient design
  • Determine the minimum detectable odds ratio for a case-control study given fixed N
  • Create a short report summarizing assumptions and recommended sample sizes for an IRB submission

FAQ

Can this skill handle one-sided and two-sided tests?

Yes — you can specify one- or two-sided hypotheses for t-tests and proportion tests, and the calculations adjust accordingly.

What if I don’t know the effect size?

Run sensitivity analyses across a plausible effect-size range or use pilot data to estimate variance; the skill can produce power curves to aid decision-making.