R Matrix Laboratory

R Matrix Lab 2 — AR Recursions and Yule–Walker Equations

Convert AR models to companion form, compare polynomial roots with eigenvalues, propagate shocks, and recover coefficients from autocovariances.

Question

How do one scalar difference equation, one companion matrix, and one Toeplitz linear system describe the same AR process?

Consider

Xt=ϕ1Xt−1+⋯+ϕpXt−p+εt.X_t=\phi_1X_{t-1}+\cdots+\phi_pX_{t-p}+\varepsilon_t.

Define the state

st=(Xt,Xt−1,…,Xt−p+1)⊤.\mathbf s_t=(X_t,X_{t-1},\ldots,X_{t-p+1})^\top.

Then

st=Fst−1+Gεt,\mathbf s_t=F\mathbf s_{t-1}+G\varepsilon_t,

where

F=[ϕ1ϕ2⋯ϕp10⋯001⋱⋮⋮⋱0],G=(1,0,…,0)⊤.F= \begin{bmatrix} \phi_1&\phi_2&\cdots&\phi_p\\ 1&0&\cdots&0\\ 0&1&\ddots&\vdots\\ \vdots&&\ddots&0 \end{bmatrix}, \qquad G=(1,0,\ldots,0)^\top.

Example 1 — Roots, eigenvalues, and shock propagation

For

Xt=0.75Xt−1−0.125Xt−2+εt,X_t=0.75X_{t-1}-0.125X_{t-2}+\varepsilon_t,

the AR polynomial is

ϕ(z)=1−0.75z+0.125z2.\phi(z)=1-0.75z+0.125z^2.

Its roots must lie outside the unit circle. The companion eigenvalues are their reciprocals and must lie inside.

R

Compare AR roots, companion eigenvalues, and impulse responses

Idle

The first output checks admissibility. The second shows dynamics: FhGF^hG is the state response to one innovation, and its first component is ψh\psi_h in the MA(∞\infty) representation.

Example 2 — Yule–Walker as a Toeplitz solve

For a stationary AR(pp),

Γpϕ=γp,\Gamma_p\boldsymbol\phi=\boldsymbol\gamma_p,

with

Γp=Toeplitz⁡{γ(0),…,γ(p−1)},γp=(γ(1),…,γ(p))⊤.\Gamma_p=\operatorname{Toeplitz}\{\gamma(0),\ldots,\gamma(p-1)\}, \qquad \boldsymbol\gamma_p=(\gamma(1),\ldots,\gamma(p))^\top.

The innovation variance follows from the lag-zero equation:

σε2=γ(0)−ϕ⊤γp.\sigma_\varepsilon^2 =\gamma(0)-\boldsymbol\phi^\top\boldsymbol\gamma_p.
R

Recover AR coefficients from theoretical autocovariances

Idle

This cell deliberately starts from population autocovariances. In estimation, replacing them by sample autocovariances introduces sampling error; the linear algebra remains the same.

One model, four equivalent views

ViewObjectStability or identification check
difference equationϕ(B)Xt=εt\phi(B)X_t=\varepsilon_tcoefficients define recursion
polynomialϕ(z)\phi(z)roots outside unit circle
state equationst=Fst−1+Gεt\mathbf s_t=F\mathbf s_{t-1}+G\varepsilon_teigenvalues of FF inside unit circle
moment equationsΓpϕ=γp\Gamma_p\boldsymbol\phi=\boldsymbol\gamma_pΓp\Gamma_p invertible

The views are equivalent under the model, but each makes a different task easier.

Exercises

  1. Build the companion matrix for AR(3) coefficients (0.5,−0.2,0.1)(0.5,-0.2,0.1).
  2. Verify numerically that each companion eigenvalue is the reciprocal of one AR-polynomial root.
  3. Set ϕ=(1.2,−0.32)⊤\phi=(1.2,-0.32)^\top. Check roots and eigenvalues before simulating.
  4. For AR(1), reduce the matrix Yule–Walker equation to ϕ=γ(1)/γ(0)\phi=\gamma(1)/\gamma(0).
  5. Set ϕ=(0.9,0.09)⊤\phi=(0.9,0.09)^\top. Inspect the spectral radius and the decay of ψh\psi_h. Explain why “coefficients sum to less than one” is not the general AR(pp) stability test.
  6. Graduate extension: solve vec⁡(P)=(I−F⊗F)−1vec⁡(σ2GG⊤)\operatorname{vec}(P)=(I-F\otimes F)^{-1}\operatorname{vec}(\sigma^2GG^\top) and compare P11P_{11} with γ(0)\gamma(0).
Checkpoints
  1. The first row is (0.5,−0.2,0.1)(0.5,-0.2,0.1); rows two and three shift the state with ones on the first subdiagonal.
  2. Match the two unordered sets after taking reciprocals; allow floating-point tolerance.
  3. A coefficient larger than one does not decide stability by itself; the polynomial roots or companion eigenvalues do.
  4. Γ1=[γ(0)]\Gamma_1=[\gamma(0)] and γ1=[γ(1)]\boldsymbol\gamma_1=[\gamma(1)].
  5. Stability depends on all roots jointly, not on one coefficient or one sum.

Completion standard

You should be able to move without ambiguity among lag-polynomial, companion-matrix, impulse-response, and Yule–Walker representations.

Continue to Lab 3 — Prediction and Likelihood.

Copyright © 2026