# 6.2 Moving averages

The classical method of time series decomposition originated in the 1920s and was widely used until the 1950s. It still forms the basis of later time series methods, and so it is important to understand how it works. The first step in a classical decomposition is to use a moving average method to estimate the trend-cycle, so we begin by discussing moving averages.

## Moving average smoothing

Year | Sales (GWh) | 5-MA |
---|---|---|

1989 | 2354.34 | |

1990 | 2379.71 | |

1991 | 2318.52 | 2381.53 |

1992 | 2468.99 | 2424.56 |

1993 | 2386.09 | 2463.76 |

1994 | 2569.47 | 2552.60 |

1995 | 2575.72 | 2627.70 |

1996 | 2762.72 | 2750.62 |

1997 | 2844.50 | 2858.35 |

1998 | 3000.70 | 3014.70 |

1999 | 3108.10 | 3077.30 |

2000 | 3357.50 | 3144.52 |

2001 | 3075.70 | 3188.70 |

2002 | 3180.60 | 3202.32 |

2003 | 3221.60 | 3216.94 |

2004 | 3176.20 | 3307.30 |

2005 | 3430.60 | 3398.75 |

2006 | 3527.48 | 3485.43 |

2007 | 3637.89 | |

2008 | 3655.00 |

ylab="GWh", xlab="Year")

lines(ma(elecsales,5),col="red")

Notice how the trend (in red) is smoother than the original data and captures the main movement of the time series without all the minor fluctuations. The moving average method does not allow estimates of $T_{t}$ where $t$ is close to the ends of the series; hence the red line does not extend to the edges of the graph on either side. Later we will use more sophisticated methods of trend-cycle estimation which do allow estimates near the endpoints.

The order of the moving average determines the smoothness of the trend-cycle estimate. In general, a larger order means a smoother curve. The following graph shows the effect of changing the order of the moving average for the residential electricity sales data.

Simple moving averages such as these are usually of odd order (e.g., 3, 5, 7, etc.) This is so they are symmetric: in a moving average of order $m=2k+1$, there are $k$ earlier observations, $k$ later observations and the middle observation that are averaged. But if $m$ was even, it would no longer be symmetric.

## Moving averages of moving averages

It is possible to apply a moving average to a moving average. One reason for doing this is to make an even-order moving average symmetric.

For example, we might take a moving average of order 4, and then apply another moving average of order 2 to the results. In Table 6.2, this has been done for the first few years of the Australian quarterly beer production data.

Year | Data | 4-MA | 2x4-MA |
---|---|---|---|

1992 Q1 | 443.00 | ||

1992 Q2 | 410.00 | 451.25 | |

1992 Q3 | 420.00 | 448.75 | 450.00 |

1992 Q4 | 532.00 | 451.50 | 450.12 |

1993 Q1 | 433.00 | 449.00 | 450.25 |

1993 Q2 | 421.00 | 444.00 | 446.50 |

1993 Q3 | 410.00 | 448.00 | 446.00 |

1993 Q4 | 512.00 | 438.00 | 443.00 |

1994 Q1 | 449.00 | 441.25 | 439.62 |

1994 Q2 | 381.00 | 446.00 | 443.62 |

1994 Q3 | 423.00 | 440.25 | 443.12 |

1994 Q4 | 531.00 | 447.00 | 443.62 |

1995 Q1 | 426.00 | 445.25 | 446.12 |

1995 Q2 | 408.00 | 442.50 | 443.88 |

1995 Q3 | 416.00 | 438.25 | 440.38 |

1995 Q4 | 520.00 | 435.75 | 437.00 |

1996 Q1 | 409.00 | 431.25 | 433.50 |

1996 Q2 | 398.00 | 428.00 | 429.62 |

1996 Q3 | 398.00 | 433.75 | 430.88 |

ma4 <- ma(beer2, order=4, centre=FALSE)

ma2x4 <- ma(beer2, order=4, centre=TRUE)

## Estimating the trend-cycle with seasonal data

## Example 6.2 Electrical equipment manufacturing

Figure 6.9 shows a $2\times12$-MA applied to the electrical equipment orders index. Notice that the smooth line shows no seasonality; it is almost the same as the trend-cycle shown in Figure 6.2 which was estimated using a much more sophisticated method than moving averages. Any other choice for the order of the moving average (except for 24, 36, etc.) would have resulted in a smooth line that shows some seasonal fluctuations.

main="Electrical equipment manufacturing (Euro area)")

lines(ma(elecequip, order=12), col="red")

## Weighted moving averages

Name | a_{0} |
a_{1} |
a_{2} |
a_{3} |
a_{4} |
a_{5} |
a_{6} |
a_{7} |
a_{8} |
a_{9} |
a_{10} |
a_{11} |
---|---|---|---|---|---|---|---|---|---|---|---|---|

3-MA | .333 | .333 | ||||||||||

5 MA | .200 | .200 | .200 | |||||||||

2x12-MA | .083 | .083 | .083 | .083 | .083 | .083 | .042 | |||||

3x3-MA | .333 | .222 | .111 | |||||||||

3x5-MA | .200 | .200 | .133 | .067 | ||||||||

S15-MA | .231 | .209 | .144 | .066 | .009 | -.016 | -.019 | -.009 | ||||

S21-MA | .171 | .163 | .134 | .037 | .051 | .017 | -.006 | -.014 | -.014 | -.009 | -.003 | |

H5-MA | .558 | .294 | -.073 | |||||||||

H9-MA | .330 | .267 | .119 | -.010 | -.041 | |||||||

H13-MA | .240 | .214 | .147 | .066 | .000 | -.028 | -.019 | |||||

H23-MA | .148 | .138 | .122 | .097 | .068 | .039 | .013 | -.005 | -.015 | -.016 | -.011 | -.004 |

*S = Spencer’s weighted moving average
H = Henderson’s weighted moving average
Table 6.3: Commonly used weights in weighted moving averages.*