Margin of Error — Precision and Sample Size
Foundations of Statistics
The Price of Precision
The margin of error quantifies the width of confidence intervals and depends on sample size, variability, and confidence level. Understanding this relationship is essential for designing efficient studies and interpreting reported results.
- Survey Research — Determining how many respondents are needed for reliable estimates
- Quality Control — Balancing precision requirements against inspection costs
- Business Intelligence — Setting appropriate precision targets for data collection
The margin of error tells you exactly how much precision your budget can buy.
What Is Margin of Error?
DfMargin of Error
The margin of error quantifies the maximum expected difference between a sample statistic and the true population parameter at a given confidence level. It reflects the precision of an estimate — smaller margin of error means more precision.
Core Formula
Margin of Error for the Mean
Here,
- =Margin of error
- =Critical z-value for the desired confidence level
- =Population standard deviation
- =Sample size
When to Use t vs z
When is unknown and estimated by , replace with . For large (), the difference is negligible since by convergence of the t-distribution.
Critical Values for Common Confidence Levels
ThRelationship Between Confidence Level and Critical Value
The margin of error scales linearly with the critical value, which grows sub-linearly with confidence level. Specifically:
| Confidence Level | Relative Margin | |
|---|---|---|
| 90% | 1.645 | 1.00 |
| 95% | 1.960 | 1.19 |
| 99% | 2.576 | 1.57 |
Increasing from 90% to 95% confidence increases the margin by 19%; increasing from 95% to 99% adds another 31%.
The Square Root Law
The margin of error decreases as . To halve the margin of error, you need four times the sample size. This is the fundamental trade-off between precision and cost.
Derivation: Why ?
ThMargin of Error from the Pivotal Quantity
Start with the pivotal quantity . The probability statement
rearranges to:
The half-width of this interval is .
Worked Example: Polling
A pollster surveys 1,200 voters and finds 58% support Candidate A. The 95% margin of error is:
So the 95% CI is — Candidate A leads by 3 to 9 percentage points.
Design Effect in Complex Surveys
The formula above assumes simple random sampling. In stratified or cluster samples, the design effect inflates the margin: . For typical cluster samples, ranges from 1.5 to 3.
The Three Factors Affecting Margin of Error
Factors Affecting $E$
- Sample size : . Doubling reduces by factor .
- Population variability : . More variable data requires larger samples for the same precision.
- Confidence level: . Higher confidence requires wider intervals.
- Population proportion (for proportions): is maximized at , giving .
Python Implementation
import numpy as np
from scipy import stats
def margin_of_error_mean(sigma, n, confidence=0.95):
"""Compute margin of error for population mean (σ known)."""
z_crit = stats.norm.ppf(1 - (1 - confidence) / 2)
return z_crit * sigma / np.sqrt(n)
def margin_of_error_proportion(p_hat, n, confidence=0.95):
"""Compute margin of error for population proportion."""
z_crit = stats.norm.ppf(1 - (1 - confidence) / 2)
return z_crit * np.sqrt(p_hat * (1 - p_hat) / n)
# Example 1: Mean with known σ
print(f"E (95%, σ=10, n=100): {margin_of_error_mean(10, 100, 0.95):.3f}")
print(f"E (99%, σ=10, n=100): {margin_of_error_mean(10, 100, 0.99):.3f}")
# Example 2: Proportion
print(f"E (95%, p̂=0.58, n=1200): {margin_of_error_proportion(0.58, 1200, 0.95):.4f}")
# Show 1/√n scaling
for n in [100, 400, 1600, 6400]:
E = margin_of_error_mean(10, n, 0.95)
print(f"n={n:5d}: E = {E:.3f}")
Key Takeaways
Summary: Margin of Error
- : the half-width of the confidence interval
- Scales as : quadruple to halve
- Scales linearly with : more variable data needs more data
- For proportions, maximized at : use as a conservative estimate when planning studies
- Always distinguish between the margin of error (half-width) and the confidence interval (point estimate margin)