Least Squares Regression Line Calculator

Use this least squares regression line calculator to fit a straight line to your data points using the least square method.

One "x, y" pair per line.
Clear
Line of best fity = 1.99x + 0.05
Slope1.99
y-intercept0.05
Correlation r0.99865176strong linear relationship
0.9973053399.73% of the variation explained
Points5

Fit and residuals

xyPredictedResidual
12.12.040.06
23.94.03-0.13
36.26.020.18
47.88.01-0.21
510.1100.1

The formula

least squares: minimise the sum of squared residuals

What least squares minimises

The fitted line is the one making the sum of squared vertical distances as small as possible. Squaring means large misses count disproportionately, which is why a single outlier can drag the line noticeably.

R² is the share of the variation in y that the line accounts for. A high R² says the line fits; it does not say x causes y, and it does not guarantee a line was the right model.