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.
How to use the linear regression calculator
- 1Paste your data as x,y pairs — one per line, separated by a comma, tab or space.
- 2Read the fitted equation and the scatter plot to check the line is a sensible description of the points.
- 3Check R² and the slope's p-value before drawing any conclusion from the slope.
- 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?
What is the p-value on the slope for?
Why does predicting outside my data get a warning?
Should I always look at the scatter plot?
Does a strong fit mean x causes y?
Related tools
Slope Calculator
Calculators
Slope, angle, distance, midpoint and the equation of the line through two points.
Confidence Interval Calculator
Calculators
Build a confidence interval for a mean or a proportion, with the margin of error.
Standard Deviation Calculator
Calculators
Calculate sample or population standard deviation with the full working shown.