Linear Regression Calculator
Slope, intercept, and r from comma-separated X and Y lists, with optional prediction. Click any i for detail.
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
- Enter matching X and Y comma lists.
- Optionally set an X to predict.
- Read slope, intercept, r, and ŷ.
- 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̄.
| Item | Detail |
|---|---|
| r = ±1 | Perfect linear association |
| r ≈ 0 | Weak linear link |
| Extrapolation | Risky outside data range |
| n | Need ≥ 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.