Skip to article frontmatterSkip to article content
Site not loading correctly?

This may be due to an incorrect BASE_URL configuration. See the MyST Documentation for reference.

6.4 ARMA Models (Under Construction)

In this section, we will combine AR and MA models to create autoregressive moving average (ARMA) models. A model is defined as ARMA(p,qp, q) if it is stationary and can be expressed as

xt=ϕ1xt−1+…+ϕpxt−p+wt+θ1wt−1+…+θqwt−q.x_t = \phi_1 x_{t-1} + \ldots + \phi_p x_{t-p} + w_t + \theta_1 w_{t-1} + \ldots + \theta_q w_{t-q}.

If E[xt]≠0\mathbb{E}[x_t]\neq 0, we instead define the model as

xt=α+ϕ1xt−1+…+ϕpxt−p+wt+θ1wt−1+…+θqwt−q,x_t = \alpha +\phi_1 x_{t-1} + \ldots + \phi_p x_{t-p} + w_t + \theta_1 w_{t-1} + \ldots + \theta_q w_{t-q},

with α=μ(1−ϕ1−…−ϕp)\alpha = \mu(1-\phi_1-\ldots-\phi_p). In general, we will assume that the mean has been subtracted from our time series so that μ=α=0\mu=\alpha=0.

In the process of developing ARMA models we will build tools that allow us to better understand the autocorrelation of various processes and how to apply this knowledge to practical data science applications.

Operator Notation and Parameter Redundancy

In keeping with the operators derived in sections 6.2 and 6.3, an ARMA(p,qp, q) model may be expressed in operator form as

ϕ(B)xt=θ(B)wt\phi(\mathbb{B})x_t = \theta(\mathbb{B})w_t

Eq. (3) presents a potential problem inasmuch as we can multiply both sides by the same term and still maintain a valid model, for example

η(B)ϕ(B)xt=η(B)θ(B)wt\eta(\mathbb{B})\phi(\mathbb{B})x_t = \eta(\mathbb{B})\theta(\mathbb{B})w_t

To give a concrete example, take the white noise process xt=wtx_t = w_t, and multiply it by some η(B)\eta(\mathbb{B}), say (1−0.5B)(1-0.5\mathbb{B}):

(1−0.5B)xt=(1−0.5B)wt,(1-0.5B)x_t = (1-0.5B)w_t,

or

xt=0.5xt−1−0.5wt−1+wt,x_t = 0.5x_{t-1} - 0.5w_{t-1} + w_t,

which is now an ARMA(1,11,1) model, despite only describing white noise. You might be tempted to rely on the statistical significance of the fitted ϕ\phi and θ\theta values to identify parameter redundancy. The following code helps demonstrate why we cannot use this tactic. Note that it is particularly strongly recommended that you run this code yourself to appreciate parameter redundancy.

import numpy as np
import matplotlib.pyplot as plt
from statsmodels.tsa.arima.model import ARIMA

#%%
# initialize empty lists
phi_estimates = []
theta_estimates = []
phi_significance = []
theta_significance = []
# create 100 white noise simulations and fit ARMA(1,1) model
for idx in range(100):
    white_noise = np.random.normal(size=1000)
    arma_1_1 = ARIMA(white_noise, order=(1,0,1)).fit()
    phi_estimates.append(arma_1_1.params[1]) # estimated phi
    theta_estimates.append(arma_1_1.params[2]) # estimated theta
    phi_significance.append(arma_1_1.pvalues[1]) # p-value of estimated phi
    theta_significance.append(arma_1_1.pvalues[2]) # p-value of estimated theta

#%%
# plot phi and theta values
fig, ax = plt.subplots()
ax.scatter(phi_estimates, theta_estimates, c=theta_significance, cmap='viridis')
ax.set_xlabel('ϕ Estimates', fontsize=18)
ax.set_ylabel('θ Estimates', fontsize=18)
ax.set_title('Scatter Plot of ϕ vs θ Estimates', fontsize=20)

#%%
# plot histogram of p-values
fig, ax = plt.subplots()
ax.hist(theta_significance, bins=50, alpha=0.7, label='θ Estimates')
ax.hist(phi_significance, bins=50, alpha=0.7, label='ϕ Estimates')
ax.set_xlabel('Parameter Significance', fontsize=18)
ax.set_ylabel('Frequency', fontsize=18)
ax.set_title('Histogram of ϕ and θ p-values', fontsize=20)
ax.legend()

In the above code, you should see that in almost all cases θ≈−ϕ\theta\approx -\phi, with values in (−1,1)(-1,1) (by default, statsmodels will attempt to enforce both stationarity and invertibility). You should also see that the majority of all estimates were statistically significant.

ARMA to AR(∞\infty) and MA(∞\infty)

AR(∞\infty) and MA(∞\infty) Terminology

Before deriving them, we first define the terminology for AR(∞\infty) and MA(∞\infty) representations. An MA(∞\infty) representation is traditionally denoted using the variable ψ\psi as

xt=∑j=0∞ψj wt−j=∑j=0∞ψjBj wt=ψ(B) wt\begin{split} x_t &= \sum_{j=0}^{\infty}\psi_j\, w_{t-j}\\ &= \sum_{j=0}^{\infty}\psi_j\mathbb{B}^j\,w_t\\ &= \psi(\mathbb{B})\,w_t \end{split}

where ψ0=△1\psi_0\stackrel{\triangle}{=}1.

Following the same logic, the AR(∞\infty) representation, often denoted by the variable π\pi (apologies for using π\pi as a variable instead of a constant), is given as

wt=∑j=0∞πj xt−j=∑j=0∞πjBj xt=π(B) xt\begin{split} w_t &= \sum_{j=0}^{\infty}\pi_j\, x_{t-j}\\ &= \sum_{j=0}^{\infty}\pi_j\mathbb{B}^j\,x_t\\ &= \pi(\mathbb{B})\,x_t \end{split}

where π0=△1\pi_0\stackrel{\triangle}{=}1.

Autocovariance and Autocorrelation of AR(pp) Models

Deriving Weights for Causal Process

We’ve seen that the autoregressive operator ϕ(B)\phi(\mathbb{B}) is extremely useful for determining stationarity. In this section, we will explore another useful application of ϕ(B)\phi(\mathbb{B}), namely converting a finite AR model into a MA(∞\infty) consisting of an infinite series of noise (or shock) terms. This in turn will help us understand the autocovariance of AR processes and derive confidence intervals for predictions.

We’ve already seen one example of converting to an infinite series of noise for AR(1) models

xt=(1+ϕB+ϕ2B2+ϕ3B3+…) wt=wt+ϕwt−1+ϕ2wt−2+ϕ3wt−3+…\begin{split} x_t&=(1 + \phi \mathbb{B} + \phi^2 \mathbb{B}^2 + \phi^3 \mathbb{B}^3 + \ldots)\,w_t\\ &= w_t + \phi w_{t-1} + \phi^2 w_{t-2} + \phi^3 w_{t-3} + \ldots \end{split}

How might we go about finding weights, call them ψj\psi_j’s with associated operator ψ(B)\psi(\mathbb{B}), for higher order AR(pp) processes? In other words, we want to find ψ\psi weights to satisfy the equation

xt=ψ(B) wtx_t = \psi(\mathbb{B})\,w_t

where we have defined ψ0=△1\psi_0\stackrel{\triangle}{=}1.Given that an AR model is defined as

wt=ϕ(B) xt,w_t = \phi(\mathbb{B})\,x_t,

we may combine Eqs. (10) and (11) to arrive at

wt=ϕ(B)xt=ϕ(B)ψ(B)wt=(1−ϕ1B−ϕ2B2−…−ϕpBp)(1+ψ1B+ψ2B2+…)=1+(ψ1−ϕ1)B+(ψ2−ϕ2−ψ1ϕ1)B2+…\begin{split} w_t &=\phi(\mathbb{B})x_t\\ &=\phi(\mathbb{B})\psi(\mathbb{B})w_t\\ &=(1 - \phi_1 \mathbb{B}-\phi_2 \mathbb{B}^2-\ldots-\phi_p \mathbb{B}^p)(1 + \psi_1 \mathbb{B} + \psi_2 \mathbb{B}^2 + \ldots)\\ &= 1 + (\psi_1-\phi_1)\mathbb{B} + (\psi_2 -\phi_2 -\psi_1\phi_1) \mathbb{B}^2 +\ldots \end{split}

Given that the left-hand side of Eq. (12) does not have any backshifted terms, we conclude that the coefficients of each backshift operator must be zero, i.e.

ψ0=1ψ1−ϕ1=0ψ1=ϕ1ψ2−ϕ2−ψ1ϕ1=0ψ2−ϕ2−ϕ12=0substituting ψ1=ϕ1ψ2=ϕ2+ϕ12⋮\begin{split} \psi_0&=1\\ \psi_1-\phi_1&=0\\ \psi_1 &= \phi_1\\ \psi_2 -\phi_2 -\psi_1\phi_1 &= 0\\ \psi_2 -\phi_2 -\phi_1^2 &= 0 \qquad \text{substituting }\psi_1 = \phi_1\\ \psi_2 &=\phi_2 +\phi_1^2\\ \vdots \end{split}

Fortunately, statsmodels performs the operations in Eq. (13) for us using the property impulse_response[4]. Continuing with the example from above, add the following line to the code:

print(f"psi weights 0-9: {ar2.impulse_response(10)}")

Do the results agree with Eq. (13) applied in the problem above?

Where do MA Processes Arise? Part 2

The MA(∞\infty) representation—referred to as the impulse response or impulse response function in disciplines such as signal processing—allows us to immediately determine how long a noise (or “impulse”) continues to generate observations outside of the system’s normal behavior. In the case of an AR(1) model who’s MA(∞\infty) is simply

∑j=0∞ϕjwt−j,\sum_{j=0}^{\infty}\phi^j w_{t-j},

it is straightforward in both the AR(1) and MA(∞\infty) representations to determine that for, say, ϕ=±0.75\phi=\pm0.75, the influence of an anomalous wtw_t will decay to roughly 10%10\% of its initial value after 8 timesteps, and roughly 1%1\% after 16. For AR(pp) processes higher pp values, extracting this information directly from the AR representation becomes far more challenging. Representing the process in its MA(∞\infty) form allows to quickly determine how a shock will decay by examining the ψ\psi weights. Moreover, for p≥2p\geq2, there is no guarantee that the ψ\psi weights will decay monotonically. An AR(pp) process with complex roots will exhibit correlations (and hence ψ\psi weights) that decay both exponentially and sinusoidally. The sinusoidal nature will result in ψ\psi weights that appear to reawaken at regular intervals and change the direction of their influence between positive and negative. Analyzing this decay of the ψ\psi weights allows us to avoid being surprised when we thought a shock had completely died off.

ψ\psi Weight Representation

Brockwell & Davis (1991) chapter 3.3 provides three broad methods to calculate the theoretical autocovariance and autocorrelation of AR models (and ARMA models in general). We will focus on the first here.

The first method relies on representing the model in the form of Eq. (10). γ(h)\gamma(h) is then calculated in the same fashion as Eq. (5)

γ(h)=Cov(xt+h,xt)=E[xt+hxt]=E[(∑j=0∞ψjwt+h−j)(∑k=0∞ψkwt−k)]=σw2∑i=0∞ψi ψi+h\begin{split} \gamma(h) &= \text{Cov}(x_{t+h}, x_t)\\ &=\mathbb{E}[x_{t+h}x_t]\\ &=\mathbb{E}\Big[\Big(\sum_{j=0}^{\infty}\psi_j w_{t+h-j}\Big)\Big(\sum_{k=0}^{\infty} \psi_k w_{t-k}\Big)\Big]\\ &= \sigma_w^2 \sum_{i=0}^{\infty} \psi_i\,\psi_{i+h} \end{split}

where we have used the fact that the noise is iid resulting in zero covariance for different noise terms. Unfortunately, AR(pp) models with p≥2p\geq2 do not have the same convenient geometric series representation seen with an AR(1) model. Nevertheless, Eq. (15) provides an elegant method for calculating the autocovariance, and hence the autocorrelation, of any stationary AR process—or, as we shall see, any stationary ARMA process. The fact that the ψ\psi weights decay exponentially results in it being possible to truncate Eq. (15) after say, thirty terms, with relatively little loss in accuracy.

Recursion Relations

The second and third methods in Brockwell & Davis (1991) rely on using recursion relations relating higher hh values to lower ones. We will not go into great depth regarding this method, but it is instructive to see how it might be applied to an AR(2) model. Let us begin with the AR(2) process xt=ϕ1xt−1+ϕ2xt−2+wtx_t = \phi_1 x_{t-1} + \phi_2 x_{t-2} + w_t. We can multiply through by xt−hx_{t-h} and take the expectation:

xtxt−h=ϕ1xt−1xt−h+ϕ2xt−2xt−h+wtxt−hE[xtxt−h]=E[ϕ1xt−1xt−h]+E[ϕ2xt−2xt−h]+E[wtxt−h]E[xtxt−h]=ϕ1E[xt−1xt−h]+ϕ2E[xt−2xt−h]+E[wtxt−h]γ(h)=ϕ1γ(h−1)+ϕ2γ(h−2)+E[wtxt−h].\begin{split} x_t x_{t-h} &= \phi_1 x_{t-1}x_{t-h} + \phi_2 x_{t-2}x_{t-h} + w_t x_{t-h}\\ \mathbb{E}[x_t x_{t-h}] &= \mathbb{E}[\phi_1 x_{t-1}x_{t-h}] + \mathbb{E}[\phi_2 x_{t-2}x_{t-h}] + \mathbb{E}[w_t x_{t-h}]\\ \mathbb{E}[x_t x_{t-h}] &= \phi_1\mathbb{E}[ x_{t-1}x_{t-h}] + \phi_2\mathbb{E}[x_{t-2}x_{t-h}] + \mathbb{E}[w_t x_{t-h}]\\ \gamma(h) &= \phi_1\gamma(h-1) +\phi_2 \gamma(h-2) + \mathbb{E}[w_t x_{t-h}]. \end{split}

Provided that our AR(2) process is causal (stationary), we can rewrite the final term in Eq. (16) as

E[wtxt−h]=E[wt∑j=0∞ψjwt−h−j]=0.\mathbb{E}[w_t x_{t-h}] = \mathbb{E}\Big[w_t\sum_{j=0}^{\infty}\psi_j w_{t-h-j}\Big]=0.

Combining Eqs. (16) and (17) we arrive at the desired recursion relation

γ(h)=ϕ1γ(h−1)+ϕ2γ(h−2)\gamma(h) = \phi_1\gamma(h-1) +\phi_2 \gamma(h-2)

Without additional information, we cannot further simplify in Eq. (18). However, dividing through by γ(0)\gamma(0) generates a recursion relation for the autocorrelation

ρ(h)=ϕ1ρ(h−1)+ϕ2ρ(h−2).\rho(h) = \phi_1\rho(h-1) + \phi_2 \rho(h-2).

We know that ρ(0)=1\rho(0)=1, and we can evaluate ρ(1)\rho(1) using Eq. (18):

γ(1)=ϕ1γ(0)+ϕ2γ(−1)=ϕ1γ(0)+ϕ2γ(1)(1−ϕ2)γ(1)=ϕ1γ(0)γ(1)=ϕ11−ϕ2γ(0)ρ(1)=ϕ11−ϕ2\begin{split} \gamma(1) &= \phi_1 \gamma(0) + \phi_2 \gamma(-1)\\ &= \phi_1 \gamma(0) + \phi_2 \gamma(1)\\ (1-\phi_2)\gamma(1) &= \phi_1 \gamma(0)\\ \gamma(1) &= \frac{\phi_1}{1-\phi_2}\gamma(0)\\ \rho(1) &= \frac{\phi_1}{1-\phi_2}\\ \end{split}

Thus we can derive ρ(2)\rho(2) as

ρ(2)=ϕ121−ϕ2+ϕ2,\rho(2) = \frac{\phi_1^2}{1-\phi_2} + \phi_2,

and continue extending the recursion relation to higher values of hh.

Footnotes
  1. The term “impulse response” comes from signal processing and denotes that fact that ψ(B)\psi(\mathbb{B}) dictates how noise, or an “impulse,” decays with time. We will elaborate on this in the next subsection.

References
  1. Brockwell, P. J., & Davis, R. A. (1991). Time Series: Theory and Methods. In Springer Series in Statistics. Springer New York. 10.1007/978-1-4419-0320-4