Home · Statistics · Correlation & Regression · Linear Regression Calculator

Linear Regression Calculator

Least-squares linear regression of y on x: the slope of the best-fitting straight line, with the intercept reported by the same fit.

Your figures

Example result — edit the figures to make it yours

1.5357

Slope1.535714
Intercept1.285714
Correlation r0.946485
R-squared0.895833
Pairs (n)7

What this calculator does

Least-squares linear regression of y on x: the slope of the best-fitting straight line, with the intercept reported by the same fit. Every figure on this page is computed from the standard definition stated below — the same definition used in textbooks and reference tables — with no hidden rounding steps, and the method notes name the exact convention where more than one exists.

The formula and method

Slope b = Σ(x−x̄)(y−ȳ) / Σ(x−x̄)²; intercept a = ȳ − b·x̄; fitted line ŷ = a + b·x

Least squares chooses the line minimising the sum of squared vertical residuals.

The headline result is the slope: the predicted change in y for a one-unit increase in x.

The line always passes through the point of means (x̄, ȳ).

Worked example

With the example inputs this page opens with, the result is 1.5357. Change any figure and the result updates with the same formula.

Quick reference

Quick reference — the worked example in full
FigureValue
Result1.5357
Slope1.535714
Intercept1.285714
Correlation r0.946485
R-squared0.895833
Pairs (n)7

Computed with the same formulas as the calculator above — enter any values there for figures beyond this table.

Common questions

How do I use the slope and intercept?

Predict with ŷ = a + b·x: here ŷ = 1.286 + 1.536·x, so each extra unit of x predicts about 1.54 more units of y. Predictions are trustworthy only inside (or near) the x-range of the data.

Does regression prove that x causes y?

No. It quantifies association under a linear model. Swapping the axes gives a different line (regression of x on y), which is a reminder that the equation describes prediction, not mechanism.

How does the Linear Regression Calculator work?

Least-squares linear regression of y on x: the slope of the best-fitting straight line, with the intercept reported by the same fit. X values · y values → Slope of the regression line. The result updates as you type, and the formula and method on this page state the exact definitions used, so you can reproduce the calculation by hand.

What inputs does the Linear Regression Calculator need?

X values · y values → Slope of the regression line. Invalid entries — such as a zero denominator, an out-of-range value or a malformed list — produce a plain-language message instead of a misleading number.