Documentation Center

  • Trial Software
  • Product Updates

Moving Average Filter

Some time series are decomposable into various trend components. To estimate a trend component without making parametric assumptions, you can consider using a filter.

Filters are functions that turn one time series into another. By appropriate filter selection, certain patterns in the original time series can be clarified or eliminated in the new series. For example, a low-pass filter removes high frequency components, yielding an estimate of the slow-moving trend.

A specific example of a linear filter is the moving average. Consider a time series yt, t = 1,...,N. A symmetric (centered) moving average filter of window length 2q + 1 is given by

You can choose any weights bj that sum to one. To estimate a slow-moving trend, typically q = 2 is a good choice for quarterly data (a 5-term moving average), or q = 6 for monthly data (a 13-term moving average). Because symmetric moving averages have an odd number of terms, a reasonable choice for the weights is for j = ±q, and otherwise. Implement a moving average by convolving a time series with a vector of weights using conv.

You cannot apply a symmetric moving average to the q observations at the beginning and end of the series. This results in observation loss. One option is to use an asymmetric moving average at the ends of the series to preserve all observations.

See Also

Related Examples

More About

Was this topic helpful?