Skip to content
Statistics CalculatorStatistics Calculator

Linear Regression Calculator

Fit a least-squares regression line to your paired data. Get the slope, intercept, correlation, and R², plus a scatter plot with the fitted line drawn through your points.

Tested against reference valuesLast reviewed August 2026
Paired data
Regression equation
ŷ = 0.2786 + 0.9548x
Slope (b)0.9548
0.9951
Intercept (a)
0.2786
Correlation (r)
0.9975
Mean of x
4.5000
Mean of y
4.5750
n (pairs)
8
Residual SS
0.1890

Scatter & regression line

R² = 0.9951
0.664.558.440.444.508.56
Data points Regression line

How to use this calculator

  1. Enter your independent (x) values and dependent (y) values, each separated by commas, spaces, or new lines.
  2. Make sure the two lists have the same number of values — one x for each y.
  3. Read the regression equation, slope, intercept, and R², and see the fitted line on the scatter plot.

What is linear regression?

Simple linear regression finds the straight line that best describes the relationship between an independent variable x and a dependent variable y. “Best” is defined by ordinary least squares (OLS): the line that minimizes the sum of the squared vertical distances between the data points and the line.

Least squares regression formula

The fitted line is ŷ = a + bx, where the slope b and intercept a are:

b=(xixˉ)(yiyˉ)(xixˉ)2b=\dfrac{\sum (x_i-\bar{x})(y_i-\bar{y})}{\sum (x_i-\bar{x})^2}a=yˉbxˉa=\bar{y}-b\bar{x}

The slope tells you how much y changes for a one-unit increase in x, and the intercept is the predicted value of y when x is zero.

What does R² mean?

R² (the coefficient of determination) is the proportion of the variation in y that is explained by the regression line. It ranges from 0 to 1: an R² of 0.85 means 85% of the variability in y is accounted for by x. R² is the square of the Pearson correlation coefficient r.

A high R² does not prove causation, and a straight line may be a poor model even with a high R². Always look at the scatter plot.

Linear regression in Excel

Use =SLOPE(y_range, x_range) and =INTERCEPT(y_range, x_range) for the line, =RSQ(y_range, x_range) for R², and =CORREL(x_range, y_range) for the correlation. Or add a trendline to a scatter chart and display its equation and R².

Frequently asked questions

What is the least squares regression line?

It is the straight line that minimizes the sum of the squared vertical distances (residuals) between the observed data points and the line. It gives the best linear fit in the least-squares sense.

What is the difference between r and R²?

r is the Pearson correlation coefficient, ranging from −1 to 1, which measures the strength and direction of the linear relationship. R² is r squared, ranging from 0 to 1, and represents the proportion of variance in y explained by x.

How do I interpret the slope and intercept?

The slope is the predicted change in y for each one-unit increase in x. The intercept is the predicted value of y when x equals zero, which is only meaningful if x = 0 is within a sensible range for your data.

How do I run a linear regression in Excel?

Use =SLOPE(y,x), =INTERCEPT(y,x), and =RSQ(y,x), or insert a scatter chart and add a trendline with the equation and R² displayed.

Related calculators

Was this calculator helpful?