Toolstia / linear regression calculator
Linear regression calculator
Enter your data points, one x and y pair per line, to find the line of best fit. You get the equation, the slope and intercept, the correlation coefficient and R squared, and you can predict y for any x.
This fits a straight line y = mx + b through your points with the least squares method. R squared shows how much of the variation in y the line explains: 1 is a perfect fit and 0 means none. Predicting far outside your data can be unreliable.
How it works
- Enter one x and y pair per line.
- Read the equation and statistics.
- Enter an x to predict y.
Least squares
The line is chosen so that the sum of the squared vertical distances from your points to the line is as small as possible.
The statistics
The slope is how much y changes for each step in x. The intercept is y when x is zero. R squared is the share of the variation in y that the line explains, from 0 to 1. The correlation r runs from −1 to 1.
Predicting
Enter an x value and the tool gives the y on the line. Predictions inside the range of your data are far more reliable than those outside it.
Limits
A high R squared shows a good fit to a line, not that x causes y. At least two points with different x values are needed.
Questions
How many points do I need?
Two at least, but more points give a more reliable line.
Can I use commas?
Yes. Separate x and y with a space, comma, tab or semicolon.
Is my data stored?
Everything happens in your browser, and nothing you enter is sent anywhere.