Which calculation do I need?
- Estimate a prevalence when you survey one group to measure how common something is, for example HIV testing coverage in a district.
- Compare two proportions when the outcome is yes or no in two groups, for example cure rates with a new treatment and with standard care.
- Compare two means when the outcome is a measurement, for example blood pressure or haemoglobin.
Worked examples
Each result below comes from this calculator. Enter the same values above to see every step.
A prevalence survey
Expected prevalence unknown (use 50%), precision ±5 percentage points, 95% confidence.
385 respondents
Comparing two proportions
Infection falls from 30% with standard care to 20% with the intervention; two-sided α = 0.05, 80% power, equal groups.
294 per arm, 588 in total
Comparing two means
Blood pressure, standard deviation 15 mmHg, smallest important difference 5 mmHg; two-sided α = 0.05, 80% power.
142 per arm, 284 in total
The same trial in clusters
The two-proportion trial above, run in clinics of about 20 patients with an ICC of 0.05 (design effect 1.95).
574 per arm, 1,148 in total
The formulas
- One proportion (survey)
- n = z² × p(1 − p) / d²
- z for the confidence level (1.96 for 95%), p the expected proportion, d the precision. With a small known population N, apply the finite population correction n / (1 + (n − 1) / N).
- Two proportions
- n per arm = [z₁₋α/₂ √(2p̄(1 − p̄)) + z₁₋β √(p₁(1 − p₁) + p₂(1 − p₂))]² / (p₁ − p₂)²
- p̄ is the average of p₁ and p₂; z₁₋β is 0.84 for 80% power and 1.28 for 90%.
- Two means
- n per arm = 2σ²(z₁₋α/₂ + z₁₋β)² / Δ²
- σ is the standard deviation of the outcome and Δ the smallest difference worth detecting.
The full derivations, with worked examples, are in the free lessons Calculating sample size for means, proportions and events and Clusters, non-inferiority, attrition and writing the section.
What to report in your protocol
- The primary outcome the calculation is based on.
- The assumed values (proportions, standard deviation, ICC) and where each comes from, with a reference.
- The effect size you aim to detect and why it matters clinically.
- α, power, whether the test is one- or two-sided, and the allocation ratio.
- Adjustments for clustering and dropout, and the final number to recruit.
Questions
- What sample size do I need for a survey with an unknown prevalence?
- Use an expected prevalence of 50%, which gives the largest sample. For a 95% confidence interval of ±5 percentage points you need 385 respondents, before any adjustment for non-response or clustering.
- What power should I use?
- 80% is the usual minimum and 90% is common for definitive trials. Higher power needs a larger sample: for the same difference, going from 80% to 90% power increases the sample by about a third.
- How do I adjust for dropout?
- Divide by the proportion you expect to keep, rather than adding a percentage. With 10% expected dropout, 385 becomes 385 ÷ 0.9 = 428 (rounded up), not 385 + 39 = 424.
- How do I adjust for a cluster design?
- Multiply by the design effect, 1 + (m − 1) × ICC, where m is the average cluster size and ICC the intra-cluster correlation. With 20 people per cluster and an ICC of 0.05 the design effect is 1.95, so 294 per arm becomes 574 per arm.
- Is this calculator accurate?
- Scintria's statistics are compared in public against SciPy, statsmodels and R, with the data published so anyone can rerun the comparison. Results are always rounded up to the next whole participant.
Also free: the power calculator and the study design chooser.
Planning the whole study?
Scintria also chooses study designs, writes statistical analysis plans and protocols, analyses your data and drafts full grant proposals, with every source linked. Free to start.
Start free