Statistics100% FreeNo Sign-UpNo Tracking

Linear Regression Calculator

Fit the least-squares regression line to your data and predict.

Linear Regression Calculator Runs locally
Enter your values and press Calculate.

All calculations happen locally in your browser — nothing is uploaded, stored or tracked.

STEP 01

Add your (x, y) data

One pair per row; add rows as needed.

STEP 02

Enter a prediction x

Optional — the fitted line evaluates it.

STEP 03

Read the model

Equation, R², slope, intercept and prediction.

What Is Linear Regression?

Linear regression finds the straight line that best fits a set of paired data points using the method of least squares — the line that minimises the sum of squared vertical distances from the points. The result is the equation y = mx + b, where m is the slope and b the intercept.

The calculator reports the fitted equation, R² (how well the line explains the data), and lets you predict the y-value for any new x. It also shows the correlation coefficient and the standard error of the estimate.

The Formulas

m = Σ((xᵢ − x̄)(yᵢ − ȳ)) ÷ Σ(xᵢ − x̄)²
b = ȳ − m·x̄
ŷ = m·x + b (prediction)

These are the ordinary least squares estimators. R² equals the square of the Pearson correlation coefficient for simple linear regression.

Your data never leaves your device.

Every calculation on this site runs in your browser using vanilla JavaScript. Nothing is uploaded, stored or tracked.

  • 100% local, client-side calculations
  • No data stored on any server
  • No tracking, no analytics, no ads scripts
  • Works offline once loaded

Frequently Asked Questions

How do I calculate the regression line?

Compute the slope m = Σ((x−x̄)(y−ȳ)) / Σ(x−x̄)², then the intercept b = ȳ − m·x̄.

What is R² in regression?

It shows how much of the variation in y the line explains, from 0 (none) to 1 (perfect fit).

Can I predict values outside my data range?

You can, but extrapolating far beyond the observed range becomes unreliable — the relationship may change.

How many data points do I need?

At least two to fit a line, but a meaningful model needs more, ideally spread across the range you care about.

What if my relationship is not linear?

The line will fit poorly (low R²). Consider transforming the variables or a non-linear model.