Share this free calculator
Send this tool to someone who needs the calculation.
How to use
This simple linear regression calculator fits the least-squares line between an independent variable X and dependent variable Y. It reports slope b, intercept a, correlation r and R², and can predict ŷ for a new X value. A fitted line describes association; it does not prove causation.
- Enter the X values in order.
- Enter the same number of Y values in matching order.
- Optionally enter a new X for prediction, then calculate.
How it is calculated
Example
Example: X=1,2,3,4,5 and Y=2,4,5,4,5 give approximately ŷ=2.2+0.6x and R²=0.6. At X=6, ŷ≈5.8.
Important notes
X must vary; if every X is identical, slope is undefined. If Y is perfectly constant, the regression line still exists but the usual r and R² interpretation is undefined, so those fields may show as unavailable.
Worked examples and interpreting results
Pairs X=(1, 2, 3) and Y=(3, 5, 7) lie exactly on y=2 x+1. Slope is 2, intercept 1 and prediction at x=4 is 9.
| Case | Calculation | Result |
|---|---|---|
| Slope | (7 − 3) ÷ (3 − 1) | 2 |
| Prediction at four | 2 × 4 + 1 | 9 |
How to check the result
Enter lists in matching order so each X pairs with its Y, and enter prediction 4. A perfect fit in this example proves neither causality nor reliable extrapolation beyond the data.
Frequently asked questions
What is the difference between r and R²?
r gives the direction and strength of linear association; in simple regression, R² summarizes the fraction of Y variation associated with the fitted linear model.
Can I extrapolate beyond the X range?
You can compute it, but extrapolation may be much less reliable because the relationship can change outside observed data.
Does regression prove causation?
No. Regression and correlation alone do not establish causality.