notesonly.in

One notebook for every subject — open it anywhere.

Log in

Lines of Regression: Equations with Examples Guide

A line of regression is the straight line that best predicts one variable from another. Given data like advertising spend (x) and sales (y), the regression line of y on x lets you estimate sales for any spend level.

This matters because decisions constantly require predicting the unobserved: how many marks will 6 hours of study earn, what revenue follows a ₹50,000 ad campaign. The regression line turns a cloud of past data into a usable prediction rule.

Key Concepts

  • Regression line of y on x: ŷ = a + bx, the line minimising the sum of squared vertical errors (least squares).
  • Slope b: the expected change in y for a one-unit increase in x. Also written b = r × (sy / sx), linking it to correlation.
  • Intercept a: the predicted y when x = 0, computed as a = ȳ − bx̄ — the line always passes through (x̄, ȳ).
  • Residual: y − ŷ, the vertical gap between an actual point and the line; least squares minimises the sum of squared residuals.
  • Two regression lines: y on x (predict y from x) and x on y (predict x from y) are different lines unless r = ±1.
  • Interpolation vs extrapolation: predicting inside the data range is interpolation (safe); outside it is extrapolation (risky).

Formulas

  • Slope: b = Σ(x − x̄)(y − ȳ) / Σ(x − x̄)².
  • Intercept: a = ȳ − b x̄.
  • Prediction: ŷ = a + bx for any x.
  • Via correlation: b = r (sy / sx), where r is the correlation coefficient and sx, sy the standard deviations.

Assumptions: the relationship is approximately linear, x is measured without huge error, and residuals have roughly constant spread.

Worked Example

Data (x, y): (1, 2), (2, 4), (3, 5), (4, 4), (5, 6). Find the regression line of y on x and predict y at x = 6.

  1. Means: x̄ = (1+2+3+4+5)/5 = 3; ȳ = (2+4+5+4+6)/5 = 21/5 = 4.2.
  2. Denominator: Σ(x − x̄)² = 4 + 1 + 0 + 1 + 4 = 10.
  3. Numerator: (−2)(−2.2) + (−1)(−0.2) + (0)(0.8) + (1)(−0.2) + (2)(1.8) = 4.4 + 0.2 + 0 − 0.2 + 3.6 = 8.0.
  4. Slope: b = 8.0 / 10 = 0.8.
  5. Intercept: a = 4.2 − 0.8 × 3 = 4.2 − 2.4 = 1.8.
  6. Line: ŷ = 1.8 + 0.8x. Check: at x = 3, ŷ = 4.2 = ȳ, as theory promises.
  7. Predict: at x = 6, ŷ = 1.8 + 4.8 = 6.6 — a mild extrapolation, so treat it cautiously.

Common Misconceptions

  • Regression does not prove causation. A perfect line between ice-cream sales and drownings predicts well but explains nothing — both follow temperature.
  • The two regression lines are not interchangeable. Predicting y from x uses one line; predicting x from y uses another. Using the wrong one gives biased predictions.
  • Extrapolation is dangerous. The line is only validated where data exists; trends bend, saturate, or break outside the observed range.

Real-World Applications

  • Sales forecasting: retailers predict revenue from planned advertising spend.
  • Medicine: estimating a patient's expected recovery time from dosage and age.
  • Agriculture: predicting crop yield from rainfall or fertiliser quantity.
  • Real estate: estimating house prices from floor area in a neighbourhood.

The regression line compresses a scatterplot's story into ŷ = a + bx: slope for the rate of change, intercept for the baseline, and least squares guaranteeing the best straight-line fit. Learn to compute it, and you can turn any two related variables into predictions.