Linear Regression Calculator

Slope, intercept, and r from comma-separated X and Y lists, with optional prediction. Click any i for detail.

Jump to result

Data

X values
i
X

Comma-separated numbers.

Y values
i
Y

Comma-separated; same count as X.

Predict Y at X (optional)
i
Predict

Evaluate ŷ = a + bx.

How to use this calculator

  1. Enter matching X and Y comma lists.
  2. Optionally set an X to predict.
  3. Read slope, intercept, r, and ŷ.
  4. Check scatter assumptions before trusting the fit.

Results explained

Ordinary least squares chooses slope and intercept to minimize squared vertical residuals. Correlation r measures linear association strength and sign.

Quick reference: simple OLS

b = Σ((x−x̄)(y−ȳ))/Σ((x−x̄)²); a = ȳ − b x̄.

ItemDetail
r = ±1Perfect linear association
r ≈ 0Weak linear link
ExtrapolationRisky outside data range
nNeed ≥ 2 distinct x

Educational fit only — not causal inference.

How the estimate is built

b = Sxy/Sxx; a = ȳ − b x̄; r = Sxy / √(Sxx Syy); ŷ = a + bx.

Example scenario

X=1..5, Y=2,3,5,4,6 → slope 0.9, intercept 1.3, r=0.9; ŷ(6)=6.7.

FAQ

Multiple regression?

Not on this page.

Unequal list lengths?

The page requires equal counts.

Outliers?

They can dominate OLS — inspect a plot.

r²?

Square r for variance explained in the simple linear case.