Calculators

Linear Regression Calculator

Fit a least-squares straight line and calculate slope, intercept, correlation and R².

01 / INPUTProcessed on your device
02 / RESULTReady when you are

Your result belongs here.
Enter your values and calculate.

Your inputs are not saved or included in shared links.

Local processing · No account requiredReport an issue →

UNDERSTAND YOUR RESULT

How to use this tool

  1. Enter one x, y pair per line.
  2. Use at least two pairs with different x-values.
  3. Calculate the fitted line, slope, intercept, correlation and R².

How it works

Slope = Σ((x−x̄)(y−ȳ))/Σ(x−x̄)². Intercept = ȳ−slope×x̄. The fit minimizes squared vertical residuals.

WORKED EXAMPLE

Points (1,2), (2,4), (3,6) give y = 2x, intercept 0 and R² = 1.

Common mistake to avoid

A high R² does not establish causation or guarantee reliable predictions outside the data range.

Limits and assumptions

Requires at least two pairs and varying x-values. Correlation does not prove causation; a straight line may not describe your data.

Common questions

What does the slope mean?

It is the fitted change in y for a one-unit increase in x. Its units are y-units per x-unit.

Why can correlation or R² be undefined?

If all y-values are equal, their variance is zero and the usual correlation denominator is zero.