Skip to content

Mathematics and Statistics · Ch 12 — Time Series

Measurement of Trend: Method of Least Squares

5

Measurement of Trend: Method of Least Squares

The method of least squares fits an objective mathematical trend line to the data — the one straight line for which the sum of the squares of the vertical gaps between the actual points and the line is the smallest possible. This is the same principle used to fit a regression line, and it gives a unique trend equation that can also be used to forecast.

Let time be measured by a variable XX and the observed values by YY. The straight-line trend is

Yt=a+bX,Y_t = a + bX,

where aa is the trend value at the origin (X=0X = 0) and bb is the amount by which the trend changes per unit of time. The values of aa and bb that minimise the squared error satisfy the two normal equations:

∑Y=n a+b∑X,\sum Y = n\,a + b\sum X,

∑XY=a∑X+b∑X2.\sum XY = a\sum X + b\sum X^2.

The coding short-cut. The arithmetic becomes very light if we measure time as a deviation from the middle year, so that ∑X=0\sum X = 0. The normal equations then collapse to

a=∑Yn,b=∑XY∑X2.a = \frac{\sum Y}{n}, \qquad b = \frac{\sum XY}{\sum X^2}.

  • Odd number of years: take the middle year as origin and let X=…,−2,−1,0,1,2,…X = \ldots, -2, -1, 0, 1, 2, \ldots (one unit == one year). Then ∑X=0\sum X = 0 automatically.
  • Even number of years: there is no middle year, so take the origin midway between the two central years and use a half-year unit, giving X=…,−3,−1,1,3,…X = \ldots, -3, -1, 1, 3, \ldots (consecutive odd numbers). Again ∑X=0\sum X = 0; here one XX-unit is half a year, so the yearly change in trend is 2b2b.

Once aa and bb are found, substitute each year's XX to get its trend value, and substitute a future year's XX to forecast.

Tip

Merits and limitations …

Definition 1Method of least squares

A method that fits the trend line Y=a+bXY = a + bX by making the sum of squared vertical deviations of the points from the line a minimum, giving …

Definition 2Normal equations

The pair ∑Y=na+b∑X\sum Y = na + b\sum X and ∑XY=a∑X+b∑X2\sum XY = a\sum X + b\sum X^2, solved for aa and bb; when ∑X=0\sum X = 0 they reduce to a=∑Y/na = \sum Y / n and …

Definition 3Trend value

The value Yt=a+bXY_t = a + bX predicted by the fitted line for a given time XX; used both to smooth existing years and to …