Moving Averages

Learn what moving averages are and how to use them to make forecasts.

Understanding moving averages

Moving averages can refer to two different things in time series forecasting:

  • A simpler concept, also known as a rolling mean.

  • The moving average model, also known as MA(n).

The rolling mean is the average of the value we are looking at calculated over a certain period of time. That average is updated according to the period, so it's always relative.

Using weather data as an example, we could look at the average temperature over the past thirty days. If we do that for every day in our data series, we would get the moving average over thirty days for the whole period. Let's see how to do this in practice and how we can use this to make forecasts.

Calculating simple moving averages

Using our Seattle weather data as an example, we can plot the original time series with the moving average to see how it behaves. In pandas, we can do this with the rolling() method.

Get hands-on with 1200+ tech skills courses.