Linear Regression Calculator

Linear regression fits the straight line that best describes how Y changes with X, using least squares. Use it to describe a trend or to predict Y for a new X.

Separate numbers with commas or spaces.
Separate numbers with commas or spaces.
Results update as you type.

Regression line

y = 0.866667 + 1.94286x

Predicted Y at X = 4.5
9.6095238
Slope (b)
1.9428571Y changes by 1.94286 for each 1 added to X
Intercept (a)
0.86666667
R²
0.981047the line explains 98.1% of the variation
Correlation (r)
0.990478
Standard error of estimate
0.564843
p-value for the slope
0.000135571t = 14.389, df = 4

About this calculator

You get the equation, how well it fits (R²) and whether the slope is statistically significant.

How to use it

  1. Enter the X values and the matching Y values.
  2. Optionally enter an X to predict at.
  3. Read the equation and fit.

The formula

b = Σ(x − x̄)(y − ȳ) ÷ Σ(x − x̄)²; a = ȳ − b x̄
b
slope
a
intercept
x̄, ȳ
means of X and Y

Worked example

X 1 to 6 and Y 3, 5, 6, 9, 10, 13

  1. b = 1.943 and a = 0.867, so y = 0.867 + 1.943x.
  2. R² = 0.981; at X = 4.5, Y ≈ 9.61.

What the result means

The slope is the change in Y for each unit of X. Predictions outside the range of your X values are guesses and are flagged.

Assumptions

  • A straight-line relationship with roughly constant scatter.

Limitations

  • Outliers can pull the line strongly.

Frequently asked questions

What is the regression of y on x?

The line used to predict y from x, which is what this calculator gives.

What does R² = 0.8 mean?

The line explains 80% of the variation in Y.

Can I predict X from Y with the same line?

Not exactly; the regression of x on y is a different line unless r is ±1.

Last reviewed on 6 October 2026. Found a mistake? Tell us.