Advertisement

Linear Regression Calculator

Run a linear regression: paste x,y points for the least-squares line, R squared, and predictions.

Linear Regression

Paste one x,y point per line.

Result
-

Enter numbers to see the result.

Slope (m)
-
Intercept (b)
-
R squared
-
Formula: m = (n sum xy - sum x sum y) / (n sum x^2 - (sum x)^2). R^2 measures explained variance.
Advertisement

Minimizing squared error

Least squares picks the slope and intercept that minimize the sum of squared vertical gaps between the points and the line. The formulas use only five sums (x, y, x^2, xy, y^2), so the tool recomputes the line on every keystroke.

Reading R squared

R squared is the fraction of y's variance the line explains: 1.0 is a perfect fit, 0 means the line explains nothing. The default data gives about 0.73, a solid but imperfect linear trend. Predictions beyond the data range are extrapolations: treat them with care.

Linear Regression FAQs

What is the regression line for (1,2), (2,4), (3,5), (4,4), (5,6)?
About y = 0.8x + 1.8, with R^2 near 0.73. The points are preloaded.
What is the least squares formula?
Slope m = (n sum xy - sum x sum y) / (n sum x^2 - (sum x)^2), intercept b = mean y - m x mean x.
What does R squared tell me?
How much of the variation in y the line explains, from 0 (nothing) to 1 (perfect). Higher is a tighter fit.
How do I predict a new value?
Enter an x in the Predict field; the tool evaluates the fitted line there. Predictions far outside the data are less reliable.
Is my data uploaded anywhere?
No. The regression runs fully in your browser with JavaScript.
Advertisement