Linear Regression Calculator
Fit a line to paired measurements, inspect residuals, compare mean and individual prediction intervals, and explore the influence of one point.
Fit a line to your paired measurements, then look at the residuals before trusting a prediction. All calculations stay in your browser.
Least-squares line · all 5 points
ŷ = 2.2 + 0.6 × xCentered form: ŷ − 4 = 0.6 × (x − 3)
R² alone does not establish a good model, and correlation does not establish cause. A curved pattern or widening spread in residuals can make these linear-model intervals inappropriate.
Line and observations
Axes show offsets from x̄ = 3 and ȳ = 4.
Residuals against x
What does this point change?
Exploration keeps your original input. Do not remove observations just to improve R²; an unusual point may contain real information.
Prediction at x = 3
Fitted value 4
95% confidence interval · mean response
2.72702148 to 5.27297852Uncertainty in the average y at this x.95% prediction interval · one new observation
0.88185217 to 7.11814783Also includes individual scatter, so it is wider.Intervals assume a linear relationship, independent errors, constant error variance and normally distributed errors. They are pointwise intervals, not a simultaneous confidence band or a guaranteed future range.
Calculation and fitted values
Explore a pattern
Synthetic examples. Each resets the data, prediction and confidence level.
How to interpret the line, residuals and intervals
One predictor, one response
Ordinary least squares minimizes the sum of squared vertical residuals. With an intercept, b = Sxy / Sxx and a = ȳ − bx̄. The centered form ŷ − ȳ = b(x − x̄) avoids subtracting large nearly equal numbers.
Residual standard deviation is s = √(SSE / (n − 2)). At a chosen x₀, h = 1/n + (x₀ − x̄)² / Sxx. The confidence interval for the mean is ŷ ± t × s√h. A prediction interval for a new observation is ŷ ± t × s√(1 + h), using n − 2 degrees of freedom.
Two points define a line but cannot estimate the residual scatter. When the residual variance is exactly zero, the fitted line is shown but intervals are withheld: a perfect fit in observed data does not establish certain future outcomes. Constant y makes r and R² undefined; constant x does not identify a unique slope.
Temporary exclusion is a sensitivity check, not permission to discard inconvenient data. This tool does not fit multiple predictors, weighted models, nonlinear curves or causal effects. Use standard deviation to describe a single sample, or the confidence interval calculator to estimate one mean or binomial proportion.
Method references: NIST least squares, residual validation, mean-response uncertainty and individual prediction uncertainty.