Premed · Premed · Statistics Biostatistics
Lecture 12: Confidence Intervals for Means
Statistics / Biostatistics
Learning Objectives
By the end of this lecture, students will be able to:
- Explain the concept and interpretation of a confidence interval
- Construct confidence intervals for a population mean using z and t distributions
- Describe the t-distribution and when to use it
- Determine the required sample size for a desired margin of error
- Interpret confidence intervals in clinical research contexts
Lecture Content
I. The Concept of a Confidence Interval
A point estimate such as x-bar provides a single best guess for a parameter, but it gives no information about the precision of that guess. A confidence interval (CI) provides a range of plausible values for the parameter, taking the form: point estimate +/- margin of error. The margin of error depends on the desired confidence level (commonly 90%, 95%, or 99%), the variability in the data (standard error), and the sample size.
The correct interpretation of a 95% CI is that if we repeated the sampling procedure many times, approximately 95% of the computed intervals would contain the true population parameter. It does NOT mean there is a 95% probability that the parameter lies in this particular interval, because the parameter is fixed, not random.
II. CI for a Mean When Sigma Is Known (Z-Interval)
Although rarely used in practice because sigma is almost never known, the z-interval is conceptually important. The formula is x-bar +/- z_(alpha/2) * (sigma / sqrt(n)). For a 95% CI, z_(0.025) = 1.96; for a 99% CI, z_(0.005) = 2.576.
As an example, if the mean cholesterol in a sample of 64 patients is 210 mg/dL with a known population sigma = 40 mg/dL, the 95% CI is 210 +/- 1.96 (40/sqrt(64)) = 210 +/- 1.96 5 = 210 +/- 9.8 = (200.2, 219.8).
III. The t-Distribution
When sigma is unknown -- which is the usual case -- we estimate it with the sample standard deviation s, and the resulting statistic follows a t-distribution rather than a standard normal. The t-distribution is symmetric and bell-shaped, centered at 0, but has heavier tails than the standard normal, placing more probability in the extremes. Its shape depends on the degrees of freedom (df) = n - 1. As df increases, the t-distribution approaches the standard normal, and for df >= 30 the two distributions are very similar. The heavier tails of the t-distribution account for the additional uncertainty that comes from estimating sigma.
<image>An overlay of the standard normal distribution (Z) and t-distributions with df = 3, df = 10, and df = 30. The Z curve is the tallest and narrowest. The t-curve with df = 3 is the shortest and has the heaviest tails. As df increases, the t-curves approach the Z curve. Labeled critical values at the 95% level are marked for each: z = 1.96, t(30) = 2.042, t(10) = 2.228, t(3) = 3.182. An annotation notes that heavier tails produce wider confidence intervals.</image>
IV. CI for a Mean When Sigma Is Unknown (T-Interval)
The standard method used in practice is the t-interval: x-bar +/- t_(alpha/2, df) * (s / sqrt(n)), where df = n - 1.
As an example, a sample of 25 patients has a mean systolic BP of 135 mmHg and s = 18 mmHg. With df = 24, t_(0.025, 24) = 2.064, so the 95% CI is 135 +/- 2.064 (18/sqrt(25)) = 135 +/- 2.064 3.6 = 135 +/- 7.4 = (127.6, 142.4). The interpretation is that we are 95% confident the true mean systolic BP in the population lies between 127.6 and 142.4 mmHg. The assumptions are that the data are a simple random sample from the population and that the population distribution is approximately normal or n is large enough for the CLT to apply.
V. Factors Affecting the Width of a Confidence Interval
Three factors determine how wide a confidence interval will be. A higher confidence level produces a wider interval (a 99% CI is wider than a 95% CI). A larger sample size produces a narrower interval because the standard error decreases. Greater variability (s or sigma) produces a wider interval. There is a fundamental trade-off: we want narrow intervals for precision and high confidence for coverage. Increasing sample size is the only way to simultaneously improve both precision and confidence.
VI. Sample Size Determination
To achieve a desired margin of error (E) at a given confidence level, the required sample size when sigma is known is n = (z_(alpha/2) * sigma / E)^2. When sigma is unknown, a pilot estimate or conservative estimate of sigma is used.
For example, to obtain a 95% CI for mean cholesterol with a margin of error of 5 mg/dL and an estimated sigma of 40 mg/dL, n = (1.96 * 40 / 5)^2 = (15.68)^2 = 245.9, which rounds up to n = 246. Always round up to ensure the required precision. Sample size calculations should be completed before data collection as part of the study planning phase.
<image>A figure showing the relationship between sample size and confidence interval width. The x-axis shows sample size (n) from 10 to 500. The y-axis shows the width of a 95% CI. The curve is a decreasing hyperbola, steep at first then flattening. Specific points are marked: n = 25 (wide CI), n = 100 (moderate CI), n = 400 (narrow CI). An annotation highlights diminishing returns: doubling n from 100 to 200 reduces width by ~29%, but doubling from 200 to 400 reduces it by only ~29% again.</image>
VII. CI for the Difference Between Two Means
When comparing two independent groups, the quantity of interest is x-bar1 - x-bar2. The pooled t-interval, which assumes equal variances, uses SE = s_p sqrt(1/n1 + 1/n2), where s_p = sqrt[((n1-1)s1^2 + (n2-1)s2^2) / (n1 + n2 - 2)], with df = n1 + n2 - 2. Welch's t-interval, which does not assume equal variances, uses SE = sqrt(s1^2/n1 + s2^2/n2) with degrees of freedom calculated using the Welch-Satterthwaite approximation. In both cases, the CI takes the form (x-bar1 - x-bar2) +/- t_(alpha/2, df) SE. If the CI for the difference excludes 0, the means are significantly different at that confidence level.
VIII. Paired Data: CI for the Mean Difference
When observations are naturally paired -- for example, before and after measurements on the same patient -- the approach is to calculate the difference for each pair (d_i = x_after - x_before) and treat the differences as a single sample. The confidence interval is d-bar +/- t_(alpha/2, n-1) * (s_d / sqrt(n)).
As an example, blood pressure was measured before and after treatment in 15 patients, yielding a mean difference of d-bar = -8 mmHg with s_d = 10 mmHg. The 95% CI is -8 +/- 2.145 * (10/sqrt(15)) = -8 +/- 5.54 = (-13.54, -2.46). Since the CI excludes 0, the treatment significantly reduced blood pressure.
<image>A visual summary of three confidence interval scenarios. Panel A: One-sample CI -- a number line showing the point estimate (x-bar) with the CI extending symmetrically, and a question mark at the unknown population mean mu. Panel B: Two-sample CI for the difference -- a number line centered at x-bar1 - x-bar2 with the CI; if it excludes zero (marked with a vertical dashed line), the difference is significant. Panel C: Paired CI -- similar to Panel A but applied to the mean difference d-bar, with zero marked for significance reference.</image>


