Skip to content
ToolBoxGeniehome

Linear Regression Calculator

Calculators · Added

Paste your x and y pairs and this fits the least-squares line, plots the points against it, and reports how much of the variation the line actually explains — along with whether the slope is distinguishable from zero, which is the part that usually gets skipped.

One x and y pair per line, separated by a space, comma or tab. Two columns pasted from a spreadsheet work as they are.

The prediction is least certain far from the middle of your data.

How to use the linear regression calculator

  1. 1Paste your data as x,y pairs — one per line, separated by a comma, tab or space.
  2. 2Read the fitted equation and the scatter plot to check the line is a sensible description of the points.
  3. 3Check R² and the slope's p-value before drawing any conclusion from the slope.
  4. 4Enter an x value to predict from, and note the warning if it falls outside your data's range.

Examples

Five points on a near-straight line

Input
(1, 2.1) (2, 4.2) (3, 5.9) (4, 8.3) (5, 9.8)
Result
y = 1.95x + 0.21, r = 0.998, R² = 0.996. Slope standard error 0.07, t = 27.86, p = 0.0001. Predicting at x = 6 gives 11.91 ± 0.32.

Flagged: with only five points a strong-looking correlation is weak evidence, and one outlier would move it a long way.

A weak relationship

Input
Thirty points with R² around 0.15
Result
A slope that may still be statistically significant while explaining 15% of the variation — significance and usefulness answering two different questions.

About the linear regression calculator

What least squares actually minimises

The fitted line is the one that makes the sum of the squared vertical distances from the points to the line as small as possible. Two details in that sentence do real work. Vertical means the errors are assumed to be in y alone, with x treated as known — so swapping the axes gives a different line, not the same line rearranged.

Squared means a point twice as far off contributes four times as much, which makes outliers extremely influential. That is a deliberate property with useful mathematics behind it, and it is also why a single mistyped value can visibly tilt the whole fit. If your data has genuine outliers you cannot remove, a method that is less aggressive about large residuals will serve you better.

How many points is enough

Two points always give a perfect fit, because two points define a line — R² of 1 there is arithmetic, not evidence. Three or four points barely improve matters, and this page warns below about eight for that reason.

There is no single threshold, because the number you need depends on how noisy the data is and how large an effect you are looking for. The practical signal is stability: if dropping any one point noticeably changes the slope, you have not got enough data to be making claims about it, whatever R² says.

Frequently asked questions

What does R² tell me that r does not?
R² is the share of the variation in y that the line accounts for, so 0.75 means three-quarters of the spread is explained by the relationship with x and the rest is not. The correlation r additionally carries the direction, positive or negative, and is on a scale where small values look larger than they are: r = 0.5 sounds like a moderate relationship but explains only a quarter of the variation.
What is the p-value on the slope for?
It answers whether the slope is distinguishable from zero — that is, whether there is a relationship at all rather than a pattern that scattered points would produce anyway. A small p-value says the slope is unlikely to have arisen from no relationship; it says nothing about the slope being large, important, or causal. A trivial slope on a big dataset is easily significant.
Why does predicting outside my data get a warning?
Because a fitted line describes the range it was fitted over, and has no information about anything beyond it. Real relationships bend, saturate and reverse outside the region you happened to measure, and the arithmetic will keep extending the line regardless, with a standard error that understates the risk badly. Extrapolation is a judgement about the underlying system, not an output of the fit.
Should I always look at the scatter plot?
Yes, and this page plots it for exactly that reason. Anscombe's quartet is four datasets with the same means, the same variances, the same regression line and the same R² which look completely different when drawn — one is a clean line, one a curve, one a line with a single outlier dragging it, one a vertical stack. Summary statistics cannot distinguish them and a glance at the plot can.
Does a strong fit mean x causes y?
No. Regression measures how two quantities move together, which is equally consistent with x driving y, y driving x, a third thing driving both, or a coincidence in a small sample. Ice cream sales and drowning rates correlate strongly and neither causes the other. Causation is established by the design of the study, not by the strength of the fit.