Linear Regression Calculator
Paste your x and y pairs, one per line. The tool finds the least-squares line and tells you how well the points follow it.
Use the tool
Loading the tool…
About Linear Regression Calculator
Find the straight line that best fits a set of x and y pairs, one pair per line. The tool shows the slope and intercept, and you can enter a value of x to predict y.
Worked example
Enter the pairs 1, 2; 2, 4.1; 3, 5.9; 4, 8.2. The tool shows the best-fit line, and the predicted y for an x you choose.
Limits
A straight line fits some data well and other data badly. Look at the points before you rely on the prediction, and do not predict far outside the range of your data.
How to use Linear Regression Calculator
- Paste the pairs, one per line, with a comma or space between x and y.
- Optionally enter an x to predict y for it.
- Read the equation, r and R squared.
Good to know
- You need at least 2 pairs with different x values.
- If every y is the same, the line is flat and r is not defined.
- A high R squared shows a close straight-line fit, not that x causes y.
- Predictions outside the range of your x values may be unreliable.
Frequently asked questions
What does R squared mean?
It is the share of the variation in y that the straight line explains, from 0 to 1.
Why does it reject identical x values?
The line would be vertical and has no slope.
How is the line chosen?
It minimizes the sum of the squared vertical distances from the points to the line (least squares).