Understand the idea
A regression line can answer two different questions at, say, a flipper length of 200 mm. One is about the average: what is the mean body mass of all penguins with 200 mm flippers? The other is about one animal: how heavy will the next penguin with 200 mm flippers be? Both start from the same fitted value, but they need different intervals.
The confidence interval for the mean answers the first question Confidence interval. Its only uncertainty is where the line itself is, because the line was estimated from a sample. With more data the line is pinned down better and this interval keeps shrinking.
The prediction interval answers the second. It carries the same uncertainty about the line plus the scatter of individual penguins around it, which more data does not remove: even if we knew the true line exactly, penguins with the same flipper length would still differ in weight. So the prediction interval is always wider, and with more data it narrows only toward the natural spread of individuals, never to zero.
On the penguin regression (342 penguins), the fitted body mass at 200 mm is 4,156 g. The 95% confidence interval for the mean is 4,114 to 4,198 g, about 84 g wide; the 95% prediction interval for one penguin is 3,380 to 4,933 g, about 1,550 g wide. Only 12% of the 342 penguins lie inside the narrow mean-CI band, while 95% lie inside the prediction band: the first describes where the average is, the second where individual penguins fall.
Both intervals are narrowest at the average flipper length and widen toward the edges of the data, and neither can be trusted far outside the range of the data. Drawn along the whole line, a prediction interval is called a prediction band; it is also described as the interval for a new observation.
Practitioner explanation
At new predictor values x₀ with h₀ = x₀ᵀ(XᵀX)⁻¹x₀, the OLS confidence interval for the mean response E[y | x₀] is ŷ₀ ± t_{1−α/2, n−p} s√h₀, and the prediction interval for a new response y₀ = x₀ᵀβ + ε₀ is ŷ₀ ± t_{1−α/2, n−p} s√(1 + h₀), because the prediction error y₀ − ŷ₀ has variance σ²(1 + h₀) when ε₀ is independent of the sample. As n grows h₀ shrinks toward 0, so the CI shrinks toward zero width while the PI half-width tends to z_{1−α/2}σ. Both widen with h₀, that is, away from the center of the predictor data Leverage.
The PI leans on the error distribution far more than the CI does. The CI is protected by the central limit theorem acting on β̂, but the PI is a statement about one ε₀, so skewed or heavy-tailed errors make its coverage wrong at any n, and heteroscedastic errors make it too wide where the spread is small and too narrow where it is large; check the residual plots before quoting one Homogeneity of variance (homoscedasticity). The 95% is a property of the procedure over repeated samples and new draws, not a claim that 95% of the population lies inside (that is a tolerance interval), and it covers one new observation: simultaneous statements need wider bands (Working-Hotelling for the whole mean line, Bonferroni or Scheffé for several new observations).
In KernelStats the linear regression card with one continuous predictor draws both bands on its scatter plot at the card's confidence level (95% by default): the mean-CI band darker and the prediction band lighter, both from statsmodels' get_prediction (the same intervals as R's predict with interval = "confidence" and "prediction"). For fits of up to 5,000 rows the card also stores each row's mean interval and prediction interval in its statistics. The ARIMA and exponential smoothing cards give a 95% prediction interval with each forecast, widening with the horizon.
When to use it
Consider it when
When the question is about one new case at given predictor values (the weight of the next penguin, next month's sales in one store) rather than about the average at those values.
Use caution when
Not for the mean response (use the confidence interval for the mean), not far outside the range of the data, and not without checking the residuals for constant spread and rough normality, which the prediction interval depends on at every sample size.
Formulas and symbols
Prediction interval for a new observation (OLS)
y-hat_0 is the fitted value at the new predictor values x_0, s the residual standard error on n - p degrees of freedom.
Confidence interval for the mean response (OLS)
The same quantities; the missing 1 under the square root is the variance of one new observation around the line, in units of sigma squared.
Worked example
Scenario
The linear regression of body mass on flipper length for the 342 penguins with both values; intervals at a flipper length of 200 mm, near the mean of 200.9 mm.
Result
Fitted value 4,156 g; 95% confidence interval for the mean 4,114 to 4,198 g; 95% prediction interval 3,380 to 4,933 g (residual standard error s = 394 g).
Interpretation
The mean body mass of penguins with 200 mm flippers is pinned down to within about 42 g either way, but a single new penguin with 200 mm flippers could plausibly weigh anything from about 3.4 to 4.9 kg. The prediction interval is the one to quote for an individual; its half-width, 777 g, is close to 1.97 × s because the line's own uncertainty is small at the center of the data.
Dataset: penguins.csv
Common misconceptions
Misconception
A prediction interval is the same as a confidence interval.
Correction
They answer different questions. The confidence interval is for the mean response at those predictor values and reflects only the uncertainty in the fitted line; the prediction interval is for one new observation and adds the scatter of individual values around the line, so it is always wider.
Misconception
With enough data the prediction interval shrinks to almost nothing.
Correction
Only the confidence interval for the mean does. The prediction interval narrows toward the natural spread of individual values around the line, about plus or minus two residual standard deviations for 95%, because more data pins down the line but does not make individuals vary less.
Misconception
About 95% of the data points should fall inside the 95% confidence band around a regression line.
Correction
The confidence band is for the mean line, so with a large sample most points fall outside it; the prediction band is the one built to contain a new individual value 95% of the time. On the penguin regression only 12% of the penguins lie inside the 95% mean-CI band, and 95% lie inside the prediction band.
References
- Applied Linear Statistical Models, 5th edition, Kutner, M. H., Nachtsheim, C. J., Neter, J. and Li, W. (2004), Chapter 2 (interval estimation of the mean response; prediction of a new observation).
- KernelStats linear regression card (engine code, Learn More and Save Columns descriptions), KernelStats documentation (2026).
