Confidence Intervals

Study Sheet

Confidence Intervals

Estimating with a margin of error

Intervals for a Proportion

Concept
Estimate ±\pm margin
true p = 0.520.420.470.520.570.62
Twenty simulated polls of 400 with true p = 0.52: one interval (bold) misses it; in the long run 5% do.

A confidence interval is estimate±z∗⋅SE\text{estimate} \pm z^*\cdot\text{SE}. For a proportion: p^±z∗p^(1−p^)n\hat p \pm z^*\sqrt{\dfrac{\hat p(1-\hat p)}{n}}, with z∗=1.96z^* = 1.96 for 95%95\% confidence (1.6451.645 for 90%90\%, 2.5762.576 for 99%99\%). "95% confident" means the method captures the true value in 95%95\% of all samples.

The interval is a statement about the procedure, not about this one answer. The true proportion is a fixed number; it is either in the interval or not. What is 95%95\% is the fraction of intervals, over many repetitions of the sampling, that would contain it — as the simulated intervals above illustrate. Widening the interval (higher confidence) or enlarging the sample (smaller SE) are the only two ways to buy more certainty.

Example
A poll interval

p^=0.52\hat p = 0.52, n=400n = 400: SE =0.52⋅0.48/400≈0.025= \sqrt{0.52\cdot0.48/400} \approx 0.025. 95%95\% interval: 0.52±1.96⋅0.025=0.52±0.0490.52 \pm 1.96\cdot0.025 = 0.52 \pm 0.049, i.e. (0.471,0.569)(0.471, 0.569). The interval includes values below 0.50.5, so the poll cannot confidently call a majority.

Example
Trading confidence for width

Same poll at other levels. 90%90\%: 0.52±1.645⋅0.025=0.52±0.0410.52 \pm 1.645\cdot0.025 = 0.52 \pm 0.041. 99%99\%: 0.52±2.576⋅0.025=0.52±0.0640.52 \pm 2.576\cdot0.025 = 0.52 \pm 0.064. More confidence means a wider net; with the data fixed, you cannot have both a narrow interval and high confidence.

Side note
Where it goes wrong

Reading the interval as a range of individual answers: "95%95\% of voters are between 47.1%47.1\% and 56.9%56.9\%" is meaningless. The interval is a range of plausible values for ONE number — the population proportion.

Try it
Try it: build an interval

In a sample of 500500, 34%34\% say they walk to work. Give a 95%95\% confidence interval for the population proportion.

Show the answer

SE =0.34⋅0.66/500≈0.0212= \sqrt{0.34\cdot0.66/500} \approx 0.0212; margin 1.96⋅0.0212≈0.0421.96\cdot0.0212 \approx 0.042. Interval 0.34±0.0420.34 \pm 0.042, i.e. (0.298,0.382)\mathbf{(0.298, 0.382)}.

Intervals for a Mean

Concept
The tt interval
z* = 1.96t* = 2.131−3−2−10123t, 15 dfnormal (dashed)
The t curve with 15 df has heavier tails than the normal, so its 95% cutoff 2.131 lies beyond 1.96.

For a mean with unknown σ\sigma: xˉ±t∗sn\bar x \pm t^*\dfrac{s}{\sqrt n}, where t∗t^* comes from the tt distribution with n−1n - 1 degrees of freedom. For large nn, t∗≈z∗t^* \approx z^*; for small nn it is larger, paying for the extra uncertainty in ss.

Replacing the unknown σ\sigma by the sample's own ss adds a second source of randomness: in a small sample ss may come out too small, making the interval too narrow. The tt distribution builds that risk in by having heavier tails, and it approaches the normal as the degrees of freedom grow, because ss becomes a reliable estimate of σ\sigma.

Example
A small sample

n=16n = 16, xˉ=30\bar x = 30, s=4s = 4, 95%95\%: with 1515 degrees of freedom t∗=2.131t^* = 2.131. SE =4/16=1= 4/\sqrt{16} = 1. Interval 30±2.131⋅1=30±2.1330 \pm 2.131\cdot1 = 30 \pm 2.13, i.e. (27.87,32.13)(27.87, 32.13) — wider than the 30±1.9630 \pm 1.96 a zz interval would claim.

Example
A large sample

n=100n = 100, xˉ=52\bar x = 52, s=10s = 10: SE =10/100=1= 10/\sqrt{100} = 1 and t99∗=1.984t^*_{99} = 1.984, so the interval is 52±1.9852 \pm 1.98, i.e. (50.02,53.98)(50.02, 53.98). With 9999 degrees of freedom t∗t^* is already close to 1.961.96.

Side note
Where it goes wrong

Saying "there is a 95% probability the true mean is in this interval" (the interval is what is random), or using z∗z^* with a tiny sample. With n=16n = 16, the zz interval 30±1.9630 \pm 1.96 would capture the true mean less than 95%95\% of the time.

Try it
Try it: interpret

A 95%95\% interval for mean commute time is (28,34)(28, 34) minutes. Which is correct: (a) 95%95\% of commutes take 2828–3434 minutes; (b) we are 95%95\% confident the MEAN commute is between 2828 and 3434?

Show the answer

(b). The interval estimates the population mean; individual commutes are far more spread out than the mean is uncertain.

Margin of Error and Sample Size

Concept
Planning nn
nmargin (%)400800120016002000240024684.9% at n = 4002.45% at n = 1600
The 95% margin 1.96·√(0.25/n) falls quickly at first, then slowly: 4× the sample halves the margin.

The margin of error for a proportion is m=z∗p(1−p)/nm = z^*\sqrt{p(1 - p)/n}. Solving for nn: n=(z∗m)2p(1−p)n = \left(\dfrac{z^*}{m}\right)^2p(1 - p). With no prior guess use p=0.5p = 0.5, the worst case, since p(1−p)≤0.25p(1 - p) \le 0.25: at 95%95\%, n≈0.96/m2n \approx 0.96/m^2. Always round UP.

Because mm is proportional to 1/n1/\sqrt n, halving the margin needs four times the sample and cutting it to a third needs nine times. That diminishing return is visible in the curve and explains the typical national poll of about 10001000 people: going from ±3%\pm3\% to ±1%\pm1\% would cost nine times as much. The formula uses the planned pp, not the result, because it is computed before collecting any data.

Example
A ±3%\pm3\% poll

How many people for a ±3%\pm3\% margin at 95%95\%, with no prior guess? n=(1.96/0.03)2⋅0.25≈1067.1n = (1.96/0.03)^2\cdot0.25 \approx 1067.1. Round up: 10681068. Rounding down to 10671067 would give a margin slightly larger than 3%3\%.

Example
Four times the sample

At n=400n = 400 the worst-case margin is 1.960.25/400=0.0491.96\sqrt{0.25/400} = 0.049; at n=1600n = 1600 it is 0.02450.0245 — exactly half. Quadrupling the sample halves the margin, because the square root turns 44 into 22.

Example
Using a prior guess

If an earlier study suggests p≈0.1p \approx 0.1, then n=(1.96/0.03)2⋅0.1⋅0.9≈384.2n = (1.96/0.03)^2\cdot0.1\cdot0.9 \approx 384.2, so 385385 — far fewer than 10681068. Proportions near 00 or 11 vary less from sample to sample, so they are cheaper to pin down.

Side note
Where it goes wrong

Rounding the sample size to the nearest integer instead of up, or using p^\hat p from the finished survey to plan it. The planning formula needs a guess made in advance; when in doubt, p=0.5p = 0.5 guarantees the margin.

Try it
Try it: size

How many people must be polled for a ±2%\pm2\% margin at 95%95\% confidence (no prior guess)?

Show the answer

n=(1.96/0.02)2⋅0.25=982⋅0.25=9604⋅0.25=2401n = (1.96/0.02)^2\cdot0.25 = 98^2\cdot0.25 = 9604\cdot0.25 = \mathbf{2401} — exactly an integer here, so no rounding is needed.

Why It Works

The sampling distribution of p^\hat p is approximately normal with centre pp, so in 95%95\% of samples p^\hat p lands within 1.961.96 SE of pp. But "p^\hat p is within 1.961.96 SE of pp" is the same statement as "pp is within 1.961.96 SE of p^\hat p" — distance is symmetric. So in exactly those 95%95\% of samples, the interval around p^\hat p contains pp. (Using the estimated SE instead of the true one introduces a small error, which is why the tt distribution is used for means with small samples.)