Linear Regression Calculator

This linear regression calculator fits the line y = m · x + b to your data pairs and reports R², standard errors, a prediction with intervals, residuals and a scatter plot.

Source: NIST/SEMATECH e-Handbook of Statistical Methods – Linear Least Squares Regression. Updated: .

one row per pair: separate x and y by space, tab or semicolon; a decimal comma is accepted
optional: y is predicted for this x value
My ToolboxYour inputs are saved in this browser only.

24681012345678xy

The chart updates with every input.

Result

Regression line
y = 1.0119 · x + 1.32143
Key figures
MeasureValue
Slope m1.0119
Intercept b1.32143
Correlation coefficient r0.957841
Coefficient of determination R²0.91746
Number of pairs n8
Standard error of the estimate0.80302
Standard error of the slope0.123909
Standard error of the intercept0.625708
95% interval for the slope0.70871 … 1.3151
p-value (slope = 0)0.0002
Prediction
For x = 9 the line predicts y = 10.4286. 95% interval for the mean: 8.8975 to 11.96. For a single new value: 7.9376 to 12.92.
Residuals
xyŷ (line)Residual y − ŷ
122.3333-0.3333
243.34520.6548
354.35710.6429
445.369-1.369
566.381-0.381
687.39290.6071
798.40480.5952
899.4167-0.4167

How it is calculated

For the sample data the line is y = 1.012 · x + 1.321 with R² = 0.92. The regression line is the line that minimises the sum of squared vertical distances to all points (ordinary least squares).

How it is calculated

The slope is m = Σ(x − x̄)(y − ȳ) / Σ(x − x̄)² and the intercept b = ȳ − m · x̄. R² is the share of the variation in y explained by x. The standard error of the estimate is s = √(Σ residual² / (n − 2)); from it come the standard errors of slope and intercept, the 95% interval for the slope (t distribution with n − 2 degrees of freedom) and the p-value for whether the slope differs from 0.

Good to know

Frequently asked questions

How do you calculate linear regression?

Slope m = Σ(x − x̄)(y − ȳ) / Σ(x − x̄)² and intercept b = ȳ − m · x̄. The calculator does this for any number of data pairs and lists the key figures in a table.

What does R² tell you in regression?

R², the coefficient of determination, is the share of the variation in y that the line explains. R² = 0.85 means 85% of the spread comes from the linear relationship.

How do you predict with a regression line?

Insert the x value into y = m · x + b. The calculator does this in the “Predict for x” field and also gives the 95% interval for the mean and for a single value.

How many data pairs do you need?

At least three for standard errors and intervals; with two points the line merely passes through both. More pairs make the estimate more reliable.

Sources and legal basis

As of: · Editorial policy

Related tools