Linear Regression Calculator

Type one pair of x and y values on each line. You get the equation of the best straight line, the correlation and R², the standard errors, a prediction for an x you choose, the residuals and a chart of the data with the fitted line.

Free Runs in your browser Checked Tuesday, November 10, 2026

Two numbers on each line, separated by a space, a tab or a semicolon: 1 2, then 2 4, and so on. At least three pairs are needed.

Leave it empty if you do not need a prediction.

Result

Least-squares line — The line that makes the sum of the squared residuals as small as possible.
Slope b — How much y changes for each 1 added to x.
Intercept a — The value of y when x is 0.
Correlation r — Between −1 and 1: how closely the points follow a straight line.
R² — The share of the variation in y that the line explains.
Standard error of the slope — How precisely the slope is estimated.
Standard error of the intercept — How precisely the intercept is estimated.
Predicted y — The value of y on the line at the x you entered.

Data and fitted line

How it is worked out

Residuals: each point and its distance from the line

This tool runs in your browser. What you enter is not sent to us.

How to use it

  1. Type each pair of x and y on its own line in Pairs of x and y, with a space between the two numbers.
  2. Type an x in Predict y for this x if you want a prediction; leave it empty otherwise.
  3. Read Least-squares line, the Correlation r and R², and the standard errors.
  4. Check the Residuals table and the chart, then go through How it is worked out.

The least-squares line

The line y = a + bx is chosen so that the squared vertical distances from the points to the line add up to the least possible total. The slope is b = Sxy ÷ Sxx, where Sxy and Sxx add up the products and squares of the deviations from the means, and the intercept is a = ȳ − b x̄.

The correlation r = Sxy ÷ √(Sxx × Syy) lies between −1 and 1. R² = r² is the share of the variation in y that the line explains.

b = Sxy ÷ Sxx
a = ȳ − b × x̄
r = Sxy ÷ √(Sxx × Syy),  R² = r²

Standard errors and residuals

A residual is the difference y − ŷ between a point and the line. The residual standard error s = √(SSE ÷ (n − 2)) measures their typical size, and the standard errors of the slope and the intercept show how precisely they are estimated from the data.

A correlation close to 1 or −1 does not show that x causes y; it shows only that the points lie close to a straight line.

SSE = Σ (y − ŷ)²,  s = √(SSE ÷ (n − 2))
SE(b) = s ÷ √Sxx,  SE(a) = s × √(1/n + x̄² ÷ Sxx)

What the calculator does not cover

  • More than one x variable (multiple regression), curves, and transformed data.
  • Confidence intervals and significance tests for the slope; use the standard errors with your own critical value.
  • More than 200 pairs in one calculation, and pairs with a missing value.

Worked example: x = 1 to 5 and y = 2, 4, 5, 4, 5

The means are x̄ = 3 and ȳ = 4. Sxx = 10, Syy = 6 and Sxy = 6, so the slope is b = 6 ÷ 10 = 0.6 and the intercept is a = 4 − 0.6 × 3 = 2.2. The line is y = 0.6x + 2.2.

The correlation is r = 0.7746, so R² = 0.6. The standard error of the slope is 0.2828, and the prediction at x = 6 is 0.6 × 6 + 2.2 = 5.8.

Result
Slope b 0.6
Intercept a 2.2
Correlation r, R² 0.7746, 0.6
Prediction at x = 6 5.8

Frequently asked questions

How do I enter the data?

Put each pair on its own line, with the x value, a space and the y value. Use a point for decimals in English, or a comma in Turkish. Lines that do not hold exactly two numbers are reported with their line number.

What does R² tell me?

R² is the share of the variation in y that the line explains, between 0 and 1. An R² of 0.6 means that 60% of the variation in y is accounted for by x in a straight-line model.

What is a residual?

A residual is the observed y minus the fitted value ŷ on the line. Positive residuals are points above the line and negative ones are points below it, and the residuals add up to 0 for a least-squares line.

Why does the chart use equal steps for the x values?

The chart is a line chart with the points in order of x. The x labels are spaced evenly, so with very uneven x values the shape of the line is only a guide; the table gives the exact values.

Why do I need at least three pairs?

The standard errors use n − 2 degrees of freedom, so two pairs fit a line exactly and tell you nothing about its error. Three pairs is the least that gives a standard error.

Are the numbers I enter sent to a server?

No. The regression runs in your browser, and nothing you type is sent to us.

Sources

Figures and text last checked on Tuesday, November 10, 2026.

We use necessary cookies to run the site. With your consent, Google also uses advertising cookies to show personalised ads. If you reject them, you still see ads, but they are not personalised.