keisoku

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

1.466.110.740.7635.24x = 1, y = 2.1x = 2, y = 3.9x = 3, y = 6.2x = 4, y = 7.8x = 5, y = 10.1

Data points and residuals

No.xy (observed)Fitted yResidual
112.12.040.06
223.94.03-0.13
336.26.020.18
447.88.01-0.21
5510.1100.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

  1. Home
  2. Linear Regression Calculator (Least Squares)