Sample size for a margin of error
By Jude Wallis · Updated
The sample size for a target margin of error is the squared ratio of the critical value to that margin, times p-star times one minus p-star, rounded up.
Fix the margin of error you want, set the margin of error formula equal to it, and solve for : , where (p-star) is a planning value for the proportion chosen before any data exist. With no prior estimate use , since peaks at 0.25 there and so returns the largest, safest . Nothing on the right comes from a sample, which is what makes this a planning calculation rather than inference.
For a margin of error of 0.05 at 95% confidence with : .
The answer is 385, and the round-up is a rule you can check rather than accept. Put both candidates back into the margin of error formula. At , , which is above the target. At , , which meets it. Rounding 384.16 to the nearest whole number gives 384 and misses, by a hair, but it misses. Since sits under a square root in the denominator, the margin falls as rises, so the first whole number at or past 384.16 is the smallest sample that works.
"So 385 people guarantees a margin of error of 0.05" reads the formula backwards. The planning value is a guess; the margin you finally report is rebuilt from the (p-hat) your sample actually delivers. Planning with can only overshoot: if those 385 people split 40 to 60, the realized margin is , narrower than promised. Plan with a smaller taken from an earlier study and that protection is gone, because a sample proportion landing nearer 0.5 than your planning value gives a wider interval than you budgeted for.
One edge case: when the formula lands exactly on a whole number, nothing rounds. At and , exactly, and 2401 returns a margin of 0.020000.
Where this comes up
More confidence intervals terms, or browse the full statistics glossary.