Linear Regression Calculator

Least-squares line of best fit, slope, intercept and R² from two lists, with a prediction for any x.

Paired with Y values in the same order.

Slope (b)

3.6905

Equation
y = 3.6905x + 48.1429
Intercept (a)
48.1429
R²
0.9671
Correlation (r)
0.9834
Pairs (n)
8
Standard error of estimate
1.8017
Predicted y at x = 10
85.0476
Fitted values8 rows
xyPredicted yResidual
15251.83330.1667
25555.5238-0.5238
36159.21431.7857
46462.90481.0952
56366.5952-3.5952
67070.2857-0.2857
77473.97620.0238
87977.66671.3333

How it works

Linear regression fits the straight line y = a + bx that minimizes the sum of squared vertical distances (residuals) between the points and the line. The slope b is how much y changes for each one-unit increase in x; the intercept a is the predicted y when x is 0.

R² is the share of the variation in y explained by the line. An R² of 0.95 means the line accounts for 95% of the variation; the rest is scatter around it.

Predictions inside the range of your x values (interpolation) are usually more reliable than predictions outside it (extrapolation), where the linear pattern may not hold.

Formula

b = Σ(x − x̄)(y − ȳ) ÷ Σ(x − x̄)² · a = ȳ − b·x̄ · R² = 1 − SSE ÷ SST

Questions people ask

What is a good R² value?

It depends on the field. Physical measurements often give R² above 0.9, while social and behavioral data with an R² of 0.3 can still be useful. A high R² does not prove the relationship is causal.

What are residuals?

A residual is the actual y minus the predicted y. Residuals that show a pattern (such as a curve) suggest a straight line is not the right model.

Is R² the same as r squared?

For simple linear regression with one x variable, yes: R² equals the square of the Pearson correlation r.