Method of Least Squares
Time Series — Chapter 5, GSEB Class 12 Statistics
Fitting a Trend Line
The method of least squares fits a straight trend line through the time series data. We assign natural numbers (t = 1, 2, 3, ...) to the time periods and use the least squares formulas to find the best-fit line.
Worked Example
Fit a trend line for the following sales data
| Year | t | Sales (y) | ty | t² |
|---|---|---|---|---|
| 2017 | 1 | 35 | 35 | 1 |
| 2018 | 2 | 40 | 80 | 4 |
| 2019 | 3 | 38 | 114 | 9 |
| 2020 | 4 | 46 | 184 | 16 |
| 2021 | 5 | 50 | 250 | 25 |
| 2022 | 6 | 54 | 324 | 36 |
| 2023 | 7 | 52 | 364 | 49 |
| Total | 315 | 1351 | 140 | |
t̄ = Σt / n = 28 / 7 = 4
ȳ = Σy / n = 315 / 7 = 45.00
b = (nΣty − ΣtΣy) / (nΣt² − (Σt)²) = (7 × 1351 − 28 × 315) / (7 × 140 − 28²)
= (9457 − 8820) / (980 − 784) = 3.25
a = ȳ − b·t̄ = 45.00 − 3.25 × 4 = 32.00
Ŷ = 32.00 + 3.25t
Forecasting
To forecast future values, assign the next natural number to t and substitute:
Forecast for 2024 and 2025:
2024: t = 8 (next natural number after 7)
Ŷ = 32.00 + 3.25 × 8 = 58.00
2025: t = 9
Ŷ = 32.00 + 3.25 × 9 = 61.25
Key Takeaways
Key Takeaways
- Assign natural numbers to time periods: t = 1, 2, 3, ...
- b = (nΣty − ΣtΣy) / (nΣt² − (Σt)²) — the slope of the trend line.
- a = ȳ − b·t̄ — the intercept where the line crosses the Y-axis.
- Trend line: Ŷ = a + bt — substitute t for any year to forecast.
- For future years, continue the natural number sequence (t = n+1, n+2, ...).