Linear Regression Calculator
Calculate simple linear regression equation y = mx + b from data points. Find slope, intercept, R² goodness of fit, and predicted values. Identify trends in your data.
Formula & Reference
| Variable | Symbol | Formula | Units |
|---|---|---|---|
| Linear Regression Calculator | — | y = mx + b (m = r × sy/sx) | same as data units |
Step-by-Step Examples
x (hours): 1,2,3,4,5. y (score): 50,60,65,70,80.
- mx = 3, my = 65
- m = Σ(xi-mx)(yi-my)/Σ(xi-mx)² = 20/10 = 7
- b = 65 - 7×3 = 44
- Equation: y = 7x + 44
- Each extra hour predicts 7 more points
x (sq ft): 1000,1200,1500,1800,2000. y ($k): 150,180,210,250,280.
- Slope m ≈ 0.12 ($k per sq ft = $120/sq ft)
- b ≈ 3.6 ($3,600 base)
- Predict 1600 sq ft: y = 0.12×1600+3.6 = 195.6 ($196k)
- R² ≈ 0.99: very strong linear fit
Same equation y=7x+44. Predict score for 8 hours studying.
- y = 7(8) + 44 = 56 + 44 = 100
- Predicted score = 100
- But 8 hours is outside training data range (1-5 hrs)
- Extrapolation beyond data range is risky!
Real-World Applications
Common Mistakes to Avoid
Predicting y for x values far outside your training data is unreliable. The relationship may be nonlinear outside the observed range.
R² alone doesn't confirm a linear relationship is appropriate. Always check a residual plot for patterns — systematic curves indicate nonlinearity.
Regression fits a line; it doesn't prove x causes y. Many strong regressions are spurious (ice cream sales predicting drownings — both caused by summer heat).
Frequently Asked Questions
Related Math Calculators
Formula Explorer connections
Interpretation: This formula summarizes data, models uncertainty or supports inference about a population or random process. Assumption: The sampling design and distribution assumptions must match the data. Independence, sample size, outliers and measurement quality can materially affect interpretation.