Type at least 2 letters. Enter opens the first result, Esc closes.

    Time Series and Forecasting · Lesson 5 · ARIMA and state-space models

    Autoregressive and moving-average models (AR, MA, ARMA)

    Intermediate 90 min 5 interactive figures 5 videos Colab notebook

    Before this lesson: lesson 02 (stationarity, white noise, ACF, PACF, the AR(1) process) and lesson 03 (forecasts and residuals). From other tracks: eigenvalues (linear-algebra lesson 05), least squares (linear-algebra lesson 12), Toeplitz matrices (linear-algebra lesson 19) and maximum likelihood (the probability-and-statistics track). Time: about 90 minutes, plus the notebook.


    Why this matters #

    • ARIMA is built from these parts. Lesson 06 adds differencing and seasonality to ARMA and gives forecast intervals. Almost every forecasting paper uses ARIMA as a benchmark.
    • Lag features. A regression on yt−1,…,yt−py_{t-1}, \dots, y_{t-p} is an AR(pp) model. Gradient-boosted forecasters (lesson 08) use the same lags as input features.
    • Linear recurrences in deep learning. A state-space layer (S4, Mamba) is a linear recurrence xt=Axt−1+Butx_t = A x_{t-1} + B u_t. It is stable exactly when the eigenvalues of AA lie inside the unit circle, the same condition as for an AR model in companion form (deep-learning lesson 16).
    • Science and engineering. Speech codecs model each short frame of speech as an AR process (linear predictive coding). Climate scientists use an AR(1) process ("red noise") as the null model for climate variability. Yule (1927) invented the AR(2) model to explain the sunspot cycle.

    1. Predict first #

    2. The picture #

    Start with AR(1) from lesson 02: yt=ϕ yt−1+εty_t = \phi\, y_{t-1} + \varepsilon_t with white noise εt∼WN(0,σ2)\varepsilon_t \sim \mathrm{WN}(0, \sigma^2). Unroll it: yt=εt+ϕεt−1+ϕ2εt−2+…y_t = \varepsilon_t + \phi\varepsilon_{t-1} + \phi^2\varepsilon_{t-2} + \dots. A shock that happened jj steps ago still has weight ϕj\phi^j. If ∣ϕ∣<1|\phi| < 1 the weights shrink and the series is stationary; its ACF is ρ(k)=ϕk\rho(k) = \phi^k. If ∣ϕ∣≥1|\phi| \ge 1 old shocks never fade.

    AR(2): two lags of feedback. yt=ϕ1yt−1+ϕ2yt−2+εty_t = \phi_1 y_{t-1} + \phi_2 y_{t-2} + \varepsilon_t. Now the pair (ϕ1,ϕ2)(\phi_1, \phi_2) decides everything. In the figure, each point of the plane is one AR(2) model.

    Interactive figure: loading…

    Drag the orange point (ϕ1,ϕ2)(\phi_1, \phi_2), or pick an example. Inside the aqua triangle the model is stationary. Below the dashed parabola ϕ12+4ϕ2=0\phi_1^2 + 4\phi_2 = 0 the roots are complex and the path (blue) oscillates with a period shown in the readout. Notice: the ACF (blue bars) of an AR(2) decays, the PACF (violet bars) is zero after lag 2, and outside the triangle the path explodes. Each path uses the same random shocks.

    Three regions matter:

    • Inside the triangle, above the parabola: two real roots. The ACF decays like a mix of two geometric sequences. The path wanders smoothly (ϕ1>0\phi_1 > 0) or flips sign (ϕ1<0\phi_1 < 0).
    • Inside the triangle, below the parabola: complex roots. The ACF is a damped cosine. The path shows a quasi-cycle: it oscillates with a typical period, but the amplitude and phase change at random. This is the sunspot picture.
    • Outside the triangle: no stationary (causal) solution. Shocks are amplified and the path explodes, even though each coefficient may be smaller than 1.

    Roots and eigenvalues. The stationarity rule has two equivalent forms. Write the AR polynomial ϕ(z)=1−ϕ1z−ϕ2z2\phi(z) = 1 - \phi_1 z - \phi_2 z^2. The rule "all roots of ϕ(z)\phi(z) lie outside the unit circle" is the same as "all eigenvalues of the companion matrix (ϕ1ϕ210)\begin{pmatrix} \phi_1 & \phi_2 \\ 1 & 0 \end{pmatrix} lie inside the unit circle", because the eigenvalues are exactly the reciprocals 1/z1/z of the roots. Section 3 proves it. The next figure lets you place the roots yourself.

    Interactive figure: loading…

    Drag the orange root z1z_1 of ϕ(z)\phi(z) in the complex plane. In "complex pair" mode its conjugate follows; in "two real roots" mode drag both roots along the real axis. The aqua points are the companion eigenvalues λ=1/z\lambda = 1/z. Notice: when a root crosses the unit circle into the inside, its eigenvalue leaves the circle and the path explodes. The closer the roots are to the circle, the slower the ACF decays.

    MA(1): a shock that lives for two steps. yt=εt+θεt−1y_t = \varepsilon_t + \theta\varepsilon_{t-1}. The shock εt\varepsilon_t enters yty_t and yt+1y_{t+1} and then disappears. So yty_t and yt+2y_{t+2} share no shock, and ρ(2)=0\rho(2) = 0. The ACF of an MA(1) cuts off after lag 1. Its PACF, however, decays slowly (section 3 explains why).

    Interactive figure: loading…

    Move the slider θ\theta and watch the theoretical ACF (blue) and PACF (violet). Notice: the ACF is exactly zero after lag qq. In MA(1) mode the lower chart draws ρ(1)=θ/(1+θ2)\rho(1) = \theta/(1 + \theta^2): it never goes above 0.5. Press θ → 1/θ: the ACF does not change, but only the model with ∣θ∣<1|\theta| < 1 is invertible.

    Quick check

    In the triangle figure, the point (ϕ1,ϕ2)=(1.0,−0.5)(\phi_1, \phi_2) = (1.0, -0.5) lies inside the triangle and below the parabola. What does a sample path look like?

    3. Definitions and main results #

    The backshift operator #

    The backshift operator BB moves a series one step back: Byt=yt−1B y_t = y_{t-1}, and Bkyt=yt−kB^k y_t = y_{t-k}. Polynomials in BB act term by term: (1−0.5B) yt=yt−0.5 yt−1(1 - 0.5B)\,y_t = y_t - 0.5\,y_{t-1}. They multiply like ordinary polynomials: (1−aB)(1−bB)=1−(a+b)B+ab B2(1 - aB)(1 - bB) = 1 - (a + b)B + ab\,B^2. This turns a model into an algebra problem in one variable.

    AR(pp) #

    An autoregressive model of order pp, AR(pp), is

    yt=c+ϕ1yt−1+ϕ2yt−2+⋯+ϕpyt−p+εt,εt∼WN(0,σ2),y_t = c + \phi_1 y_{t-1} + \phi_2 y_{t-2} + \dots + \phi_p y_{t-p} + \varepsilon_t, \qquad \varepsilon_t \sim \mathrm{WN}(0, \sigma^2),

    or in short form ϕ(B) yt=c+εt\phi(B)\,y_t = c + \varepsilon_t with the AR polynomial ϕ(z)=1−ϕ1z−⋯−ϕpzp\phi(z) = 1 - \phi_1 z - \dots - \phi_p z^p. The shock εt\varepsilon_t is also called the innovation: it is the part of yty_t that the past cannot predict.

    Mean. If the process is stationary, E yt=μ\mathrm E\,y_t = \mu for every tt. Take expectations of both sides: μ=c+ϕ1μ+⋯+ϕpμ\mu = c + \phi_1\mu + \dots + \phi_p\mu. So

    μ=c1−ϕ1−⋯−ϕp=cϕ(1).\mu = \frac{c}{1 - \phi_1 - \dots - \phi_p} = \frac{c}{\phi(1)} .

    The constant cc is not the mean. With c=2c = 2 and ϕ1=0.8\phi_1 = 0.8, the mean is 2/0.2=102/0.2 = 10. Equivalently, yt−μ=ϕ1(yt−1−μ)+⋯+ϕp(yt−p−μ)+εty_t - \mu = \phi_1(y_{t-1} - \mu) + \dots + \phi_p(y_{t-p} - \mu) + \varepsilon_t.

    Companion form. Stack the last pp values into a state vector xt=(yt,yt−1,…,yt−p+1)⊤x_t = (y_t, y_{t-1}, \dots, y_{t-p+1})^\top. Then the AR(pp) becomes a first-order vector recursion

    xt=A xt−1+e1 (c+εt),A=(ϕ1ϕ2⋯ϕp−1ϕp10⋯0001⋯00⋮⋱⋮00⋯10),x_t = A\,x_{t-1} + e_1\,(c + \varepsilon_t), \qquad A = \begin{pmatrix} \phi_1 & \phi_2 & \cdots & \phi_{p-1} & \phi_p \\ 1 & 0 & \cdots & 0 & 0 \\ 0 & 1 & \cdots & 0 & 0 \\ \vdots & & \ddots & & \vdots \\ 0 & 0 & \cdots & 1 & 0 \end{pmatrix},

    with e1=(1,0,…,0)⊤e_1 = (1, 0, \dots, 0)^\top. The first row is the AR equation; the other rows only shift the old values down by one place. AA is the companion matrix of the AR model.

    Theorem (stationarity of AR(pp)). Assume ϕp≠0\phi_p \ne 0. The following are equivalent:

    1. all roots of ϕ(z)\phi(z) lie outside the unit circle, ∣z∣>1|z| > 1;
    2. all eigenvalues of the companion matrix AA lie inside the unit circle, ∣λ∣<1|\lambda| < 1.

    Under these conditions the AR equation has exactly one stationary solution that depends only on present and past shocks (a causal solution): yt=μ+∑j≥0ψjεt−jy_t = \mu + \sum_{j \ge 0} \psi_j \varepsilon_{t-j} with ψj=(Aj)11\psi_j = (A^j)_{11}, and ∑j∣ψj∣<∞\sum_j |\psi_j| < \infty. If some eigenvalue has ∣λ∣≥1|\lambda| \ge 1, no causal stationary solution exists.

    Proof of 1 ⇔ 2.

    1. The characteristic polynomial of the companion matrix is det⁡(λI−A)=λp−ϕ1λp−1−⋯−ϕp−1λ−ϕp\det(\lambda I - A) = \lambda^p - \phi_1\lambda^{p-1} - \dots - \phi_{p-1}\lambda - \phi_p. (Expand the determinant along the first row; for p=2p = 2: det⁡(λ−ϕ1−ϕ2−1λ)=λ2−ϕ1λ−ϕ2\det\begin{pmatrix} \lambda - \phi_1 & -\phi_2 \\ -1 & \lambda \end{pmatrix} = \lambda^2 - \phi_1\lambda - \phi_2.)
    2. Multiply ϕ(1/λ)\phi(1/\lambda) by λp\lambda^p: λp ϕ(1/λ)=λp−ϕ1λp−1−⋯−ϕp\lambda^p\,\phi(1/\lambda) = \lambda^p - \phi_1\lambda^{p-1} - \dots - \phi_p. This is the same polynomial.
    3. ϕp≠0\phi_p \ne 0, so λ=0\lambda = 0 is not an eigenvalue. Therefore λ\lambda is an eigenvalue of AA exactly when z=1/λz = 1/\lambda is a root of ϕ(z)\phi(z).
    4. ∣z∣=1/∣λ∣|z| = 1/|\lambda|, so ∣z∣>1  ⟺  ∣λ∣<1|z| > 1 \iff |\lambda| < 1. ■\blacksquare
    Why the eigenvalues decide stationarity

    Eigenvalues inside the circle give a stationary solution.

    1. Unroll the companion recursion kk times: xt=Akxt−k+∑j=0k−1Aje1(c+εt−j)x_t = A^k x_{t-k} + \sum_{j=0}^{k-1} A^j e_1 (c + \varepsilon_{t-j}).
    2. If every eigenvalue has ∣λ∣<1|\lambda| < 1, then ∥Aj∥≤Crj\|A^j\| \le C r^j for some CC and some r<1r < 1 (by the Jordan form of linear-algebra lesson 05, the entries of AjA^j are sums of terms jmλjj^m\lambda^j, and jm∣λ∣j→0j^m|\lambda|^j \to 0 when ∣λ∣<1|\lambda| < 1). So Akxt−k→0A^k x_{t-k} \to 0, and the sum converges absolutely when k→∞k \to \infty.
    3. The limit xt=∑j≥0Aje1(c+εt−j)x_t = \sum_{j \ge 0} A^j e_1 (c + \varepsilon_{t-j}) uses only present and past shocks and has the same distribution for every tt: it is a causal stationary solution. Its first entry is yt=μ+∑jψjεt−jy_t = \mu + \sum_j \psi_j\varepsilon_{t-j} with ψj=(Aj)11\psi_j = (A^j)_{11}.

    An eigenvalue on or outside the circle rules it out.

    1. Let w⊤A=λw⊤w^\top A = \lambda w^\top with ∣λ∣≥1|\lambda| \ge 1 (a left eigenvector). For a companion matrix the first entry w1w_1 of a left eigenvector is never 0 (if w1=0w_1 = 0, the equations w⊤A=λw⊤w^\top A = \lambda w^\top force all other entries to 0, column by column).
    2. Put ut=w⊤xtu_t = w^\top x_t. Then ut=λut−1+w1(c+εt)u_t = \lambda u_{t-1} + w_1(c + \varepsilon_t).
    3. In a causal stationary solution, ut−1u_{t-1} depends only on shocks up to t−1t - 1, so it is uncorrelated with εt\varepsilon_t, and Var⁡(ut)=Var⁡(ut−1)=v\operatorname{Var}(u_t) = \operatorname{Var}(u_{t-1}) = v. Then v=∣λ∣2v+∣w1∣2σ2>∣λ∣2v≥vv = |\lambda|^2 v + |w_1|^2\sigma^2 > |\lambda|^2 v \ge v. This is impossible. ■\blacksquare

    AR(2): the triangle and the quasi-cycle #

    For AR(2) the companion eigenvalues solve λ2−ϕ1λ−ϕ2=0\lambda^2 - \phi_1\lambda - \phi_2 = 0, so λ1+λ2=ϕ1\lambda_1 + \lambda_2 = \phi_1 and λ1λ2=−ϕ2\lambda_1\lambda_2 = -\phi_2.

    Theorem (AR(2) stationarity triangle). An AR(2) is stationary if and only if

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

    Its roots are complex when ϕ12+4ϕ2<0\phi_1^2 + 4\phi_2 < 0 (below the parabola).

    Proof of the triangle

    Let g(λ)=λ2−ϕ1λ−ϕ2g(\lambda) = \lambda^2 - \phi_1\lambda - \phi_2. Note g(1)=1−ϕ1−ϕ2g(1) = 1 - \phi_1 - \phi_2 and g(−1)=1+ϕ1−ϕ2g(-1) = 1 + \phi_1 - \phi_2.

    Real roots (ϕ12+4ϕ2≥0\phi_1^2 + 4\phi_2 \ge 0).

    1. If both roots lie in (−1,1)(-1, 1), then g(1)>0g(1) > 0 and g(−1)>0g(-1) > 0 (an upward parabola is positive outside its roots), and ∣ϕ2∣=∣λ1λ2∣<1|\phi_2| = |\lambda_1\lambda_2| < 1.
    2. Conversely, let g(1)>0g(1) > 0, g(−1)>0g(-1) > 0 and ∣λ1λ2∣<1|\lambda_1\lambda_2| < 1. A root in (−∞,−1](-\infty, -1] and another in [1,∞)[1, \infty) would make g(1)≤0g(1) \le 0. So both roots are on the same side of 11 and on the same side of −1-1: both in (−1,1)(-1, 1), both >1> 1, or both <−1< -1. The last two cases give ∣λ1λ2∣>1|\lambda_1\lambda_2| > 1. So both roots lie in (−1,1)(-1, 1).

    Complex roots (ϕ12+4ϕ2<0\phi_1^2 + 4\phi_2 < 0). Then λ2=λˉ1\lambda_2 = \bar\lambda_1 and ∣λ1∣2=λ1λˉ1=−ϕ2|\lambda_1|^2 = \lambda_1\bar\lambda_1 = -\phi_2. So ∣λ∣<1  ⟺  ϕ2>−1|\lambda| < 1 \iff \phi_2 > -1. The other two conditions hold automatically: ϕ2<−ϕ12/4\phi_2 < -\phi_1^2/4 gives ϕ1+ϕ2<ϕ1−ϕ12/4=1−(1−ϕ1/2)2≤1\phi_1 + \phi_2 < \phi_1 - \phi_1^2/4 = 1 - (1 - \phi_1/2)^2 \le 1, and the same for −ϕ1-\phi_1. ■\blacksquare

    Quasi-cycle. With complex roots, write the eigenvalues as λ=re±iω\lambda = r e^{\pm i\omega}. From ∣λ∣2=−ϕ2|\lambda|^2 = -\phi_2 and λ1+λ2=2rcos⁡ω=ϕ1\lambda_1 + \lambda_2 = 2r\cos\omega = \phi_1:

    r=−ϕ2,cos⁡ω=ϕ12−ϕ2,period=2πω.r = \sqrt{-\phi_2}, \qquad \cos\omega = \frac{\phi_1}{2\sqrt{-\phi_2}}, \qquad \text{period} = \frac{2\pi}{\omega} .

    The ACF solves the recursion ρ(k)=ϕ1ρ(k−1)+ϕ2ρ(k−2)\rho(k) = \phi_1\rho(k-1) + \phi_2\rho(k-2), so it is a combination of λ1k\lambda_1^k and λ2k\lambda_2^k. With complex eigenvalues this combination is real and equals a rkcos⁡(kω+b)a\,r^k\cos(k\omega + b) for some constants a,ba, b: a cosine with period 2π/ω2\pi/\omega that decays by the factor rr per step. Random shocks keep restarting the oscillation, so the path never settles.

    Yule–Walker equations and the ACF of AR(pp) #

    Theorem (Yule–Walker). For a stationary AR(pp) with autocovariance γ(k)\gamma(k) and ACF ρ(k)=γ(k)/γ(0)\rho(k) = \gamma(k)/\gamma(0):

    ρ(k)=ϕ1ρ(k−1)+ϕ2ρ(k−2)+⋯+ϕpρ(k−p)(k≥1),σ2=γ(0)(1−ϕ1ρ(1)−⋯−ϕpρ(p)).\rho(k) = \phi_1\rho(k-1) + \phi_2\rho(k-2) + \dots + \phi_p\rho(k-p) \quad (k \ge 1), \qquad \sigma^2 = \gamma(0)\bigl(1 - \phi_1\rho(1) - \dots - \phi_p\rho(p)\bigr).

    Proof.

    1. Subtract the mean: y~t=yt−μ\tilde y_t = y_t - \mu satisfies y~t=ϕ1y~t−1+⋯+ϕpy~t−p+εt\tilde y_t = \phi_1\tilde y_{t-1} + \dots + \phi_p\tilde y_{t-p} + \varepsilon_t.
    2. Multiply both sides by y~t−k\tilde y_{t-k} and take expectations. On the left: E[y~ty~t−k]=γ(k)\mathrm E[\tilde y_t\tilde y_{t-k}] = \gamma(k). On the right: ϕi γ(k−i)\phi_i\,\gamma(k - i) for each lag.
    3. The last term is E[εty~t−k]\mathrm E[\varepsilon_t\tilde y_{t-k}]. For k≥1k \ge 1 it is 0, because in the causal solution y~t−k\tilde y_{t-k} depends only on shocks up to t−kt - k. For k=0k = 0 it is E[εty~t]=σ2\mathrm E[\varepsilon_t\tilde y_t] = \sigma^2 (only the ψ0εt\psi_0\varepsilon_t term of y~t\tilde y_t contributes).
    4. So γ(k)=∑iϕiγ(k−i)\gamma(k) = \sum_i\phi_i\gamma(k - i) for k≥1k \ge 1 and γ(0)=∑iϕiγ(i)+σ2\gamma(0) = \sum_i\phi_i\gamma(i) + \sigma^2. Divide by γ(0)\gamma(0) and use γ(−i)=γ(i)\gamma(-i) = \gamma(i). ■\blacksquare

    The equations for k=1,…,pk = 1, \dots, p form a linear system with a symmetric Toeplitz matrix (constant along each diagonal, see linear-algebra lesson 19):

    (1ρ(1)⋯ρ(p−1)ρ(1)1⋯ρ(p−2)⋮⋱⋮ρ(p−1)ρ(p−2)⋯1)⏟Rp(ϕ1ϕ2⋮ϕp)=(ρ(1)ρ(2)⋮ρ(p)).\underbrace{\begin{pmatrix} 1 & \rho(1) & \cdots & \rho(p-1) \\ \rho(1) & 1 & \cdots & \rho(p-2) \\ \vdots & & \ddots & \vdots \\ \rho(p-1) & \rho(p-2) & \cdots & 1 \end{pmatrix}}_{R_p} \begin{pmatrix}\phi_1 \\ \phi_2 \\ \vdots \\ \phi_p\end{pmatrix} = \begin{pmatrix}\rho(1) \\ \rho(2) \\ \vdots \\ \rho(p)\end{pmatrix}.

    Two uses. Forward: given ϕ\phi, solve for ρ(1),…,ρ(p)\rho(1), \dots, \rho(p) and then run the recursion to get the whole ACF. Backward (estimation): replace ρ(k)\rho(k) by the sample ACF ρ^(k)\hat\rho(k) and solve for ϕ^\hat\phi. This is the Yule–Walker estimator. With the sample ACF that divides by nn (lesson 02), RpR_p is positive definite and the fitted model is always stationary.

    The ACF of an AR(pp) decays. For k>pk > p the recursion has no forcing term, so ρ(k)\rho(k) is a combination of λik\lambda_i^k over the companion eigenvalues. All ∣λi∣<1|\lambda_i| < 1, so ρ(k)\rho(k) decays geometrically: like ϕk\phi^k, like a sum of such terms, or like a damped cosine. It never cuts off.

    The PACF of an AR(pp) cuts off after lag pp. Recall from lesson 02 that the PACF value ϕkk\phi_{kk} is the last coefficient of the best linear predictor of yty_t from yt−1,…,yt−ky_{t-1}, \dots, y_{t-k}. For k≥pk \ge p, the best predictor is the AR equation itself, because the remaining error εt\varepsilon_t is uncorrelated with all past values. Its coefficient vector is (ϕ1,…,ϕp,0,…,0)(\phi_1, \dots, \phi_p, 0, \dots, 0). So ϕpp=ϕp\phi_{pp} = \phi_p and ϕkk=0\phi_{kk} = 0 for every k>pk > p.

    Quick check

    A stationary AR(2) has ϕ1=0.5\phi_1 = 0.5 and ϕ2=0.2\phi_2 = 0.2. What is ρ(1)\rho(1)?

    MA(qq) #

    A moving-average model of order qq, MA(qq), is

    yt=c+εt+θ1εt−1+⋯+θqεt−q,oryt=c+θ(B) εt,y_t = c + \varepsilon_t + \theta_1\varepsilon_{t-1} + \dots + \theta_q\varepsilon_{t-q}, \qquad \text{or} \qquad y_t = c + \theta(B)\,\varepsilon_t,

    with the MA polynomial θ(z)=1+θ1z+⋯+θqzq\theta(z) = 1 + \theta_1 z + \dots + \theta_q z^q. It is a weighted sum of the last q+1q + 1 shocks; it is not a moving average of the data (that is a smoother, lesson 01).

    An MA(qq) is always stationary. It is a finite sum of white noise terms, so its mean cc and its autocovariances do not depend on tt. With θ0=1\theta_0 = 1:

    γ(0)=σ2 (1+θ12+⋯+θq2),γ(k)=σ2∑j=0q−kθjθj+k (1≤k≤q),γ(k)=0 (k>q).\gamma(0) = \sigma^2\,(1 + \theta_1^2 + \dots + \theta_q^2), \qquad \gamma(k) = \sigma^2\sum_{j=0}^{q-k}\theta_j\theta_{j+k} \ (1 \le k \le q), \qquad \gamma(k) = 0 \ (k > q).

    Proof. Cov⁡(yt,yt+k)=∑i∑jθiθjCov⁡(εt−i,εt+k−j)\operatorname{Cov}(y_t, y_{t+k}) = \sum_{i}\sum_{j}\theta_i\theta_j\operatorname{Cov}(\varepsilon_{t-i}, \varepsilon_{t+k-j}). The covariance is σ2\sigma^2 when t−i=t+k−jt - i = t + k - j, that is j=i+kj = i + k, and 0 otherwise. If k>qk > q, no pair (i,i+k)(i, i + k) has both indices in {0,…,q}\{0, \dots, q\}. ■\blacksquare

    So the ACF of an MA(qq) cuts off after lag qq. For MA(1):

    ρ(1)=θ1+θ2,ρ(k)=0 (k≥2).\rho(1) = \frac{\theta}{1 + \theta^2}, \qquad \rho(k) = 0 \ (k \ge 2).

    Since (1−∣θ∣)2≥0(1 - |\theta|)^2 \ge 0 gives 1+θ2≥2∣θ∣1 + \theta^2 \ge 2|\theta|, we get ∣ρ(1)∣≤1/2|\rho(1)| \le 1/2, with equality only at θ=±1\theta = \pm 1. An MA(1) can never have a lag-1 autocorrelation above 0.5.

    Invertibility. Replace θ\theta by 1/θ1/\theta and σ2\sigma^2 by θ2σ2\theta^2\sigma^2: γ(0)=θ2σ2(1+1/θ2)=σ2(1+θ2)\gamma(0) = \theta^2\sigma^2(1 + 1/\theta^2) = \sigma^2(1 + \theta^2) and γ(1)=θ2σ2⋅(1/θ)=σ2θ\gamma(1) = \theta^2\sigma^2 \cdot (1/\theta) = \sigma^2\theta. Same autocovariances. With Gaussian shocks the two models give exactly the same distribution of the data, so no data set can tell them apart. We pick one by a rule:

    An MA (or ARMA) model is invertible if all roots of θ(z)\theta(z) lie outside the unit circle. For MA(1) this means ∣θ∣<1|\theta| < 1. Then the shocks can be recovered from past data. From εt=yt−θεt−1\varepsilon_t = y_t - \theta\varepsilon_{t-1} (take c=0c = 0) and repeated substitution:

    εt=yt−θyt−1+θ2yt−2−⋯=∑j≥0(−θ)j yt−j.\varepsilon_t = y_t - \theta y_{t-1} + \theta^2 y_{t-2} - \dots = \sum_{j \ge 0}(-\theta)^j\,y_{t-j}.

    The sum converges because ∣θ∣<1|\theta| < 1. So an invertible MA(1) is an AR(∞\infty): yt=θyt−1−θ2yt−2+θ3yt−3−⋯+εty_t = \theta y_{t-1} - \theta^2 y_{t-2} + \theta^3 y_{t-3} - \dots + \varepsilon_t. This has two consequences. First, residuals computed from data converge to the true shocks, which forecasting needs (lesson 06). Second, the best linear predictor uses all past lags, so the PACF of an MA(1) never cuts off: it decays like (−θ)k(-\theta)^k.

    Quick check

    Can an MA(1) process have lag-1 autocorrelation ρ(1)=0.7\rho(1) = 0.7?

    ARMA(p,qp, q) #

    An ARMA(p,qp, q) model combines both parts:

    ϕ(B) yt=c+θ(B) εt,yt=c+∑i=1pϕiyt−i+εt+∑j=1qθjεt−j.\phi(B)\,y_t = c + \theta(B)\,\varepsilon_t, \qquad y_t = c + \sum_{i=1}^p\phi_i y_{t-i} + \varepsilon_t + \sum_{j=1}^q\theta_j\varepsilon_{t-j}.
    • It is causal (stationary) if the roots of ϕ(z)\phi(z) lie outside the unit circle. Then yt=μ+∑j≥0ψjεt−jy_t = \mu + \sum_{j\ge0}\psi_j\varepsilon_{t-j}, the MA(∞\infty) form, with ψ(z)=θ(z)/ϕ(z)\psi(z) = \theta(z)/\phi(z). Comparing coefficients in ϕ(z)ψ(z)=θ(z)\phi(z)\psi(z) = \theta(z) gives the ψ\psi-weights by a recursion: ψ0=1\psi_0 = 1 and ψj=θj+∑i=1min⁡(j,p)ϕiψj−i\psi_j = \theta_j + \sum_{i=1}^{\min(j, p)}\phi_i\psi_{j-i}, with θj=0\theta_j = 0 for j>qj > q. For ARMA(1,1): ψj=ϕj−1(ϕ+θ)\psi_j = \phi^{j-1}(\phi + \theta) for j≥1j \ge 1.
    • It is invertible if the roots of θ(z)\theta(z) lie outside the unit circle. Then εt=π(B)(yt−μ)\varepsilon_t = \pi(B)(y_t - \mu) with π(z)=ϕ(z)/θ(z)\pi(z) = \phi(z)/\theta(z), the AR(∞\infty) form.
    • Parameter redundancy. If ϕ(z)\phi(z) and θ(z)\theta(z) share a root, it cancels. Example: yt=0.5yt−1+εt−0.5εt−1y_t = 0.5y_{t-1} + \varepsilon_t - 0.5\varepsilon_{t-1} is (1−0.5B)yt=(1−0.5B)εt(1 - 0.5B)y_t = (1 - 0.5B)\varepsilon_t, which is white noise. Fitting software can return such a pair with large, opposite coefficients; it is a sign that the model is too big.

    Both the ACF and the PACF of an ARMA(p,qp, q) with p,q≥1p, q \ge 1 decay and do not cut off. For ARMA(1,1) the ACF is ρ(1)=(1+ϕθ)(ϕ+θ)1+2ϕθ+θ2\rho(1) = \dfrac{(1 + \phi\theta)(\phi + \theta)}{1 + 2\phi\theta + \theta^2} and ρ(k)=ϕ ρ(k−1)\rho(k) = \phi\,\rho(k-1) for k≥2k \ge 2.

    Wold's theorem: why ARMA is general

    Wold's decomposition theorem. Every zero-mean, covariance-stationary process can be written as yt=∑j≥0ψjεt−j+dty_t = \sum_{j\ge0}\psi_j\varepsilon_{t-j} + d_t, with ψ0=1\psi_0 = 1, ∑jψj2<∞\sum_j\psi_j^2 < \infty, εt\varepsilon_t the white-noise one-step prediction errors (the innovations), and dtd_t a deterministic part that the past predicts perfectly (for example a pure sinusoid). So every stationary process without a deterministic part is an MA(∞\infty). An ARMA model approximates the infinite sequence ψj\psi_j by a ratio of two short polynomials θ(z)/ϕ(z)\theta(z)/\phi(z). Few parameters can then describe a long memory pattern, which is why ARMA models work well in practice.

    Estimation #

    • AR(pp) by conditional least squares. For t=p+1,…,nt = p + 1, \dots, n, regress yty_t on 1,yt−1,…,yt−p1, y_{t-1}, \dots, y_{t-p}. This is ordinary least squares (linear-algebra lesson 12); "conditional" means we condition on the first pp values. Estimate σ2\sigma^2 by the mean squared residual. The Yule–Walker estimator gives almost the same answer on long series.
    • MA and ARMA by maximum likelihood. The residuals et=yt−c−∑iϕiyt−i−∑jθjet−je_t = y_t - c - \sum_i\phi_i y_{t-i} - \sum_j\theta_j e_{t-j} depend on θ\theta through the recursion, so the problem is not linear. Software maximises the exact Gaussian likelihood numerically. The likelihood is computed with the Kalman filter (lesson 07). A cheaper version minimises the conditional sum of squares ∑tet2\sum_t e_t^2 with et=0e_t = 0 before the start.

    Choosing the order #

    Model ACF PACF
    AR(pp) decays (geometric or damped cosine) cuts off after lag pp
    MA(qq) cuts off after lag qq decays
    ARMA(p,qp, q) decays (after lag qq) decays (after lag pp)

    A sample ACF or PACF value counts as "zero" if it lies inside the band ±1.96/n\pm 1.96/\sqrt n (lesson 02). The table is a good start on long, clean series. On short or noisy series the patterns are hard to see. Practice the reading in the next figure.

    Interactive figure: loading…

    Guess the model. The figure simulates one of AR(1), AR(2), MA(1), MA(2) or ARMA(1,1) and shows the path (blue), the sample ACF (blue bars) and the sample PACF (violet bars) with the grey band ±1.96/n\pm 1.96/\sqrt n. Pick your answer; the feedback explains the pattern. Then make nn small: with 60 points even the right answer is hard to see.

    Therefore, in practice, fit a small grid of candidate models and compare them with an information criterion. With L^\hat L the maximised likelihood and kk the number of estimated parameters (including cc and σ2\sigma^2):

    AIC=−2log⁡L^+2k,AICc=AIC+2k(k+1)n−k−1,BIC=−2log⁡L^+klog⁡n.\mathrm{AIC} = -2\log\hat L + 2k, \qquad \mathrm{AICc} = \mathrm{AIC} + \frac{2k(k+1)}{n - k - 1}, \qquad \mathrm{BIC} = -2\log\hat L + k\log n .

    The first term rewards fit; the second penalises the number of parameters, so the criterion trades fit against complexity. Smaller is better. AICc corrects AIC for small samples; BIC penalises more and picks smaller models. Compare criteria only between models fitted to the same data: the same time points and the same transformation and differencing.

    Then check the residuals. If the model is adequate, its residuals look like white noise: no spikes in their ACF. The Ljung–Box test summarises the first hh residual autocorrelations:

    Q=n(n+2)∑k=1hρ^e(k)2n−k.Q = n(n+2)\sum_{k=1}^{h}\frac{\hat\rho_e(k)^2}{n - k} .

    If the residuals are white noise, QQ approximately follows a χ2\chi^2 distribution with h−p−qh - p - q degrees of freedom. A small p-value says that correlation is left in the residuals.

    Quick check

    The sample PACF of a long series has clear spikes at lags 1 and 2 and nothing after. The sample ACF decays slowly like a damped wave. Which model is the best first guess?

    Answers to section 1. (1) It explodes. ϕ1+ϕ2=1.1>1\phi_1 + \phi_2 = 1.1 > 1 breaks the first triangle condition. Equivalently, g(λ)=λ2−0.5λ−0.6g(\lambda) = \lambda^2 - 0.5\lambda - 0.6 has roots λ≈1.06\lambda \approx 1.06 and −0.56-0.56; one eigenvalue is outside the unit circle. Small coefficients do not guarantee stability. (2) At most 0.50.5, reached at θ=1\theta = 1. (3) Yes. With complex roots an AR(2) produces a quasi-cycle with period 2π/ω2\pi/\omega. Section 4 fits it to the sunspots and finds a period of about 10.9 years.

    4. Worked example #

    (a) An AR(2) by hand. Take yt=yt−1−0.5 yt−2+εty_t = y_{t-1} - 0.5\,y_{t-2} + \varepsilon_t, so ϕ1=1\phi_1 = 1, ϕ2=−0.5\phi_2 = -0.5.

    1. Triangle: ϕ1+ϕ2=0.5<1\phi_1 + \phi_2 = 0.5 < 1, ϕ2−ϕ1=−1.5<1\phi_2 - \phi_1 = -1.5 < 1, ∣ϕ2∣=0.5<1|\phi_2| = 0.5 < 1. Stationary.
    2. Roots of ϕ(z)=1−z+0.5z2\phi(z) = 1 - z + 0.5z^2: z=1±1−21=1±iz = \dfrac{1 \pm \sqrt{1 - 2}}{1} = 1 \pm i, with modulus 2≈1.414>1\sqrt 2 \approx 1.414 > 1.
    3. Companion eigenvalues: λ2−λ+0.5=0\lambda^2 - \lambda + 0.5 = 0 gives λ=(1±i)/2\lambda = (1 \pm i)/2, with modulus 0.5≈0.707=1/2\sqrt{0.5} \approx 0.707 = 1/\sqrt 2. They are the reciprocals of the roots: 1/(1+i)=(1−i)/21/(1 + i) = (1 - i)/2.
    4. Period: cos⁡ω=ϕ1/(2−ϕ2)=1/(2⋅0.7071)=0.7071\cos\omega = \phi_1/(2\sqrt{-\phi_2}) = 1/(2 \cdot 0.7071) = 0.7071, so ω=π/4\omega = \pi/4 and the period is 2π/(π/4)=82\pi/(\pi/4) = 8 steps.
    5. ACF by Yule–Walker. ρ(1)=ϕ1/(1−ϕ2)=1/1.5=0.667\rho(1) = \phi_1/(1 - \phi_2) = 1/1.5 = 0.667. Then ρ(k)=ρ(k−1)−0.5ρ(k−2)\rho(k) = \rho(k-1) - 0.5\rho(k-2). For example ρ(2)=0.667−0.5⋅1=0.167\rho(2) = 0.667 - 0.5 \cdot 1 = 0.167 and ρ(4)=−0.167−0.5⋅0.167=−0.250\rho(4) = -0.167 - 0.5 \cdot 0.167 = -0.250. The table lists the first values.
    kk 0 1 2 3 4 5 6 7 8
    ρ(k)\rho(k) 1 0.667 0.167 −0.167 −0.250 −0.167 −0.042 0.042 0.063

    The sign pattern repeats every 8 lags and the size shrinks by the factor r=0.707r = 0.707 per lag: a damped cosine.

    1. PACF: ϕ11=ρ(1)=0.667\phi_{11} = \rho(1) = 0.667, ϕ22=ϕ2=−0.5\phi_{22} = \phi_2 = -0.5, and ϕkk=0\phi_{kk} = 0 for k≥3k \ge 3.
    2. Variance: γ(0)=σ2/(1−ϕ1ρ(1)−ϕ2ρ(2))=σ2/(1−0.667+0.083)=2.4 σ2\gamma(0) = \sigma^2/(1 - \phi_1\rho(1) - \phi_2\rho(2)) = \sigma^2/(1 - 0.667 + 0.083) = 2.4\,\sigma^2.

    (b) Two MA(1) models with the same ACF. θ=0.5\theta = 0.5 gives ρ(1)=0.5/1.25=0.4\rho(1) = 0.5/1.25 = 0.4. θ=2\theta = 2 gives ρ(1)=2/5=0.4\rho(1) = 2/5 = 0.4. With σ2=1\sigma^2 = 1 for the first and σ2=0.25\sigma^2 = 0.25 for the second, also γ(0)=1.25\gamma(0) = 1.25 and γ(1)=0.5\gamma(1) = 0.5 agree. Only θ=0.5\theta = 0.5 is invertible: the root of θ(z)=1+0.5z\theta(z) = 1 + 0.5z is z=−2z = -2, outside the unit circle; the root of 1+2z1 + 2z is z=−0.5z = -0.5, inside. The PACF of the invertible model is 0.4,−0.190,0.094,−0.047,…0.4, -0.190, 0.094, -0.047, \dots: it alternates in sign and decays, roughly by the factor −θ-\theta per lag.

    Quick check

    Model A is an MA(1) with θ=2\theta = 2 and σ2=1\sigma^2 = 1. Model B is an MA(1) with θ=0.5\theta = 0.5 and σ2=4\sigma^2 = 4. Which statement is true?

    (c) The sunspot cycle with AR(2). The data are the yearly sunspot numbers 1700–2008 (n=309n = 309, from the statsmodels data sets). Regress yty_t on (1,yt−1,yt−2)(1, y_{t-1}, y_{t-2}) for the 307 years 1702–2008:

    y^t=14.91+1.392 yt−1−0.690 yt−2,σ^=16.6.\hat y_t = 14.91 + 1.392\,y_{t-1} - 0.690\,y_{t-2}, \qquad \hat\sigma = 16.6 .
    1. Stationary? 1.392−0.690=0.702<11.392 - 0.690 = 0.702 < 1, −0.690−1.392<1-0.690 - 1.392 < 1, ∣−0.690∣<1|-0.690| < 1. Yes.
    2. Complex? ϕ12+4ϕ2=1.937−2.761=−0.824<0\phi_1^2 + 4\phi_2 = 1.937 - 2.761 = -0.824 < 0. Yes: a quasi-cycle.
    3. Eigenvalue modulus r=0.690=0.831r = \sqrt{0.690} = 0.831; root modulus 1/0.831=1.2041/0.831 = 1.204.
    4. cos⁡ω=1.392/(2⋅0.831)=0.838\cos\omega = 1.392/(2 \cdot 0.831) = 0.838, so ω=0.578\omega = 0.578 and the period is 2π/0.578=10.92\pi/0.578 = 10.9 years: close to the 11-year solar cycle.
    5. Mean: μ^=14.91/(1−1.392+0.690)=14.91/0.298=49.9\hat\mu = 14.91/(1 - 1.392 + 0.690) = 14.91/0.298 = 49.9; the sample mean is 49.8.

    Is AR(2) the best order? On the common years 1710–2008, the AIC is 2732.5 for AR(1), 2536.3 for AR(2), 2533.1 for AR(3) and smallest, 2485.8, for AR(9). The Ljung–Box test on the AR(2) residuals with h=10h = 10 gives Q=32.4Q = 32.4 with 8 degrees of freedom, p-value 0.0001: some correlation is left. AR(2) captures the cycle with two parameters; AR(9) captures more detail. (The real cycle is also asymmetric, rising faster than it falls, which no linear Gaussian model reproduces.)

    Interactive figure: loading…

    Choose the order pp. The blue line is the sunspot series, the orange line the one-step fitted values of an AR(pp) fitted by least squares. Below: the residual ACF (magenta bars) with the grey band, and the AIC for p=1,…,10p = 1, \dots, 10 on the same years 1710–2008. Notice: AR(1) leaves a strong wave in the residual ACF; AR(2) removes most of it and gives a period near 11 years; AIC prefers AR(9).

    5. In code #

    NumPy checks the hand computations. The notebook embeds the sunspot data; here we load it from statsmodels.

    import numpy as np
    import statsmodels.api as sm
    
    # (a) AR(2) with phi = (1, -0.5): roots, companion eigenvalues, period, ACF
    phi1, phi2 = 1.0, -0.5
    roots = np.roots([-phi2, -phi1, 1])            # phi(z) = 1 - phi1 z - phi2 z^2
    eig = np.linalg.eigvals([[phi1, phi2], [1, 0]])
    print(roots, np.abs(roots))                    # [1.+1.j 1.-1.j] [1.414 1.414]
    print(np.abs(eig), 2 * np.pi / np.abs(np.angle(eig[0])))   # [0.707 0.707] 8.0
    rho = [1.0, phi1 / (1 - phi2)]
    for k in range(2, 9):
        rho.append(phi1 * rho[-1] + phi2 * rho[-2])
    print(np.round(rho, 3))   # [ 1. 0.667 0.167 -0.167 -0.25 -0.167 -0.042 0.042 0.063]
    
    # (b) MA(1): theta and 1/theta give the same rho(1)
    for th in (0.5, 2.0):
        print(th, th / (1 + th**2))                # 0.4 for both
    
    # (c) AR(2) on the sunspots by least squares
    y = sm.datasets.sunspots.load_pandas().data["SUNACTIVITY"].to_numpy()
    X = np.column_stack([np.ones(len(y) - 2), y[1:-1], y[:-2]])
    b, *_ = np.linalg.lstsq(X, y[2:], rcond=None)
    print(np.round(b, 3))                          # [14.907  1.392 -0.69 ]
    w = np.arccos(b[1] / (2 * np.sqrt(-b[2])))
    print(round(2 * np.pi / w, 2))                 # 10.87
    

    statsmodels.tsa.ar_model.AutoReg(y, lags=2).fit().params returns the same three numbers.

    6. Where it shows up #

    • Classical forecasting. ARIMA and SARIMA (lesson 06) are ARMA models of a differenced series. Exact likelihood estimation uses the state-space form and the Kalman filter (lesson 07).
    • Machine learning. Lag features yt−1,…,yt−py_{t-1}, \dots, y_{t-p} in gradient boosting and in linear baselines such as DLinear are nonlinear or multi-output cousins of AR(pp) (lesson 08, lesson 09). AR(pp) residuals are a common anomaly score (lesson 11).
    • Deep learning. Linear recurrent layers and state-space models (S4, Mamba) keep the eigenvalues of their transition matrix inside the unit circle for the same reason as the AR stationarity theorem. Autoregressive generation in language models uses the same word: each output depends on the previous outputs.
    • Signal processing. Linear predictive coding fits an AR model of order about 10–16 to each speech frame by Yule–Walker (the Levinson–Durbin recursion solves the Toeplitz system in O(p2)O(p^2) steps). AR spectra give high-resolution spectral estimates.
    • Science. AR(1) "red noise" is the null model for climate variability; AR models describe sunspots, EEG rhythms and economic cycles; VAR models describe several linked series (macroeconomics, neuroscience).
    Vector autoregression (VAR) and Granger causality

    For KK series stacked in a vector yt∈RK\mathbf y_t \in \R^K, a VAR(pp) model is yt=c+Φ1yt−1+⋯+Φpyt−p+εt\mathbf y_t = \mathbf c + \Phi_1\mathbf y_{t-1} + \dots + \Phi_p\mathbf y_{t-p} + \boldsymbol\varepsilon_t with K×KK \times K matrices Φi\Phi_i and a noise covariance Σ\Sigma. Each equation is a regression on the lags of all series, so least squares works equation by equation. Stability: the Kp×KpKp \times Kp block companion matrix (first block row Φ1,…,Φp\Phi_1, \dots, \Phi_p, identity blocks below) must have all eigenvalues inside the unit circle. The number of parameters, K2pK^2p, grows fast; large VARs need regularisation.

    Series xx Granger-causes series yy if the past of xx improves the forecast of yy beyond the past of yy alone; in a VAR it means some lag coefficients from xx to yy are nonzero (an F-test). This is a statement about prediction, not about causation: a third series that drives both, or different reaction delays, can produce it without any causal link (see the causal-inference track).

    7. Common mistakes #

    • Checking each coefficient instead of the roots. ∣ϕi∣<1|\phi_i| < 1 for every ii does not give stationarity: (0.5,0.6)(0.5, 0.6) explodes. Use the roots, the companion eigenvalues or, for AR(2), the triangle.
    • Inside or outside? The roots of ϕ(z)\phi(z) must lie outside the unit circle; the companion eigenvalues must lie inside. They are reciprocals, so both statements say the same thing. Software such as statsmodels often reports arroots (outside) and some books plot inverse roots (inside); read the label.
    • Reading cc as the mean. In yt=c+ϕyt−1+εty_t = c + \phi y_{t-1} + \varepsilon_t the mean is c/(1−ϕ)c/(1 - \phi). Many packages report the mean μ\mu under the name "const" or "intercept"; check which one you get.
    • Mixing MA sign conventions. A fitted θ=−0.4\theta = -0.4 in statsmodels is θ=0.4\theta = 0.4 in Box–Jenkins notation.
    • Trusting the ACF/PACF table blindly. On short series the sample ACF is noisy, and about 1 lag in 20 crosses the ±1.96/n\pm 1.96/\sqrt n band by chance. Use the table to pick candidates, then compare them by AICc and residual checks.
    • Comparing AIC across different data. An AR(2) on years 1702–2008 and an AR(9) on 1709–2008 do not have comparable likelihoods. Fit all candidates on the same time points (and the same differencing).

    8. Check yourself #

    1. Is yt=1.2 yt−1−0.5 yt−2+εty_t = 1.2\,y_{t-1} - 0.5\,y_{t-2} + \varepsilon_t stationary? Are its roots real or complex? If complex, give the period.
      AnswerTriangle: 1.2−0.5=0.7<11.2 - 0.5 = 0.7 < 1, −0.5−1.2=−1.7<1-0.5 - 1.2 = -1.7 < 1, ∣−0.5∣<1|-0.5| < 1: stationary. ϕ12+4ϕ2=1.44−2=−0.56<0\phi_1^2 + 4\phi_2 = 1.44 - 2 = -0.56 < 0: complex. cos⁡ω=1.2/(20.5)=0.849\cos\omega = 1.2/(2\sqrt{0.5}) = 0.849, ω=0.556\omega = 0.556, period 2π/0.556≈11.32\pi/0.556 \approx 11.3 steps.
    2. A stationary AR(1) has c=3c = 3 and ϕ=0.7\phi = 0.7. What is its mean? What is its variance if σ2=1\sigma^2 = 1?
      Answerμ=3/(1−0.7)=10\mu = 3/(1 - 0.7) = 10. γ(0)=σ2/(1−ϕ2)=1/0.51≈1.96\gamma(0) = \sigma^2/(1 - \phi^2) = 1/0.51 \approx 1.96.
    3. Compute the ACF of the MA(2) yt=εt+0.5εt−1+0.2εt−2y_t = \varepsilon_t + 0.5\varepsilon_{t-1} + 0.2\varepsilon_{t-2}.
      Answerγ(0)/σ2=1+0.25+0.04=1.29\gamma(0)/\sigma^2 = 1 + 0.25 + 0.04 = 1.29; γ(1)/σ2=1⋅0.5+0.5⋅0.2=0.6\gamma(1)/\sigma^2 = 1 \cdot 0.5 + 0.5 \cdot 0.2 = 0.6; γ(2)/σ2=1⋅0.2=0.2\gamma(2)/\sigma^2 = 1 \cdot 0.2 = 0.2. So ρ(1)=0.6/1.29=0.465\rho(1) = 0.6/1.29 = 0.465, ρ(2)=0.2/1.29=0.155\rho(2) = 0.2/1.29 = 0.155, and ρ(k)=0\rho(k) = 0 for k≥3k \ge 3.
    4. Is the MA(1) yt=εt+1.25 εt−1y_t = \varepsilon_t + 1.25\,\varepsilon_{t-1} invertible? Give the invertible model with the same ACF.
      AnswerNo: the root of 1+1.25z1 + 1.25z is z=−0.8z = -0.8, inside the unit circle. Use θ=1/1.25=0.8\theta = 1/1.25 = 0.8 with the noise variance multiplied by 1.252=1.56251.25^2 = 1.5625. Both give ρ(1)=1.25/2.5625=0.8/1.64≈0.488\rho(1) = 1.25/2.5625 = 0.8/1.64 \approx 0.488.
    5. Write the companion matrix of the AR(3) yt=0.5yt−1+0.2yt−2−0.1yt−3+εty_t = 0.5y_{t-1} + 0.2y_{t-2} - 0.1y_{t-3} + \varepsilon_t. How do you decide stationarity with it?
      AnswerA=(0.50.2−0.1100010)A = \begin{pmatrix} 0.5 & 0.2 & -0.1 \\ 1 & 0 & 0 \\ 0 & 1 & 0 \end{pmatrix}. Compute its eigenvalues (for example with `np.linalg.eigvals`); the model is stationary if all have modulus below 1. Here the characteristic polynomial λ3−0.5λ2−0.2λ+0.1=(λ−0.5)(λ2−0.2)\lambda^3 - 0.5\lambda^2 - 0.2\lambda + 0.1 = (\lambda - 0.5)(\lambda^2 - 0.2) gives λ=0.5\lambda = 0.5 and λ=±0.447\lambda = \pm 0.447: all inside the unit circle, so the model is stationary.
    6. Why does the PACF of an AR(3) vanish at lag 5?
      AnswerThe PACF at lag 5 is the last coefficient of the best linear predictor of yty_t from five lags. For an AR(3) that predictor is the AR equation itself, with coefficients (ϕ1,ϕ2,ϕ3,0,0)(\phi_1, \phi_2, \phi_3, 0, 0), because the error εt\varepsilon_t is uncorrelated with every past value. So the fifth coefficient is 0.
    Recall cardsAnswer in your head first, then reveal. Add the cards to your review deck to see them again just before you would forget.
    1. When is an AR(pp) model stationary (and causal)?

    2. How are the roots of ϕ(z)\phi(z) and the companion eigenvalues related?

    3. When does an AR(2) have complex roots, and what does the path look like then?

    4. State the Yule–Walker equations of an AR(pp).

    5. What is ρ(1)\rho(1) of an MA(1), and what is its largest possible value?

    6. Which model has an ACF that cuts off after lag qq, and which has a PACF that cuts off after lag pp?

    7. What does invertibility mean for an MA(1), and why do we require it?

    8. What is the mean of a stationary AR(1) with c=2c = 2 and ϕ=0.8\phi = 0.8?

    9. What does AIC trade off?

    Open the review →

    9. Interview angle #

    • "How do you check that an AR model is stationary?" — Roots of ϕ(z)\phi(z) outside the unit circle, or companion eigenvalues inside. For AR(2), the triangle. Coefficients below 1 are not enough.
    • "How do you choose pp and qq?" — Look at the ACF/PACF for a first guess (cut-offs), fit a small grid, compare AICc on the same data, and check that the residuals are white noise (Ljung–Box). Finally, compare forecasts with a backtest (lesson 03).
    • "What is the difference between an MA model and a moving-average smoother?" — The MA model is a stochastic process built from past shocks; the smoother averages past observations.
    • "Why is an MA model not identifiable without invertibility?" — θ\theta and 1/θ1/\theta (with rescaled noise variance) give the same autocovariances and, for Gaussian data, the same likelihood.
    • "How does an AR model relate to a linear RNN?" — An AR(pp) in companion form is a linear RNN with a fixed transition matrix; stability is the same eigenvalue condition.

    10. Practice #

    The notebook for this lesson runs in Colab. It has five exercises, each with a check cell and a folded solution:

    1. simulate_arma(phi, theta, n, burn, rng): simulate an ARMA with burn-in and compare its sample ACF with the theoretical ACF from the ψ\psi-weights.
    2. is_stationary(phi): decide stationarity with the companion eigenvalues; test it on the corners of the AR(2) triangle.
    3. yule_walker(y, p): estimate an AR(pp) with scipy.linalg.solve_toeplitz and compare with least squares on a long AR(2) sample.
    4. fit_ar_ols(y, p) and AIC for p=1,…,10p = 1, \dots, 10 on the sunspots; the implied period of the AR(2).
    5. MA(1) invertibility: show that (θ,σ2)(\theta, \sigma^2) and (1/θ,θ2σ2)(1/\theta, \theta^2\sigma^2) give the same autocovariances, and recover the shocks with the invertible model.

    An optional cell fits the same models with statsmodels ARIMA(order=(p, 0, q)) if it is installed.

    11. Watch and read #

    The AR(p) equation and its intuition, as in section 3.
    Open on YouTube · the player loads from youtube-nocookie.com when you press play
    The MA(q) model as a sum of past shocks; compare with the cut-off ACF in the figure.
    Open on YouTube · the player loads from youtube-nocookie.com when you press play
    Derives why the ACF of an MA model cuts off.
    Open on YouTube · the player loads from youtube-nocookie.com when you press play
    How the AR and MA parts combine.
    Open on YouTube · the player loads from youtube-nocookie.com when you press play
    For the VAR block in section 6.
    Open on YouTube · the player loads from youtube-nocookie.com when you press play