PUBH-311 · Lesson 4 of 12 · 24 min

Sampling distributions and confidence intervals

▶ Video coming soon A video version of this lesson is on the way.

When the Kestrel Valley survey results went to the board of health, one trustee asked a pointed question. “The survey says 26 percent of adults have high blood pressure. But you asked only 1,200 people out of 180,000. How do you know it isn’t 20 percent, or 35?” Dr. Osei answered that she could not know the exact figure, but she could say how far off the estimate was likely to be: the true proportion was very probably between about 23.5 and 28.5 percent. The trustee wanted to know where those numbers came from. This lesson is the answer.

Here we move from describing samples to making statements about populations. The key ideas are sampling variability, the sampling distribution, the standard error, the central limit theorem and the confidence interval. We also see how to calculate the sample size needed to estimate a mean or proportion with a chosen precision.

How samples are drawn

Inference is only as good as the sample. In a simple random sample every possible sample of a given size has the same chance of being chosen, as if names were drawn from a hat. Simple random sampling is the basis of most textbook formulas but is rarely used alone in large health surveys, because it requires a complete list of the population and can be expensive to carry out.

Systematic sampling selects every kth person from a list after a random start. Stratified sampling divides the population into groups (strata), such as regions or age groups, and samples randomly within each; it guarantees enough people in small groups and usually improves precision. Cluster sampling randomly selects groups such as neighborhoods, schools or households and then samples people within them; it is cheaper to carry out but less precise, because people in the same cluster tend to be similar. National health surveys usually combine these approaches in multistage designs.

Complex designs require survey weights, which tell the analysis how many people in the population each respondent represents, and special variance calculations. The ratio of the variance under the actual design to the variance under simple random sampling of the same size is the design effect. A design effect of 1.5 means the survey has the precision of a simple random sample only two-thirds its size. Ignoring the design usually makes results look more precise than they are. Users of NHANES and BRFSS data are instructed to use the supplied weights and design variables (strata and primary sampling units).

Non-random samples, such as volunteers or people who answer a web poll, can be useful for exploring ideas, but the formulas in this lesson do not tell us how far their results may be from the truth, because the selection process itself may be biased. A huge biased sample is still biased.

Sampling variability

If Kestrel Valley drew a second random sample of 1,200 adults, it would not find exactly 312 with hypertension. It might find 298, or 331. Each sample gives a slightly different estimate. This sampling variability is not a mistake; it is an unavoidable consequence of observing only part of the population. The question is how large it is.

Imagine drawing every possible sample of size \(n\) from a population and calculating the mean of each. The distribution of all those sample means is the sampling distribution of the mean. We never see it directly, but statistical theory tells us its properties. Its center is the population mean \(\mu\), so the sample mean is an unbiased estimate. Its spread is the standard error (SE):

\[SE(\bar{x}) = \frac{\sigma}{\sqrt{n}} \approx \frac{s}{\sqrt{n}}\]

The standard deviation describes variability among individuals; the standard error describes variability of an estimate from sample to sample. The standard error shrinks as the sample grows, but only with the square root of \(n\): to halve the standard error you must quadruple the sample size. This square-root law explains why national surveys use thousands of respondents rather than millions.

For a proportion, the standard error of \(\hat{p}\) is

\[SE(\hat{p}) = \sqrt{\frac{\hat{p}(1-\hat{p})}{n}}\]

The central limit theorem

The central limit theorem states that, for reasonably large samples, the sampling distribution of the mean is approximately normal, whatever the shape of the population distribution. Figure 1 shows it at work. The population of days of sick leave is strongly right-skewed. Means of samples of 5 are still somewhat skewed, but means of samples of 40 form a nearly symmetric, bell-shaped distribution, much narrower than the population.

Three histograms. The first shows a strongly right-skewed population of days of sick leave. The second shows means of samples of size 5, which are less skewed. The third shows means of samples of size 40, which form a narrow, nearly symmetric bell shape.
Figure 1. The central limit theorem: sample means become approximately normal as sample size grows, even when the population is skewed.

How large is "reasonably large"? For mildly skewed data, 30 is a common rule of thumb; for strongly skewed data, larger samples are needed. For proportions, the normal approximation works well when both \(n\hat{p}\) and \(n(1-\hat{p})\) are at least about 10. The theorem is the reason the normal distribution appears in so many methods: it describes the behavior of estimates, not just of raw measurements.

Confidence intervals

A point estimate is a single best guess at a parameter, such as \(\hat{p} = 0.26\). A confidence interval (CI) gives a range of plausible values together with a stated level of confidence. Most confidence intervals take the same form:

\[\text{estimate} \pm (\text{critical value}) \times SE\]

The product of the critical value and the standard error is the margin of error. For a 95 percent confidence interval based on the normal distribution, the critical value is 1.96, because 95 percent of a normal distribution lies within 1.96 standard deviations of its center. For 90 percent confidence it is 1.645 and for 99 percent it is 2.576.

Interpreting a confidence interval

The precise meaning of "95 percent confidence" is about the method, not a single interval. If we repeated the sampling many times and calculated an interval each time, about 95 percent of those intervals would contain the true parameter. Figure 2 shows 25 intervals from 25 simulated samples; most capture the true mean, but two miss it. For any one interval, we do not know whether it is one of the lucky ones, but we can be reasonably confident in the procedure.

Twenty-five horizontal confidence intervals for mean body mass index, each from a different simulated sample of 100, plotted against a vertical dashed line at the true mean of 26. Twenty-three intervals cross the line; two, drawn in red, lie entirely to its left.
Figure 2. Repeated sampling: about 95 in 100 of 95 percent confidence intervals contain the true mean. Here 23 of 25 do.

In practice it is acceptable to say, "We are 95 percent confident that the true proportion lies between 23.5 and 28.5 percent," as long as you understand the repeated-sampling meaning. It is not correct to say that 95 percent of individuals have values in the interval; that would be a statement about the spread of individuals (the standard deviation), not the precision of an estimate (the standard error).

A confidence interval for a proportion

Worked problem

Hypertension prevalence in Kestrel Valley

In a simple random sample of 1,200 adults, 312 have hypertension. Estimate the population prevalence with a 95 percent confidence interval. (Treat the sample as a simple random sample for this exercise.)

Show solution
  1. Point estimate: \(\hat{p} = 312/1200 = 0.260\).
  2. Check the normal approximation: \(n\hat{p} = 312\) and \(n(1-\hat{p}) = 888\), both well above 10.
  3. Standard error: \(SE = \sqrt{0.26 \times 0.74 / 1200} = \sqrt{0.000160} = 0.0127\).
  4. Margin of error: \(1.96 \times 0.0127 = 0.0248\).
  5. Interval: 0.260 − 0.025 = 0.235 to 0.260 + 0.025 = 0.285.

Answer: Estimated prevalence is 26.0 percent (95 percent CI 23.5 to 28.5 percent). If the survey’s design effect were 1.5, the standard error would be multiplied by the square root of 1.5 (about 1.22), widening the interval to about 23.0 to 29.0 percent.

This simple formula, called the Wald interval, performs poorly when the sample is small or the proportion is close to 0 or 1, and can even produce limits below zero. Statisticians recommend alternatives such as the Wilson score interval or exact (Clopper-Pearson) intervals in those cases, and most software provides them. For large samples and proportions away from the extremes, all methods give nearly the same answer.

A confidence interval for a mean

When estimating a mean we usually do not know the population standard deviation \(\sigma\) and must use the sample value \(s\). This adds uncertainty, which is accounted for by using the t distribution rather than the normal. The t distribution, published in 1908 by William Sealy Gosset under the pen name "Student" while he worked for the Guinness brewery in Dublin, looks like the normal but has heavier tails. Its exact shape depends on the degrees of freedom, here \(n - 1\). With few degrees of freedom the critical values are noticeably larger than 1.96; as the sample grows the t distribution approaches the normal.

\[\bar{x} \pm t_{n-1} \times \frac{s}{\sqrt{n}}\]
Table 1. Two-sided 95 percent critical values of the t distribution.
Degrees of freedom510153060120Very large (normal)
Critical t for 95 percent CI2.5712.2282.1312.0422.0001.9801.960

Worked problem

Mean BMI among bus drivers

An occupational health study measured body mass index in a random sample of 64 transit bus drivers. The mean was 27.4 kg/m² and the standard deviation 4.8 kg/m². Calculate a 95 percent confidence interval for the mean BMI of all the city’s drivers.

Show solution
  1. Standard error: \(SE = 4.8/\sqrt{64} = 4.8/8 = 0.60\).
  2. Degrees of freedom: 64 − 1 = 63. The critical t value is about 2.00 (from tables or software, 1.998).
  3. Margin of error: \(2.00 \times 0.60 = 1.20\).
  4. Interval: 27.4 − 1.2 = 26.2 to 27.4 + 1.2 = 28.6 kg/m².

Answer: Mean BMI 27.4 kg/m² (95 percent CI 26.2 to 28.6). Note the contrast with the standard deviation: individual drivers’ BMIs range much more widely, roughly 18 to 37, but the mean is estimated to within about 1.2 units.

What controls the width of an interval

Three things determine how wide a confidence interval is. A higher confidence level needs a larger critical value and gives a wider interval: a 99 percent interval is wider than a 95 percent interval from the same data. Greater variability in the data (a larger standard deviation) gives a wider interval. A larger sample size gives a narrower interval, in proportion to \(1/\sqrt{n}\). Only the last is usually under the investigator’s control, which brings us to sample size planning.

Sample size for estimation

Before a survey, investigators decide how precise the estimate needs to be, expressed as the desired margin of error \(E\), and solve for \(n\). For a proportion,

\[n = \frac{z^2 \, p(1-p)}{E^2}\]

and for a mean,

\[n = \left( \frac{z \, \sigma}{E} \right)^2\]

Here \(z\) is 1.96 for 95 percent confidence, \(p\) is a guess at the proportion and \(\sigma\) a guess at the standard deviation, from earlier studies or a pilot. If nothing is known about \(p\), use 0.5, which gives the largest (most cautious) sample size. Always round up.

Worked problem

Planning a vaccination coverage survey

A health department wants to estimate the proportion of adults who received a seasonal influenza vaccine to within ±3 percentage points with 95 percent confidence. No recent estimate is available. How many adults should be sampled with simple random sampling? What if the design effect is 2 and only 60 percent of those contacted respond?

Show solution
  1. Use p = 0.5 and E = 0.03: \(n = 1.96^2 \times 0.25 / 0.03^2 = 3.8416 \times 0.25 / 0.0009 = 1067.1\), so 1,068 adults.
  2. With a design effect of 2 (for example, a cluster design), multiply: 1,068 × 2 = 2,136 completed interviews.
  3. Allowing for 60 percent response, divide: 2,136 / 0.60 = 3,560 adults must be approached.

Answer: About 1,068 completed interviews under simple random sampling, but about 3,560 adults approached once the design effect and non-response are included. Non-response also raises the risk of bias, which a larger sample cannot fix.

A similar calculation for a mean: to estimate mean systolic pressure to within ±2 mmHg when the standard deviation is about 15 mmHg requires \(n = (1.96 \times 15/2)^2 = 216.1\), so 217 people. Sample size for comparing groups, which depends on statistical power, is covered in Lessons 5 and 6.

Back to the board

At the next meeting Dr. Osei showed the trustee a version of Figure 2 and explained that the 23.5 to 28.5 percent range came from the size of the sample and the variability of the data, and that the final design-based analysis, which used the survey weights, widened it slightly to about 23 to 29 percent. She added that the interval did not account for people who refused the survey or misreported their blood pressure history. “The confidence interval tells you about chance,” she said. “It doesn’t tell you about bias.”

Common mistakes

  • MistakeSaying a 95 percent CI contains 95 percent of the individual observations.

    InsteadA CI describes uncertainty in an estimate such as a mean; the spread of individuals is described by the SD.

  • MistakeSaying there is a 95 percent probability that the true value lies in this particular interval.

    InsteadIn the usual (frequentist) interpretation, 95 percent of intervals produced by the method would contain the true value.

  • MistakeConfusing the standard deviation with the standard error.

    InsteadSD describes variability among individuals; SE = SD/√n describes variability of an estimate across samples.

  • MistakeAnalyzing a cluster or stratified survey as if it were a simple random sample.

    InsteadUse the survey weights and design information; otherwise intervals are usually too narrow.

  • MistakeAssuming a larger sample corrects for non-response or selection bias.

    InsteadSample size controls random error only; bias must be addressed through design and weighting.

Summary and key terms

  • Random sampling (simple, systematic, stratified, cluster or multistage) allows sampling error to be quantified; complex designs need weights and design-based variance.
  • Estimates vary from sample to sample; the sampling distribution describes this variation and its spread is the standard error.
  • SE of a mean is s/√n and of a proportion √(p(1−p)/n); quadrupling n halves the SE.
  • The central limit theorem makes sample means approximately normal in large samples, whatever the population shape.
  • A confidence interval is estimate ± critical value × SE; 95 percent of intervals from repeated samples would contain the true value.
  • Means use the t distribution with n − 1 degrees of freedom; proportions use the normal approximation or better methods such as Wilson intervals.
  • Sample size for estimation depends on the confidence level, variability and desired margin of error, adjusted for design effect and non-response.
Sampling distribution
The distribution of a statistic over all possible samples of a given size.
Standard error
The standard deviation of a sampling distribution; a measure of an estimate’s precision.
Central limit theorem
The result that sample means are approximately normally distributed in large samples.
Confidence interval
A range of plausible values for a parameter produced by a method that captures the true value a stated proportion of the time.
Margin of error
The critical value multiplied by the standard error; half the width of a symmetric CI.
t distribution
A symmetric distribution with heavier tails than the normal, used when the SD is estimated from the sample.
Degrees of freedom
A parameter of the t and chi-square distributions related to sample size.
Design effect
The ratio of an estimate’s variance under a complex survey design to its variance under simple random sampling.
Stratified sampling
Random sampling within predefined subgroups of the population.
Cluster sampling
Random selection of groups, with sampling of individuals within the selected groups.

Practice problems

Work each problem on paper first, then reveal the answer to check.

  1. In a sample of 400 teenagers, 88 report vaping in the past 30 days. Calculate a 95 percent CI for the proportion.

    Show answer

    p̂ = 0.22; SE = √(0.22 × 0.78/400) = 0.0207; margin = 1.96 × 0.0207 = 0.041; CI 0.179 to 0.261 (17.9 to 26.1 percent).

  2. A sample of 25 nurses has a mean of 6.4 hours of sleep with SD 1.0 hour. Find a 95 percent CI for the mean (t for 24 df = 2.064).

    Show answer

    SE = 1.0/5 = 0.20; margin = 2.064 × 0.20 = 0.41; CI 5.99 to 6.81 hours.

  3. A survey of 900 people gives a margin of error of ±3.3 percentage points. Roughly how many people would be needed to cut it to about ±1.65 points?

    Show answer

    Halving the margin requires four times the sample: about 3,600 people.

  4. How many people are needed to estimate mean daily sodium intake to within ±100 mg with 95 percent confidence if the SD is about 900 mg?

    Show answer

    n = (1.96 × 900/100)² = (17.64)² = 311.2, so 312 people.

Lesson quiz · 5 questions

Score 60% or more to complete this lesson.

Take the quiz