Method of Least Squares
Linear Regression — Chapter 2, GSEB Class 12 Statistics
The Principle
The method of least squares finds the straight line that minimizes the sum of squared vertical errors between the actual data points and the line.
Error = Actual Y − Predicted Y
Minimize
Σ(Y − Ŷ)²
Get
Best-fit line
Normal Equations
To find a (intercept) and b (slope), solve two simultaneous equations:
How to solve
- Step 1: Compute ΣX, ΣY, ΣXY, ΣX² from the data
- Step 2: Substitute into the two normal equations
- Step 3: Solve simultaneously for a and b
- Step 4: Write the equation Y = a + bX
Worked Example
Fit a regression line Y on X for the given data
| X | Y | XY | X² |
|---|---|---|---|
| 1 | 2 | 2 | 1 |
| 2 | 4 | 8 | 4 |
| 3 | 5 | 15 | 9 |
| 4 | 4 | 16 | 16 |
| 5 | 5 | 25 | 25 |
| 15 | 20 | 66 | 55 |
Substitute: 20 = 5a + 15b ... (1)
66 = 15a + 55b ... (2)
Solving: b = (5 × 66 − 15 × 20) / (5 × 55 − 15²) = 0.60
a = 4 − 0.60 × 3 = 2.20
Ŷ = 2.20 + 0.60X
Understanding Slope (b)
The slope b tells us: for every 1-unit increase in X, how much does Y change?Drag the slider to see how changing b affects the line.
When X increases by 1 unit, Y changes by 0.7 units (Y increases)
Understanding Intercept (a)
The intercept a is where the regression line crosses the Y-axis (when X = 0). Drag the slider to see how changing a shifts the entire line up or down.
When X = 0, Y = 1.5 — the line crosses the Y-axis at this point.
Changing a shifts the entire line up or down without changing its steepness.
Key Takeaways
Key Takeaways
- Method of least squares minimizes Σ(Y − Ŷ)² — the sum of squared vertical errors.
- Normal equations: ΣY = na + bΣX and ΣXY = aΣX + bΣX².
- Slope b = change in Y for 1-unit increase in X. Larger |b| = steeper line.
- Intercept a = value of Y when X = 0 — where the line crosses the Y-axis.
- Changing b rotates the line (steeper/flatter); changing a shifts the line up/down.
- The resulting line Y = a + bX is the best-fit line through the data.