TTKTheTextKit

Linear Regression Calculator

Enter your data as x and y pairs, one per line, and get the least squares line of best fit with its slope, intercept, correlation coefficient r, R squared and standard errors. A chart shows the points and the line, you can predict y for any x, and a table lists the fitted values and residuals. Everything runs in your browser.

Equation
y = 3 + 0.5001x
11 points
Correlation r
0.81642
strong positive
Slope b
0.50009
Standard error 0.1179
Intercept a
3.0001
Standard error 1.125
R squared
0.66654
Share of the variation in y explained by x
Standard error of estimate
1.237
Typical distance of a point from the line
4144.2610.84
Predicted y
10.501
Outside the range of your data, so treat it with care
Fitted values and residuals
xyFittedResidual
108.048.0010.039
86.957.0008-0.05082
137.589.5013-1.921
98.817.50091.309
118.338.5011-0.1711
149.9610.001-0.04136
67.246.00061.239
44.265.0005-0.7405
1210.849.00121.839
74.826.5007-1.681
55.685.50050.1795

Least squares regression finds the straight line y = a + bx that makes the sum of the squared vertical distances from the points as small as possible. The slope is b = Sxy / Sxx, where Sxy is the sum of (x minus the mean of x) times (y minus the mean of y) and Sxx is the sum of (x minus the mean of x) squared, and the intercept is a = mean of y minus b times the mean of x. The correlation r runs from -1 to 1, and R squared is r squared. A high r shows a linear pattern, not that x causes y, and a line fitted to a few points should not be used far outside their range. Everything is worked out in your browser and nothing is uploaded.

Related Tools

[5 suggestions]

About the Linear Regression Calculator

Simple linear regression finds the straight line y = a + bx that comes closest to a set of points, where closest means the smallest sum of squared vertical distances. The slope is b = Sxy / Sxx, where Sxy is the sum of (x minus the mean of x) times (y minus the mean of y) and Sxx is the sum of (x minus the mean of x) squared. The intercept is a = mean of y minus b times the mean of x. The correlation coefficient r = Sxy / the square root of (Sxx x Syy) measures how closely the points follow a line, from -1 for a perfect falling line to 1 for a perfect rising one, and R squared is r squared, the share of the variation in y that the line explains. The standard error of the estimate is the square root of SSE / (n - 2), where SSE is the sum of the squared residuals, and the standard error of the slope is that divided by the square root of Sxx. These need at least three points. As a check, the first set of Anscombe's quartet, eleven points, gives y = 3.0001 + 0.5001x with r = 0.8164 and R squared = 0.6665. The other three sets give almost the same line from very different data, which is why a chart matters as much as the numbers. Correlation does not show cause, and a prediction far outside the range of your data is unreliable. Nothing is uploaded.

What is the line of best fit?▾

The straight line that makes the sum of the squared vertical distances from the points as small as possible. It has the form y = a + bx, where b is the slope and a is the intercept.

What does R squared mean?▾

It is the share of the variation in y that the line explains, from 0 to 1. An R squared of 0.67 means about two thirds of the variation in y is accounted for by x. It is the square of the correlation r.

How many points do I need?▾

Two points define a line, but standard errors need at least three. More points make the line more reliable, and a chart helps you see whether a straight line suits the data at all.

Does a high correlation mean x causes y?▾

No. A high r only shows that the points follow a line. Both could be driven by something else, and a curved pattern can also give a decent r, so check the chart before relying on it.

Is my data uploaded?▾

No. The calculation runs in your browser and the numbers you enter are not sent anywhere.