Sub topic 3
How much can you trust a number: margin of error
A survey result is an estimate. If you ask 1,000 people a question and 48% say yes, you have not learned that exactly 48% of the whole population would say yes. You have learned that the true figure is probably near 48%. The margin of error says how near.
This chapter assumes you know what a percentage and an average are, and that you have read the earlier chapters on survey design and on sampling and weighting. You will learn to calculate a margin of error, choose a sample size, and report the figure without overstating what it covers.
What the margin of error measures
The margin of error describes sampling error. This is the random difference between your sample and the full population, caused by the fact that you asked only some people. A different random sample of the same size would give a slightly different result.
The usual convention is a 95% confidence level. If you drew many random samples and built an interval around each result, about 95 out of 100 of those intervals would contain the true population value. For a single survey, you can say the true value is probably within the margin of error of your result.
The margin of error does not cover every way a survey can go wrong. It says nothing about:
- Badly worded or leading questions.
- People who refuse to answer, or who answer untruthfully.
- A sample that was not drawn at random, such as an opt-in web poll.
- Coverage gaps, where part of the population had no chance of being asked.
A survey with a tiny margin of error can still be wrong. The figure only tells you how much random sampling noise to expect, and only if the sample was drawn properly.
The formula for a proportion
For a result expressed as a proportion (for example, 0.48 for 48%), the 95% margin of error from a simple random sample is:
MoE = z × √( p × (1 − p) / n )
pis the proportion who gave the answer, as a decimal.nis the number of respondents.zis 1.96 for a 95% confidence level.
The function below applies this formula.
import math
def margin_of_error(p, n, z=1.96):
"""95% margin of error for a proportion p from a simple random sample of size n."""
return z * math.sqrt(p * (1 - p) / n)
print(round(margin_of_error(0.5, 1000) * 100, 1)) # 3.1With 1,000 respondents and a result of 50%, the margin of error is about 3.1 percentage points. You would report that as "plus or minus 3 points" or "±3.1 points".
Why 50% is the worst case
The term p × (1 − p) is largest when p is 0.5. It shrinks as the result moves toward 0% or 100%. So a result of 10% has a smaller margin of error than a result of 50% from the same sample.
Pollsters usually quote a single headline margin of error calculated at 50%. That is the most cautious value and applies to the whole survey. For results far from 50%, the true margin for that question is smaller.
import math
def margin_of_error(p, n, z=1.96):
return z * math.sqrt(p * (1 - p) / n)
for p in (0.5, 0.3, 0.1):
print(p, round(margin_of_error(p, 1000) * 100, 1))
# 0.5 3.1
# 0.3 2.8
# 0.1 1.9Sample size and diminishing returns
The margin of error depends on the square root of n. To halve the margin of error, you need four times as many respondents. This is why very large samples are rarely worth their cost.
| Sample size (n) | Margin of error at 50% |
|---|---|
| 100 | ±9.8 points |
| 400 | ±4.9 points |
| 1,000 | ±3.1 points |
| 2,000 | ±2.2 points |
| 4,000 | ±1.5 points |
Going from 1,000 to 2,000 respondents costs twice as much and improves the margin by under one point. For most PR surveys, 1,000 is a practical target for a national result, and a few hundred can be enough for a narrow audience if you accept a wider margin.
You can also work backward from the margin you want. Rearranging the formula at p = 0.5 gives the sample size:
import math
def required_sample(moe_points, p=0.5, z=1.96):
"""Respondents needed for a target margin of error, in percentage points."""
moe = moe_points / 100
return math.ceil((z ** 2) * p * (1 - p) / (moe ** 2))
print(required_sample(3)) # 1068
print(required_sample(5)) # 385A target of ±3 points needs about 1,068 respondents. A target of ±5 points needs about 385.
Subgroups have larger margins
The headline margin applies to the full sample. Whenever you report on a subgroup, such as women aged 18 to 34 or people in one region, the relevant n is the size of that subgroup, not the whole survey.
Suppose your survey has 1,000 respondents and 150 are aged 18 to 24. The margin for that group at 50% is:
import math
def margin_of_error(p, n, z=1.96):
return z * math.sqrt(p * (1 - p) / n)
print(round(margin_of_error(0.5, 150) * 100, 1)) # 8.0That is about ±8 points, far wider than the ±3.1 for the whole sample. A finding such as "55% of 18 to 24 year olds agree" really means "somewhere between about 47% and 63%". If you build a headline on a small subgroup, state its margin and sample size, or leave it out.
Weighting and the design effect
The formula above assumes a simple random sample. Real surveys are often weighted to match the population on age, gender, region and similar traits. Weighting corrects imbalances, but it also reduces the effective sample size, because some respondents count for more than others. The loss is called the design effect.
A common approximation is Kish's design effect, based on the weights:
def effective_sample_size(weights):
"""Kish approximation of effective sample size for a list of survey weights."""
total = sum(weights)
total_sq = sum(w * w for w in weights)
return total * total / total_sq
weights = [0.8, 1.0, 1.2, 0.5, 2.0, 1.0, 0.7, 1.3]
print(round(effective_sample_size(weights), 1)) # 7.1Here eight respondents are worth about 7.1 in terms of precision. With heavier weights, the loss grows. If your weights vary widely, calculate the margin of error using the effective sample size instead of the raw count. Many survey firms report a margin of error that already includes the design effect. Ask for it in writing.
Comparing two results
A common mistake is to treat any difference as meaningful. If 48% of respondents say yes this year and 45% said yes last year, and each survey has a margin of ±3 points, the difference of 3 points may be noise.
Two points matter here:
- The margin of error on a difference between two independent surveys is larger than either margin alone. For two samples of equal size, it is roughly 1.4 times the single margin.
- Overlapping intervals are a warning sign. If the ranges around the two results overlap heavily, you should not claim a change.
import math
def moe_of_difference(p1, n1, p2, n2, z=1.96):
"""95% margin of error for the difference between two independent proportions."""
se = math.sqrt(p1 * (1 - p1) / n1 + p2 * (1 - p2) / n2)
return z * se
diff = 0.48 - 0.45
moe = moe_of_difference(0.48, 1000, 0.45, 1000)
print(round(diff * 100, 1), round(moe * 100, 1)) # 3.0 4.4The observed change is 3.0 points and the margin on the difference is 4.4 points. The change is within the margin, so "support rose three points" is not supported. A more honest statement is "support was similar to last year".
The same logic applies to a gap between two groups within one survey, and to a "lead" of one answer over another. A lead smaller than the margin of the difference should not be called a lead.
Non-probability samples
The formula only applies to probability samples, where everyone in the target population has a known chance of being chosen. Many online panels and opt-in polls are non-probability samples. For these, a computed margin of error is not strictly valid, because there is no random selection for the formula to describe.
Industry guidance, including the American Association for Public Opinion Research, recommends that these surveys not be given a classic margin of error. Some firms publish a "credibility interval" from a statistical model instead. If your survey was run on an opt-in panel:
- Say so in the methodology note.
- Report the figure as a modelled or approximate range, and name the method.
- Do not write "random sample" or "margin of error of ±3" as if it were a probability poll.
How to report it in a story
A reader or journalist needs to see three things: the sample size, the margin of error, and the confidence level. A short line is enough:
"The survey of 1,012 UK adults, conducted 3 to 6 March, has a margin of error of ±3.1 percentage points at the 95% confidence level."
Some practical rules:
- Use "percentage points", not "percent", for the margin.
- Round to one decimal place, or to the whole point if the figure is for a general audience.
- Report subgroup margins when you cite subgroup results.
- Do not apply the margin to results that were not drawn at random without saying how the figure was obtained.
The following diagram shows how to decide what to say about a result.
Common errors
- Quoting the margin for the full sample on a subgroup. Always recompute with the subgroup's
n. - Treating the margin as a measure of total accuracy. It covers only sampling error.
- Calling a small difference a trend. Compare the difference to the margin of the difference.
- Using "percent" for the margin. A margin of ±3 points on a result of 50% is not ±3 percent.
- Applying the formula to an opt-in poll. The calculation assumes random selection.
- Ignoring the design effect. Heavy weighting makes the true margin wider than the headline figure.
Exercise
A survey of 600 randomly selected adults finds that 40% support a proposal. Calculate the 95% margin of error. Last year, a separate random survey of 600 adults found 36% support. Can you say support rose?
Show answer
The margin of error is 1.96 × √(0.4 × 0.6 / 600) ≈ 0.0392, or about ±3.9 points. For the difference, the standard error is √(0.4×0.6/600 + 0.36×0.64/600) ≈ √(0.0004 + 0.000384) ≈ 0.028, so the margin on the difference is about ±5.5 points. The observed change is 4 points, which is smaller than 5.5, so you cannot say support rose. You can say support was similar to last year.
Exercise
Your survey has 1,000 respondents with a headline margin of ±3.1 points. You want to publish a finding about the 120 respondents who live in rural areas, where 62% agree with a statement. What is the approximate margin for that result, and how should you present it?
Show answer
The margin is 1.96 × √(0.62 × 0.38 / 120) ≈ 0.0869, or about ±8.7 points. Present it with the subgroup size and margin, for example "62% of rural respondents (n=120, margin of error ±8.7 points) agree", or treat it as a rough indication and avoid building the headline on it.
Exercise
A client commissions an opt-in online panel of 2,000 people and asks you to write "margin of error ±2.2 points" in the press release. What should you do?
Show answer
Do not use a classic margin of error, because an opt-in panel is not a probability sample and the formula assumes random selection. Check whether the survey firm can supply a modelled credibility interval, report that with the method named, and state in the methodology note that the sample was drawn from an opt-in panel.