A regression line gives one predicted value, but a prediction should come with a range. The regression prediction interval calculator takes the number of observations, the mean of x, Sxx, the residual standard error, a new x, its predicted y and a confidence level, and gives the confidence interval for the mean response and the prediction interval for a new observation.
How the calculation works
- From your simple linear regression, take the number of observations n, the mean of x, the sum of squared deviations Sxx = Σ(x − x̄)² and the residual standard error s.
- Compute the leverage term at the new point: 1 ÷ n + (x₀ − x̄)² ÷ Sxx. It grows as x₀ moves away from the mean of x.
- The standard error of the mean response is s × √(leverage term), and the standard error of a new observation is s × √(1 + leverage term).
- Each interval is the predicted value ± t(1 − α ÷ 2; n − 2) times its standard error. The prediction interval is always wider than the confidence interval.
Example
A regression on 24 points has x̄ = 14.2, Sxx = 310 and a residual standard error of 3.1. At x₀ = 18 the model predicts 52.4. The leverage term is 1 ÷ 24 + 3.8² ÷ 310 = 0.0883. The critical t at 95 % with 22 degrees of freedom is 2.074. The standard error of the mean response is 0.921, which gives a confidence interval of 50.49 to 54.31. The standard error of a new observation is 3.234, which gives a prediction interval of 45.69 to 59.11.
Why it matters
Forecasts in sales, engineering and science are more useful with an honest range. The prediction interval tells you where a single future value is likely to fall, which is what planners and quality engineers usually need.
Good to know
The formulas assume the usual linear model: a straight-line relationship, independent errors with constant variance, and roughly normal residuals. They apply to a simple regression with one predictor. If the residuals show a pattern or fan out, the intervals will be too narrow in some places and too wide in others.
Related tools
The linear regression calculator fits the line, and the confidence interval calculator covers intervals for means.