Regression formulas
Slope
b = Σ(x − x̄)(y − ȳ) ÷ Σ(x − x̄)² = Sxy ÷ Sxx
Intercept
a = ȳ − b·x̄
Line of best fit
ŷ = bx + a
Correlation coefficient
r = Sxy ÷ √(Sxx · Syy)
Worked example
Points: (1, 2), (2, 4), (3, 5), (4, 4), (5, 5).
- Means: x̄ = 3, ȳ = 4.
- Sxy = (-2)(-2) + (-1)(0) + (0)(1) + (1)(0) + (2)(1) = 6.
- Sxx = (-2)² + (-1)² + (0)² + (1)² + (2)² = 10.
- Slope b = 6 ÷ 10 = 0.6.
- Intercept a = 4 − 0.6 × 3 = 2.2.
- The line is ŷ = 0.6x + 2.2, with r = 0.7746 and R² = 0.6: the line explains 60% of the variation in y.
Before you trust the line
- Look at the scatter plot. If the points curve, a straight line is the wrong model even when r looks high.
- Check for outliers. One point far from the rest can swing the slope a long way.
- Keep predictions inside the range of x you measured.
To summarize one variable at a time, use the mean, median and mode calculator and the standard deviation calculator.