Skip to content
FiftyCalc Free calculators for all 50 states

Linear Regression Calculator

Test cases replayed : 2 of 2 match · Methodology · No outside source listed

Paste two lists of paired values, x and y, in the same order to fit the least-squares line and predict y for a new x.

Result

Sample figures

Regression line—

Slope (b) —

  • Intercept (a)—
  • Predicted y at that x—
  • Correlation coefficient (r)—
  • Coefficient of determination (r²)—
  • Number of pairs—
  • Note—

Estimate for planning only, not tax, legal, financial or medical advice. This calculator uses the method explained on this page.

Linear Regression Calculator

x values (separated by commas, spaces or new lines): type or paste your values. Prefilled example: 1, 2, 3, 4, 5.

y values, same order and count: type or paste your values. Prefilled example: 2, 4, 5, 4, 5.

x value to predict y for: enter a number. Prefilled example: 6.

How to use this calculator

Fill in the fields in this order; each step takes you to its field.

  1. x values (separated by commas, spaces or new lines): type or paste your values.
  2. y values, same order and count: type or paste your values.
  3. x value to predict y for: enter a number.
  4. Read the result: Regression line; the panel also shows Slope (b), Intercept (a), Predicted y at that x, Correlation coefficient (r), Coefficient of determination (r²), Number of pairs and Note.

How this calculator works

Ordinary least squares fits the line y = a + bx that makes the sum of squared vertical distances from the points smallest: slope b = Σ(xᵢ − x̄)(yᵢ − ȳ) ÷ Σ(xᵢ − x̄)², intercept a = ȳ − b x̄.

r is Pearson's correlation coefficient and r² the share of the variance of y explained by the line. A prediction far outside the range of the x values is an extrapolation and may not hold.

Worked example

x values (separated by commas, spaces or new lines)1, 2, 3, 4, 5
y values, same order and count2, 4, 5, 4, 5
x value to predict y for6
Regression liney = 2.2 + 0.6x
Slope (b)0.6
Intercept (a)2.2
Predicted y at that x5.8
Correlation coefficient (r)0.7746
Coefficient of determination (r²)0.6
Number of pairs5

Frequently asked questions

What is the regression line for x = 1 to 5 and y = 2, 4, 5, 4, 5?

y = 2.2 + 0.6x, with r² = 0.6; at x = 6 the line predicts y = 5.8.

Is least-squares regression the same as linear regression?

Yes for a straight line: simple linear regression is usually fitted by ordinary least squares, the method used here.

Questions answered

Related calculators