Linear Regression Calculator
Fits the straight line that best describes how Y changes with X.
Line of best fit
—
Share sends a link that reopens these numbers. Copy details pastes the full breakdown as a list.
Values read in each list —
Slope —
Intercept —
R² —
Predicted Y —
Standard error of the slope —
p-value for the slope —
Residual standard deviation —
Reading this —
The formula
slope = Σ(x − x̄)(y − ȳ) ÷ Σ(x − x̄)² intercept = ȳ − slope × x̄
This is ordinary least squares, which minimises the sum of squared vertical distances from the line.
What to watch out for
The slope is the change in Y for a one-unit rise in X. Swapping X and Y gives a different line, because the fit minimises vertical distances only.
Frequently Asked Questions
What is a worked example?
For X = 1, 2, 3, 4, 5 and Y = 2, 4, 5, 4, 5, the line is y = 0.6x + 2.2, with R² = 0.6.
Does a good fit prove X causes Y?
No. A third factor or a coincidence can produce a good fit.