What Is a Moving Average Model?

365 Data Science
365 Data Science
Published in
4 min readApr 1, 2020

What do we use the Moving Average model for?

In time-series, we sometimes observe similarities between past errors and present values. That’s because certain unpredictable events happen, and they need to be accounted for.

In other words, by knowing how far off our estimation yesterday was, compared to the actual value, we can tweak our model, so that it responds accordingly.

So, in this tutorial, we’re going to examine a model that considers past residuals — the Moving Average model. We’ll discuss notation, learn how to interpret it and then digest the different parts.

Let’s get right down to it!

What is the equation of a Moving Average model?

Let’s suppose that “r” is some time-series variable, like returns. Then, a simple Moving Average (MA) model looks like this:

Now, just like we did in the tutorial about the Autoregressive model, let’s go over the different parts of this equation. This will ensure you understand the idea thoroughly.

For starters, r t represents the values of “r” in the current period — t. In terms of returns, it’s what we’re estimating the returns for today will be.

What is c?

The first thing we see on the right side of the model is “c” — this stands for a constant factor. Of course, this is just the general representation and we would substitute this with a numeric value when we’re actually modeling data.

Next, θ 1 is a numeric coefficient for the value associated with the 1st lag. We prefer not to use ϕ 1 like in the Autoregressive model, to avoid confusion.

Then come ϵ t and ϵ t-1 which represent the residuals for the current and the previous period, respectively.

For anybody not familiar with the term, a residual is the same as an error term — it expresses the difference between the observed value for a variable and our estimation. In this specific case: ϵ t-1 = r t-1 — r̂ t-1 , where r̂ t-1 represents our estimation for the previous period.

So, how do we generate these residuals?

It’s quite simple. We start from the beginning of the dataset r 1 and try to predict each value (r̂ 2, r̂ 3, etc). Depending on how far off we were each time, we get a residual ϵ t = r t — r̂ t. Therefore, we generate these residuals as we go through the set and create the ϵ variable as we move through time (from period 1, all the way up to the current period).

What are the similarities between the Moving Average model and the Autoregressive model?

You can notice some parallels between the Moving Average model and the Autoregressive model we examined in a previous article. In fact, we can say a simple moving average model is equivalent to an infinite-lag autoregressive model with certain restrictions. You can find more details on that here.
Not to mention that an inverse relationship exists as well. To be more precise, a simple Autoregressive model can be a close approximator to an infinite-lag moving average model. If you’re interested to learn more, you can read about it here.

Now, in both models, we have the present-day value r_t equal a sum of a constant c; some error term ϵ_t; and a lagged value (r t-1, ϵ t-1) multiplied by an assigned coefficient (ϕ 1, θ 1). The only major difference is that the autoregressive model uses the value of the variable (r t-1), while the moving average model relies on the residual (ϵ t-1).
Finally, there’s one more common trait of the AR and MA models — the restriction remains that the absolute value of each coefficient should be less than 1(|ϕ n|<1,|θ n|<1). Once again, this is to prevent compounded effects exploding in magnitude, as we discussed in the AR model tutorial.

What is the difference between the Moving Average model and the Autoregressive model?

Apart from sharing a lot of similarities, the two types of models also have several key differences. One such distinction between them comes in the form of determining the maximum amounts of lags we are willing to include in our model. While with the Autoregressive model we relied on the Partial Autocorrelation Function, a.k.a the PACF, with Moving Averages we rely on the Autocorrelation Function or the ACF for short.
The reason is that MA models aren’t based on past period returns. Therefore, determining which lagged values have a significant direct effect on the present-day ones is not relevant.
Anyways, the total accumulated effects accommodate for these unexpected shocks. Hence, the ACF plot provides us with information on how many lags our model should use.

That rounds up our overview of what the Moving Average model is. We hope this article inspires you to use this knowledge in your practice.

Originally published at https://365datascience.com

--

--

365 Data Science
365 Data Science

Become an in-demand #DataScience professional TODAY with the 365 Data Science Program -> https://365datascience.com