Part of the Maths & Statistics suite · 235 calculators

Least Squares Regression Calculator

The line of best fit through a set of points — slope, intercept, R² and the residual spread, with the full working.

Least squares chooses the line that minimises the total squared vertical distance from the points.

Results update as you type
Results
Slope
0.904762
Intercept
Equation
Correlation r
Standard error of the slope
Residual standard deviation
p-value for the slope
Prediction
Points
Reviewed September 2026. Pure mathematics: the result does not depend on where you are. Terminology follows the Australian Curriculum (maths, brackets, decimal point).
No account required · Google Analytics off unless allowedCalculator arithmetic runs in your browserResults update as you type
All calculations run 100% in your browser. The calculator code does not submit your figures to GlobalCalc to obtain a result.
About least squares regression

How the least squares regression calculator works

Least squares chooses the line that minimises the total squared vertical distance from the points. The slope is Σ(x−x̄)(y−ȳ) ÷ Σ(x−x̄)², and the intercept follows from the fact that the line always passes through (x̄, ȳ).

Squared distances are what make the solution unique and computable in closed form — and also what makes a single outlier able to swing the whole line.

Formula: b = Σ(x−x̄)(y−ȳ) / Σ(x−x̄)²; a = ȳ − b x̄

Worked examples

InputsSlopeNote
Eight points0.904762a clear upward trend
A perfect line2slope 2, intercept 1, R² = 100%
No relationship0slope 0

Frequently asked questions

What does least squares minimise?

The sum of squared vertical distances from the points to the line. Not perpendicular distances — that is a different method.

Why squares rather than absolute distances?

Because it has a closed-form solution and clean statistical properties. Minimising absolute distances is more robust but needs iteration.

What does R² tell me?

The share of variance in Y that the line accounts for. R² = 0.8 means 80% explained and 20% left in the residuals.

Is a high R² a good model?

Not necessarily. Anscombe's quartet is four datasets with identical regressions and completely different shapes — always plot the residuals.

How much does one outlier matter?

Enormously. A single distant point can dominate the fit, because its squared residual dwarfs everything else.

Where these figures come from

Last checked: September 2026. Formulas are fixed by mathematics and do not change with tax years or regulations.