Linear Regression Calculator

Enter paired x and y values to fit a least-squares line. You get the equation, the correlation coefficient and R-squared, plus a scatter plot with the fitted line drawn through it so you can see whether a straight line is a reasonable description of the data in the first place.

What least squares does

It finds the single straight line that minimises the sum of the squared vertical distances between the line and your points. Squaring means large misses are penalised disproportionately, which is why one outlier can pull the whole line towards it.

Reading R-squared honestly

R-squared is the share of the variation in y that the line accounts for. It says nothing about whether a straight line is the right model, and nothing at all about causation. A curved relationship can still produce a respectable R-squared while the line misses the actual pattern entirely - which is exactly what the scatter plot above is for.

Extrapolate with care

The fit describes the range of x values you supplied. Predicting far outside that range assumes the relationship continues unchanged, which is an assumption your data cannot support. The prediction box will happily give you a number; whether it means anything is a separate question.

Frequently asked questions

What does R-squared tell me?

The proportion of variation in y that the line accounts for. R-squared of 0.85 means the line explains 85% of the variance. A high value does not confirm that the relationship is causal, or even that a straight line is the right shape.

Why should I look at the scatter plot?

Because very different datasets can produce identical regression statistics. Anscombe's quartet is the classic demonstration: four datasets with the same slope, intercept and R-squared that look nothing alike when plotted. Always look.

Related tools

Steuervergleich Kanton Zürich — Gemeindesteuern vergleichen (Deutsch)