Sample size for comparing two proportions
Use two expected risks to plan how many independent people each group needs for a binary comparison.
Fit
When to use it, and when not to
Use it when
- You compare a yes-or-no outcome in two independent groups.
- You have plausible risks for both groups and a meaningful difference to detect.
Not when
- Outcomes are paired. Plan for the paired binary analysis instead. Read: McNemar ’s test
- People share clusters. Use a design-specific clustered calculation. Read: Simulation-based power and sample-size planning
- You want to rule out unacceptable loss. Use margin-based noninferiority sizing. Read: Sample size for a noninferiority comparison of proportions
Before you start
What you need
- Group 1 risk, p1Enter a proportion from 0 to 1.
- Group 2 risk, p2Use the same outcome and follow-up time. The two risks must differ.
- Allocation ratio, ratioEnter group 2 per group 1. The default is 1; the engine enforces a minimum of 0.05.
- False-positive threshold, alphaThe default is 0.05. The engine uses a two-sided normal cutoff.
- Target power, powerPower is the chance of detecting the assumed difference. The engine restricts the target to 0.5 through 0.999; default 0.8.
- Each person contributes one independent outcome.How to check: Account for shared clinics or repeated measurements with another method.
- Expected risks and the normal approximation are plausible.How to check: Check less optimistic risks, sparse outcomes and the planned final test.
Plain language
How it works
The engine takes the absolute risk difference. It combines a ratio-weighted pooled risk for the null cutoff with separate risk variances for the assumed alternative. It uses normal quantiles for the two-sided alpha and target power. It rounds each group count up from its unrounded allocation. Power at a chosen total splits that total by the entered ratio. Power uses the assumed direction’s normal tail with the two-sided cutoff; it does not add the opposite tail.
The paired chi-square article describes a test of independence. Its calculator applies Yates’ correction; this sizing method does not. Confirm power for your chosen final test when sparse outcomes or corrections matter. Choosing a sample-size method helps you match the planning question to the right inputs.
Worked example
A worked example
- Setting
- A discharge trial compares two independent groups.
- Question
- How many people are needed if readmission risks are 20% and 30%, or 20 and 30 in 100?
- Approach
- Set p1=0.20, p2=0.30, ratio=1, alpha=0.05 and power=0.80.
- Result
- Mallard returns 294 in group 1 and 294 in group 2: 588 total. At that total, approximate power is 80.1%.
- What it means
- These are analysable counts under the approximation. Add a separate missing-data and recruitment plan.
In practice
Recent studies PubMed search · not vetted
Watch out
Common mistakes
The one to remember
This normal approximation does not reproduce the power of a Yates-corrected chi-square test or an exact test. It assumes independent people and includes no losses.
- Entering percentage points as whole numbers.Instead: Enter risks as proportions, and keep the same outcome horizon.
- Calling the returned number exact chi-square power.Instead: The sizing engine uses a normal approximation without a continuity correction.
Inside Mallard
How Mallard uses this
For twoProportions, Mallard returns rounded counts for each group, their total and approximate power at a chosen total. It does not include losses.
analysis.sample_size_two_proportions, the id a plan cue records.Related Learn pages
Related designs and methods
Evidence
Sources & further reading
- How to calculate sample size for different study designs in medical research? (opens in a new tab) · Indian J Psychol Med · doi 10.4103/0253-7176.116232
- Recommended tests for association in 2 x 2 tables (opens in a new tab) · Stat Med · doi 10.1002/sim.3531