Sample Size for Comparing Two Groups
What you'll learn: How to determine how many observations you need in each group to reliably detect a meaningful difference between two means or two proportions.
The Core Challenge
When comparing two groups—say, testing whether a new drug lowers blood pressure more than a placebo—you need enough data to spot a real difference if it exists. Too few observations, and even a genuine effect might look like random noise. The required sample size depends on four key factors:
- The effect size you want to detect (how big a difference matters?)
- Variability within groups (more scatter = more data needed)
- Significance level (α), typically 0.05 (controls false positives)
- Power (1 - β), typically 0.80 (your chance of detecting a real effect)
For Comparing Two Means
The formula builds on what you've learned about standard error and confidence intervals:
n = 2 × (Z_α/2 + Z_β)² × σ² / δ²
Where:
- n = sample size per group
- Z_α/2 = critical value for your confidence level
- Z_β = critical value for your desired power
- σ = standard deviation (pooled or estimated)
- δ = minimum detectable difference you care about
For Comparing Two Proportions
n = 2 × (Z_α/2 + Z_β)² × p̄(1 - p̄) / (p₁ - p₂)²
Where p̄ is the average of the two proportions you're comparing.
Think of It Like This
Imagine trying to weigh two feathers that differ by 0.1 grams. A cheap scale that varies by ±5 grams won't help—you'd need many, many measurements to average out the noise. A sensitive scale (less variability) needs fewer readings.
Key Takeaway: Larger effect sizes and lower variability require smaller samples; higher confidence and power demand more data. Always plan your sample size before collecting data to ensure you can actually detect the differences that matter.