Skip to content
LeetQuant
QR05 Time Series and Econometrics

QR05 · Time Series and Econometrics · Lesson 2 of 5

ARMA Models

AR(p), MA(q) and ARMA processes: stationarity and invertibility conditions, ACF and PACF signatures, Yule–Walker equations for AR(1) and AR(2), and forecasts with their error variance.

18 min

Objective

The time-series primer covered AR(1), MA(1) and the random walk. This lesson goes one level deeper, to the questions a researcher interview actually asks: when is an AR(2) stationary, why do we insist an MA be invertible, how do you identify the order from the ACF and PACF, how do you get parameters from autocorrelations (Yule–Walker), and how fast does forecast uncertainty grow.

The models

With white noise εt\varepsilon_t of variance σ2\sigma^2 and the lag operator LXt=Xt−1L X_t = X_{t-1}:

AR(p): ϕ(L)Xt=εt,MA(q): Xt=θ(L)εt,ARMA(p,q): ϕ(L)Xt=θ(L)εt,\text{AR}(p):\ \phi(L)X_t = \varepsilon_t, \qquad \text{MA}(q):\ X_t = \theta(L)\varepsilon_t, \qquad \text{ARMA}(p,q):\ \phi(L)X_t = \theta(L)\varepsilon_t,

where ϕ(z)=1−ϕ1z−⋯−ϕpzp\phi(z) = 1 - \phi_1 z - \dots - \phi_p z^p and θ(z)=1+θ1z+⋯+θqzq\theta(z) = 1 + \theta_1 z + \dots + \theta_q z^q. A non-zero mean μ\mu is handled by writing the model for Xt−μX_t - \mu.

Intuition: an AR process remembers its own past values, so a shock echoes forever with decaying strength. An MA process remembers the last qq shocks and then forgets them completely.

Stationarity and invertibility

Stationarity (AR part). An AR(pp) is stationary when every root of ϕ(z)=0\phi(z) = 0 lies outside the unit circle, equivalently when every root λ\lambda of λp−ϕ1λp−1−⋯−ϕp=0\lambda^p - \phi_1\lambda^{p-1} - \dots - \phi_p = 0 has ∣λ∣<1|\lambda| < 1. For AR(1) this is ∣ϕ∣<1|\phi| < 1. For AR(2) it reduces to the stationarity triangle:

ϕ1+ϕ2<1,ϕ2−ϕ1<1,∣ϕ2∣<1.\phi_1 + \phi_2 < 1, \qquad \phi_2 - \phi_1 < 1, \qquad |\phi_2| < 1 .

If ϕ12+4ϕ2<0\phi_1^2 + 4\phi_2 < 0 the roots are complex and the ACF is a damped oscillation (a pseudo-cycle). Example: ϕ1=1.2, ϕ2=−0.5\phi_1 = 1.2,\ \phi_2 = -0.5 has inverse roots 0.6±0.374i0.6 \pm 0.374i of modulus 0.5≈0.707\sqrt{0.5} \approx 0.707, so it is stationary and cycles.

Any finite MA is stationary. It is a finite sum of white noise.

Invertibility (MA part). An MA is invertible when the roots of θ(z)=0\theta(z) = 0 lie outside the unit circle; for MA(1), ∣θ∣<1|\theta| < 1. Why care? θ\theta and 1/θ1/\theta give the same autocorrelation function:

ρ1=θ1+θ2=1/θ1+1/θ2.\rho_1 = \frac{\theta}{1+\theta^2} = \frac{1/\theta}{1 + 1/\theta^2} .

With θ=0.5\theta = 0.5 and θ=2\theta = 2 both giving ρ1=0.4\rho_1 = 0.4, the data cannot tell them apart. Only the invertible one lets you write εt\varepsilon_t as a convergent sum of current and past XX's, εt=∑j≥0(−θ)jXt−j\varepsilon_t = \sum_{j \ge 0} (-\theta)^j X_{t-j}, so only it lets you recover shocks (and forecast) from observed data. Software therefore always reports the invertible root. A side fact worth knowing: an MA(1) can never have ∣ρ1∣>0.5|\rho_1| > 0.5.

ACF and PACF signatures

The partial autocorrelation at lag kk, ϕkk\phi_{kk}, is the last coefficient when you regress XtX_t on Xt−1,…,Xt−kX_{t-1}, \dots, X_{t-k}: the correlation with lag kk after removing what lags 1,…,k−11, \dots, k-1 explain.

ModelACFPACF
AR(pp)Decays (geometric or damped oscillation)Cuts off after lag pp
MA(qq)Cuts off after lag qqDecays
ARMA(p,qp,q)Decays after lag qqDecays after lag pp

Under white noise both sample functions have standard error about 1/n1/\sqrt n, so the usual bands are ±2/n\pm 2/\sqrt n. With 20 lags plotted, about one bar outside the band is expected by chance. For mixed models the table is only a starting point; in practice compare a few candidate orders by AIC or BIC and check that the residuals pass a Ljung–Box test for remaining autocorrelation.

Yule–Walker equations

Multiply the AR equation by Xt−kX_{t-k}, take expectations and divide by γ0=Var⁡(Xt)\gamma_0 = \operatorname{Var}(X_t). For AR(2):

ρk=ϕ1ρk−1+ϕ2ρk−2(k≥1),ρ0=1, ρ−1=ρ1.\rho_k = \phi_1\rho_{k-1} + \phi_2\rho_{k-2} \quad (k \ge 1), \qquad \rho_0 = 1,\ \rho_{-1} = \rho_1 .

At k=1k = 1: ρ1=ϕ1+ϕ2ρ1\rho_1 = \phi_1 + \phi_2\rho_1, so ρ1=ϕ11−ϕ2\rho_1 = \dfrac{\phi_1}{1 - \phi_2}. At k=2k = 2: ρ2=ϕ1ρ1+ϕ2\rho_2 = \phi_1\rho_1 + \phi_2. The k=0k = 0 equation gives the variance:

γ0=σ21−ϕ1ρ1−ϕ2ρ2.\gamma_0 = \frac{\sigma^2}{1 - \phi_1\rho_1 - \phi_2\rho_2} .

Run backwards, the same two equations estimate the parameters from sample autocorrelations:

ϕ^1=ρ^1(1−ρ^2)1−ρ^12,ϕ^2=ρ^2−ρ^121−ρ^12.\hat\phi_1 = \frac{\hat\rho_1(1 - \hat\rho_2)}{1 - \hat\rho_1^2}, \qquad \hat\phi_2 = \frac{\hat\rho_2 - \hat\rho_1^2}{1 - \hat\rho_1^2} .

For AR(1) everything collapses to ϕ^=ρ^1\hat\phi = \hat\rho_1 and ρk=ϕk\rho_k = \phi^k. Note ϕ^2\hat\phi_2 is exactly the lag-2 partial autocorrelation, which is why the PACF of an AR(2) is zero from lag 3.

Worked example

the ACF of an AR(2)

Xt=0.5Xt−1+0.3Xt−2+εtX_t = 0.5X_{t-1} + 0.3X_{t-2} + \varepsilon_t with σ2=1\sigma^2 = 1. Is it stationary? Find ρ1\rho_1, ρ2\rho_2, ρ3\rho_3, the variance, and the PACF at lags 2 and 3.

Show solution

Stationarity. ϕ1+ϕ2=0.8<1\phi_1 + \phi_2 = 0.8 < 1, ϕ2−ϕ1=−0.2<1\phi_2 - \phi_1 = -0.2 < 1, ∣ϕ2∣=0.3<1|\phi_2| = 0.3 < 1. Stationary. (The inverse roots solve λ2−0.5λ−0.3=0\lambda^2 - 0.5\lambda - 0.3 = 0: λ≈0.852\lambda \approx 0.852 and −0.352-0.352, both inside the unit circle. Real roots, so no oscillation.)

Autocorrelations.

  • ρ1=0.5/(1−0.3)=5/7≈0.714\rho_1 = 0.5 / (1 - 0.3) = 5/7 \approx 0.714.
  • ρ2=0.5×0.714+0.3=0.657\rho_2 = 0.5 \times 0.714 + 0.3 = 0.657.
  • ρ3=0.5×0.657+0.3×0.714=0.543\rho_3 = 0.5 \times 0.657 + 0.3 \times 0.714 = 0.543.

The ACF decays slowly, at a rate governed by the larger root 0.8520.852.

Variance. γ0=1/(1−0.5×0.714−0.3×0.657)=1/0.4457≈2.24\gamma_0 = 1 / (1 - 0.5 \times 0.714 - 0.3 \times 0.657) = 1 / 0.4457 \approx 2.24.

PACF. ϕ22=ϕ2=0.3\phi_{22} = \phi_2 = 0.3 (check: (ρ2−ρ12)/(1−ρ12)=(0.657−0.510)/0.490=0.3(\rho_2 - \rho_1^2)/(1 - \rho_1^2) = (0.657 - 0.510)/0.490 = 0.3), and ϕ33=0\phi_{33} = 0 because a third lag adds nothing once two are included.

Forecasting and forecast variance

Write the stationary process in its MA(∞\infty) form Xt−μ=∑j≥0ψjεt−jX_t - \mu = \sum_{j \ge 0} \psi_j \varepsilon_{t-j} with ψ0=1\psi_0 = 1. The optimal (minimum mean-squared error) hh-step forecast replaces future shocks by zero, so the forecast error is ∑j=0h−1ψjεT+h−j\sum_{j=0}^{h-1}\psi_j\varepsilon_{T+h-j} and

Var⁡(eT+h)=σ2∑j=0h−1ψj2.\operatorname{Var}(e_{T+h}) = \sigma^2 \sum_{j=0}^{h-1} \psi_j^2 .

For AR(1), ψj=ϕj\psi_j = \phi^j:

X^T+h=μ+ϕh(XT−μ),Var⁡(eT+h)=σ2 1−ϕ2h1−ϕ2.\hat X_{T+h} = \mu + \phi^h (X_T - \mu), \qquad \operatorname{Var}(e_{T+h}) = \sigma^2\,\frac{1 - \phi^{2h}}{1 - \phi^2} .

The forecast decays to the mean and the error variance rises to the unconditional variance σ2/(1−ϕ2)\sigma^2/(1-\phi^2). For an MA(qq) the forecast equals the mean after qq steps: an MA(1) forecast is μ+θε^T\mu + \theta\hat\varepsilon_T one step ahead and μ\mu from two steps on. Beyond a few half-lives, no ARMA model knows more than the unconditional mean.

These intervals assume known parameters. With estimated parameters they are too narrow, more so for persistent series, where small errors in ϕ\phi compound over the horizon.

Worked example

forecasting a mean-reverting spread

A spread follows Xt−2=0.8(Xt−1−2)+εtX_t - 2 = 0.8(X_{t-1} - 2) + \varepsilon_t with σ=1\sigma = 1. Today XT=5X_T = 5. Give the 1-, 2- and 5-step forecasts, their error variances, and a 95% interval at two steps.

Show solution

The deviation from the mean is 33 and shrinks by 0.80.8 each step.

hhForecast 2+3(0.8)h2 + 3(0.8)^hError variance (1−0.82h)/0.36(1 - 0.8^{2h})/0.36Error s.d.
14.401.001.00
23.921.641.28
52.982.481.57
∞\infty2.002.781.67

The two-step variance is 1+0.82=1.641 + 0.8^2 = 1.64, so the 95% interval is 3.92±1.96×1.28=3.92±2.513.92 \pm 1.96 \times 1.28 = 3.92 \pm 2.51, roughly [1.41,6.43][1.41, 6.43]. Notice the interval at two steps already contains the mean: the expected reversion is real but small relative to the noise, which is the usual situation for a trading signal.

Estimating an AR(2) by Yule–Walker

This simulates the AR(2) from the first example and recovers its coefficients from two sample autocorrelations, using only the standard library.

import random

def acf(x, k):
    n = len(x)
    m = sum(x) / n
    c0 = sum((v - m) ** 2 for v in x) / n
    ck = sum((x[t] - m) * (x[t - k] - m) for t in range(k, n)) / n
    return ck / c0

random.seed(1)
phi1, phi2, n = 0.5, 0.3, 20000
x = [0.0, 0.0]
for _ in range(n):
    x.append(phi1 * x[-1] + phi2 * x[-2] + random.gauss(0, 1))
x = x[500:]  # drop burn-in

r1, r2 = acf(x, 1), acf(x, 2)
phi2_hat = (r2 - r1**2) / (1 - r1**2)
phi1_hat = r1 * (1 - r2) / (1 - r1**2)
print(f"rho1={r1:.3f} rho2={r2:.3f}")
print(f"phi1_hat={phi1_hat:.3f} phi2_hat={phi2_hat:.3f}")

Output:

rho1=0.723 rho2=0.665
phi1_hat=0.506 phi2_hat=0.299

The sample autocorrelations are close to the theoretical 0.7140.714 and 0.6570.657. Yule–Walker is fine for pure AR models with plenty of data; for MA or mixed models, or short persistent samples, use maximum likelihood, because Yule–Walker estimates are biased towards zero in small samples.

Knowledge check

A series' sample ACF has significant spikes at lags 1 and 2 and nothing beyond; its PACF decays gradually. Which model is suggested?

Knowledge check

Is Xt=0.6Xt−1+0.5Xt−2+εtX_t = 0.6X_{t-1} + 0.5X_{t-2} + \varepsilon_t stationary?

Knowledge check

Which statement about Xt=εt+2εt−1X_t = \varepsilon_t + 2\varepsilon_{t-1} is correct?

Knowledge check

For an AR(1) with ϕ=0.9\phi = 0.9 and σ2=1\sigma^2 = 1, what is the variance of the two-step-ahead forecast error?

Key takeaways

  • AR(pp) is stationary when the roots of ϕ(z)\phi(z) lie outside the unit circle; for AR(2), ϕ1+ϕ2<1\phi_1 + \phi_2 < 1, ϕ2−ϕ1<1\phi_2 - \phi_1 < 1, ∣ϕ2∣<1|\phi_2| < 1. Complex roots give a damped cycle.
  • Finite MAs are always stationary; invertibility (∣θ∣<1|\theta| < 1 for MA(1)) picks the one of two observationally equivalent models that lets you recover shocks from data.
  • AR: PACF cuts off at pp. MA: ACF cuts off at qq. ARMA: both decay. Confirm with AIC/BIC and residual Ljung–Box tests.
  • Yule–Walker for AR(2): ρ1=ϕ1/(1−ϕ2)\rho_1 = \phi_1/(1-\phi_2), ρ2=ϕ1ρ1+ϕ2\rho_2 = \phi_1\rho_1 + \phi_2, γ0=σ2/(1−ϕ1ρ1−ϕ2ρ2)\gamma_0 = \sigma^2/(1 - \phi_1\rho_1 - \phi_2\rho_2).
  • hh-step forecast error variance is σ2∑j<hψj2\sigma^2\sum_{j<h}\psi_j^2; for AR(1), σ2(1−ϕ2h)/(1−ϕ2)\sigma^2(1-\phi^{2h})/(1-\phi^2), rising to the unconditional variance.

Practice problems

Finished reading?

Answer the 4 knowledge checks to complete this lesson (0 done).