Linear Regression Calculator

Paste your x values and your y values, and this fits the ordinary least-squares line through all of them — the line that makes the total of the squared vertical gaps as small as possible. The headline is the predicted y at whatever x you ask for; the equation, the slope and intercept, the correlation r, the R² and the standard error come with it, along with the sums the formulas are built from. Note the boundary against the slope calculator: that one draws the exact line through exactly two points, so nothing is fitted and nothing is left over. This one fits one line through many points, and the leftover is the whole story.

  • Accurate
  • Real-time
  • Easy to use
  • 100% free

Predicted y at x = 10

19.6900

Slope b

1.950000

Details

Updates as you type

Separate values with commas, spaces, or semicolons. There must be at least two, and they must not all be identical.

One y for every x, in the same order. Decimals and negatives are fine.

<-50-2502550+

Summary

Predicted y

19.6900

Total variation in y (SST)

38.0720

Explained by the line (SSR)Unexplained residual (SSE)
  • Explained by the line (SSR)38.0250100%
  • Unexplained residual (SSE)0.04700%
Equation of the line
ŷ = 0.19 + 1.95x
Slope b
1.950000
Intercept a
0.190000
Correlation r
0.999383
R² (variation explained)
0.998765
Standard error of the estimate
0.125167
Standard error of the slope
0.039581
Points used
5
  • This fits one line through every point you enter, by least squares — the line that makes the total of the squared vertical gaps as small as possible. That is a different job from the slope calculator, which draws the exact line through two given points and needs no fitting at all. With exactly two points here, the two agree: the least-squares line passes through both, and the residuals are zero.
  • Your x values run from 1 to 5, so a prediction at 10 sits outside the data. The line is only evidence about the range it was fitted over; beyond that it is an assumption that the same straight relationship continues.
  • R² says how much of the variation in y the line accounts for, and nothing about whether x causes y. A high R² on a badly chosen model is common — always look at whether the points actually lie along a line rather than a curve.
How this is calculated
Points used (n)
5
Mean of x (x̄)
3.000000
Mean of y (ȳ)
6.040000

Sxx = Σ(x − x̄)²
10.0000
Sxy = Σ(x − x̄)(y − ȳ)
19.5000
Syy = Σ(y − ȳ)² — this is SST
38.0720

Slope b = Sxy ÷ Sxx
1.950000
Intercept a = ȳ − b × x̄
0.190000
Least-squares line
ŷ = 0.19 + 1.95x

SSR (explained) = b × Sxy
38.0250
SSE (unexplained) = SST − SSR
0.0470
R² = SSR ÷ SST
0.998765
r = Sxy ÷ √(Sxx × Syy)
0.999383

Standard error s = √(SSE ÷ (n − 2))
0.125167

ŷ at x = 10 is a + b × 10
19.690000
The fitted line through your dataFitted line
051016211356810

x

Compare scenarios

See how one change moves the result

  • CurrentYour inputs as they stand19.6900Current
  • Predict y at x12.524.5650

Frequently asked questions

How is this different from a slope calculator?

A slope calculator takes exactly two points and returns the slope of the one line through them: (y2 − y1) ÷ (x2 − x1), an exact answer with no error term because two points determine a line completely. Linear regression takes many points, which will not lie on any single line, and finds the line that comes closest — the one minimising the sum of the squared vertical distances. That is why regression also reports r, R² and a standard error: they measure how far from the line the data actually sits. Give this calculator exactly two points and the two agree, because the best fit through two points is the line through them.

What does R² actually tell me?

It is the share of the variation in y that the line accounts for. The total variation, SST, splits exactly into the part the line explains, SSR, and the part left over as residual, SSE — and R² is SSR ÷ SST. An R² of 0.99 means the line accounts for 99% of the up-and-down in your y values and 1% is unexplained scatter. For a single predictor it is also just the square of the correlation r. What it does not tell you is whether a straight line was the right shape: data lying neatly along a curve can still post a high R².

What is the standard error of the estimate?

It is the typical size of a residual — how far, in the units of y, an actual observation tends to fall from the fitted line. It is the square root of SSE ÷ (n − 2), where the n − 2 is the degrees of freedom left after spending two of them estimating the slope and the intercept. Roughly two thirds of observations fall within one standard error of the line. The separate standard error of the slope answers a different question: how much the slope itself would wobble if you collected a fresh sample of the same size.

Can I predict a y value beyond the range of my data?

The calculator will do it and will warn you when you have. The arithmetic is the same, but the evidence is not: the fit is only ever evidence about the range of x it was fitted over, and extending it further assumes the same straight relationship keeps holding. That assumption fails all the time — growth curves flatten, dose responses saturate, trends reverse. Treat a prediction well outside the data as a hypothesis, not a result.

Why does it refuse when all my x values are the same?

Because the slope would be Sxy ÷ Sxx with Sxx equal to zero, which is a division by zero, and because no line of the form y = a + bx can pass through a vertical stack of points at all. Regression fits y as a function of x, and a vertical scatter gives many different y values for one x, which is not a function. Repeated x values are perfectly fine on their own — three measurements at week 2 is normal data — as long as the x values are not all identical.

Does a strong correlation mean x causes y?

No. r and R² measure how tightly the points follow a straight line and say nothing at all about direction or cause. The relationship may run the other way, both may be driven by a third factor, or the pairing may be coincidence — and with few data points, coincidence is easy. Regression is a description of the data you have. Causation is a claim about the world, and it needs an experiment or a strong argument from outside the numbers.

You might also like