Linear Regression Calculator (Least Squares)
Fit a least-squares regression line y = a + bx to your (x, y) data points and get the slope, intercept, R squared, and correlation, with a scatter plot and fitted line.
Input
Enter your (x, y) data points, one per line, to fit a regression line by the least-squares method.
One point per line. Separate x and y with a comma or a space.
x =
Plugs this x into the regression line to predict y.
Result
Regression equation
y = 0.05 + 1.99 x
Slope b
1.99
Intercept a
0.05
R squared
0.997305
Correlation r
0.998652
Number of points
5
Prediction
When x = 6, y ≈ 11.99
Scatter plot and regression line
Data points and residuals
| No. | x | y (observed) | Fitted y | Residual |
|---|---|---|---|---|
| 1 | 1 | 2.1 | 2.04 | 0.06 |
| 2 | 2 | 3.9 | 4.03 | -0.13 |
| 3 | 3 | 6.2 | 6.02 | 0.18 |
| 4 | 4 | 7.8 | 8.01 | -0.21 |
| 5 | 5 | 10.1 | 10 | 0.1 |
How it works
- The least-squares method chooses the slope b and intercept a so that the sum of the squared vertical gaps (residuals) between each data point and the line is as small as possible.
- The slope b shows how much y changes on average when x increases by one, and the intercept a is the predicted value of y when x equals zero.
- R squared ranges from 0 to 1, and values closer to 1 mean the line explains the data well. The correlation r measures the strength and direction of the straight-line relationship between x and y.
- Enter one data point per line with x and y separated by a comma or a space. At least two points are required, and the fit fails when every x value is the same.
Reviews
Tell us what you think of this calculator.
Write a review
- Home
Linear Regression Calculator (Least Squares)