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 nn: n=(zME)2p(1p)n = \left(\frac{z^*}{ME}\right)^2 p^*(1-p^*), where pp^* (p-star) is a planning value for the proportion chosen before any data exist. With no prior estimate use p=0.5p^* = 0.5, since p(1p)p^*(1-p^*) peaks at 0.25 there and so returns the largest, safest nn. 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 p=0.5p^* = 0.5: n=(1.96/0.05)2(0.25)=(39.2)2(0.25)=384.16n = (1.96/0.05)^2(0.25) = (39.2)^2(0.25) = 384.16.

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 n=384n = 384, 1.960.25/384=0.0500101.96\sqrt{0.25/384} = 0.050010, which is above the target. At n=385n = 385, 1.960.25/385=0.0499451.96\sqrt{0.25/385} = 0.049945, which meets it. Rounding 384.16 to the nearest whole number gives 384 and misses, by a hair, but it misses. Since nn sits under a square root in the denominator, the margin falls as nn 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 pp^* is a guess; the margin you finally report is rebuilt from the p^\hat{p} (p-hat) your sample actually delivers. Planning with p=0.5p^* = 0.5 can only overshoot: if those 385 people split 40 to 60, the realized margin is 1.960.40(0.60)/385=0.0489361.96\sqrt{0.40(0.60)/385} = 0.048936, narrower than promised. Plan with a smaller pp^* 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 ME=0.02ME = 0.02 and p=0.5p^* = 0.5, n=(98)2(0.25)=2401n = (98)^2(0.25) = 2401 exactly, and 2401 returns a margin of 0.020000.

Where this comes up

More confidence intervals terms, or browse the full statistics glossary.