Skip to content

Business Mathematics and Statistics · Ch 9 — Applied Statistics (Time Series, Index Numbers, Statistical Quality Control)

Measuring Trend: Method of Least Squares

3

Measuring Trend: Method of Least Squares

The method of least squares fits a mathematical trend line to a time series so that trend can be measured (and, importantly, extended to forecast future years) without losing values at either end the way the moving average method does. For a straight-line trend,

Y=a+bXY = a + bX

where YY is the trend value, XX represents time (the year), and aa, bb are constants found by solving the two normal equations:

∑Y=na+b∑X∑XY=a∑X+b∑X2\sum Y = na + b\sum X \qquad \qquad \sum XY = a\sum X + b\sum X^2

The arithmetic is made simple by a standard trick: code the years so that the middle year becomes X=0X=0 and the years on either side become −1,−2,…-1, -2, \ldots and 1,2,…1, 2, \ldots. This makes ∑X=0\sum X = 0, which collapses the normal equations to

a=∑Ynb=∑XY∑X2a = \dfrac{\sum Y}{n} \qquad \qquad b = \dfrac{\sum XY}{\sum X^2}

Worked Example. A shop's sales (₹ lakh) for five years were:

Year20172018201920202021
Sales (YY)1820222832

Coding the middle year (2019) as X=0X=0:

YearXXYYXYXYX2X^2
2017−2-218−36-364
2018−1-120−20-201
20190022000
2020112828281
2021223264644
Total∑X=0\sum X = 0∑Y=120\sum Y = 120∑XY=36\sum XY = 36∑X2=10\sum X^2 = 10

a=1205=24b=3610=3.6a = \dfrac{120}{5} = 24 \qquad \qquad b = \dfrac{36}{10} = 3.6

So the fitted trend line is Y=24+3.6XY = 24 + 3.6X. Substituting each XX back gives the trend values:

| Year | 2017 | 2018 | 2019 | 2020 | 2021 |

|---|---|---|---|---|---| …

Definition 8Method of Least Squares

A method of fitting a trend line to a time series such that the sum of the squares of the deviations of the actual values from the trend value …

Definition 9Normal Equations

The pair of simultaneous equations, derived from the least-squares condition, that are solved to find the constants aa and bb of a fitted str …