Connects to: Principles Ch. 6, Ch. 15–16, Ch. 20, Appendix B
The models of Parts III and IV are deterministic or, in the case of the RBC model, stochastic in a fully numerical sense — we solved the Bellman equation on a grid without exploiting any linear structure. This part develops the analytical and statistical machinery for handling stochastic models algebraically: rational expectations solution methods, time-series econometrics, the Kalman filter, and structural estimation. These are the tools that connect the theoretical models of Parts III–IV to the data and to the estimation exercises of Part VII.
Chapter 18 solves linear models with forward-looking expectations — the defining feature of New Keynesian macroeconomics. The method of undetermined coefficients (UMC) and McCallum’s minimum-state-variable (MSV) procedure reduce infinite-horizon expectational difference equations to finite-dimensional algebraic problems. Chapter 19 develops the time-series toolkit: unit roots, cointegration, VARs, structural identification, impulse responses, and forecast-error variance decompositions. Chapter 20 derives the Kalman filter from scratch as the MMSE estimator for state-space models, applies it to the output gap and natural rate, and shows how it generates the likelihood function for DSGE estimation. Chapter 21 completes the estimation toolkit with GMM and maximum likelihood, including full asymptotic theory, the delta method, and the application to the consumption Euler equation.
By the end of this part, the reader can take a log-linearized DSGE model (from Part VII), evaluate its likelihood using the Kalman filter, and estimate its parameters via GMM or MLE — the complete estimation pipeline used by every modern central bank model.
Chapter 18: Rational Expectations¶
Solving Linear Expectational Difference Equations
“The assumption of rational expectations is not that agents are geniuses. It is that they are not systematically fooled by the same mistake, period after period.” — Robert Lucas
Cross-reference: Principles Ch. 15 (rational expectations definition and the Lucas critique); Ch. 16 (policy ineffectiveness, Barro–Gordon); Ch. 10 (NKPC forward solution as present-value formula) [P:Ch.15, P:Ch.16, P:Ch.10]
18.1 The Rational Expectations Problem¶
Chapter 4 introduced the issue of forward-looking difference equations — equations in which appears as an argument. Chapter 4’s treatment was informal: we conjectured the MSV solution form and solved for coefficients by matching. This chapter develops the full formal theory.
A rational expectations equilibrium is a stochastic process such that: (i) households and firms form expectations as the mathematical conditional expectation given their information set; and (ii) the equilibrium conditions of the model are satisfied. The challenge is that depends on the equilibrium process for , which in turn depends on expectations — a circular structure that requires a fixed-point argument to solve.
For linear models, this circular structure can be broken algebraically, yielding closed-form solutions. The tools developed here — undetermined coefficients, the MSV criterion, Blanchard–Kahn counting — are the foundation for Part VII’s DSGE solution algorithms.
18.2 The Scalar Expectational Difference Equation¶
The simplest expectational difference equation:
Here are parameters, is an exogenous AR(1) forcing variable, and is the endogenous variable. We seek a solution consistent with rational expectations.
18.2.1 The Forward Solution¶
Case 1: (saddle-path stable). Iterate the equation forward:
using (the AR(1) forecast). This is the unique bounded solution when and .
Case 2: (indeterminate / forward-explosive). With , the forward iteration diverges unless jumps to eliminate the explosive component. Rearrange as and substitute the MSV guess :
Remarkably, the same formula applies regardless of whether or ! The distinction is in uniqueness: when the solution is the unique bounded one; when there are additional “sunspot” solutions.
18.2.2 Sunspot Solutions and Multiplicity¶
When , the general solution is:
where is any process satisfying . For example, for any constant is a solution (it dies out monotonically). But also any process with works — including sunspot processes driven by extraneous randomness.
Definition 18.1 (Sunspot Equilibrium). A sunspot equilibrium is a rational expectations equilibrium in which the endogenous variable responds to extraneous “sunspot” variables that have no fundamental economic content (they do not affect preferences, technology, or endowments). The sunspot variable satisfies where is an arbitrary martingale difference sequence.
When : multiple equilibria (MSV plus any sunspot). When : unique bounded equilibrium (MSV only). This is the scalar analogue of the Blanchard–Kahn counting rule.
18.3 The Method of Undetermined Coefficients (UMC)¶
The UMC provides a systematic procedure for finding the MSV solution of any linear rational expectations model.
Algorithm 18.1 (Method of Undetermined Coefficients).
Identify the state variables — the minimal set such that the solution can be written .
Conjecture the MSV form — where is an unknown matrix.
Compute — using the law of motion of : .
Substitute into the model equations.
Match coefficients — equate coefficients of on both sides to get a matrix equation for .
Solve for . Uniqueness of is the MSV uniqueness condition.
The matrix equation obtained in step 5 is a Sylvester equation of the form:
where , , and are known matrices from the model. Vectorizing: . A unique solution exists iff is invertible — iff no eigenvalue of equals the negative of any eigenvalue of , which is generically satisfied.
18.4 The New Keynesian Model: Forward Solutions¶
Cross-reference: Principles Ch. 10 (NKPC), Ch. 23 (NK policy) [P:Ch.10, P:Ch.23]
18.4.1 The NKPC as a Forward Equation¶
The New Keynesian Phillips Curve:
where is a cost-push shock. This is an expectational difference equation with , which satisfies . Iterating forward:
Definition 18.2 (Present-Value Inflation Formula). The NKPC forward solution expresses current inflation as the present discounted value of all future expected output gaps and cost-push shocks:
This is exactly the formula in Principles Ch. 10.4 [P:Ch.10.4], now derived rigorously. Inflation today depends on the entire expected future path of the output gap — a forward-looking property that makes disinflation potentially costless if it is credible (agents immediately revise down all future inflation expectations).
18.4.2 The NK Three-Equation System Under a Taylor Rule¶
Combine the DIS, NKPC, and Taylor rule from Principles Ch. 23 [P:Ch.23]:
with exogenous shocks: (demand shock).
Step 1: Substitute the Taylor rule into the DIS:
Collecting :
Step 2: Stack the system. Let and . Write in the canonical form:
Step 3: Reduce to standard form. Pre-multiply by :
Step 4: Apply UMC. Guess . Then . Substituting:
This is the Sylvester equation for a matrix (since is scalar):
This requires to be invertible — satisfied generically.
Step 5: Verify determinacy. The solution is the unique MSV solution iff the NK system has a unique bounded equilibrium. For a system with two free (forward-looking) variables , the Blanchard–Kahn condition requires two eigenvalues of outside the unit circle.
Theorem 18.1 (Taylor Principle and Determinacy). In the NK three-equation model, the Blanchard–Kahn condition is satisfied — the equilibrium is unique — if and only if:
For : the condition reduces to , the Taylor principle: the central bank must raise the nominal rate by more than one-for-one with inflation.
Proof sketch. The determinant and trace of can be computed explicitly. The eigenvalue analysis shows that both eigenvalues of have modulus greater than 1 iff the stated condition holds. See Chapter 28 for the full proof using the QZ decomposition.
18.5 Sunspots and Indeterminacy in the NK Model¶
When (Taylor principle violated), the NK model has indeterminate equilibria: the MSV solution is one equilibrium, but there are infinitely many others driven by sunspot shocks. The general solution is:
where is an arbitrary sunspot process satisfying (where is the eigenvalue of inside the unit circle) and is a coefficient determined by the eigenvector.
Economic implication: Sunspot equilibria generate volatility unrelated to fundamentals — the economy can fluctuate even when technology, preferences, and government policy are perfectly stable. The Taylor principle () rules out sunspots by ensuring both eigenvalues of lie outside the unit circle, leaving the MSV solution as the unique equilibrium [P:Ch.23.1].
18.6 Worked Example: Impulse Response to a Cost-Push Shock¶
Cross-reference: Principles Ch. 10.3, Ch. 23.2 [P:Ch.10.3, P:Ch.23.2]
Calibration: , , , , , (i.i.d. shock, so ).
Add a cost-push shock with .
State: . Augment the NKPC: .
MSV guess: where is .
The Sylvester equation where and now has a second column for .
Solving numerically:
⍝ APL — NK model MSV solution
⎕IO←0 ⋄ ⎕ML←1
⍝ Parameters
beta←0.99 ⋄ kappa←0.15 ⋄ sigma←1 ⋄ phi_pi←1.5 ⋄ phi_y←0.5
rho_r←0.0 ⋄ rho_u←0.5
⍝ Γ₀ and Γ₁ matrices (stacked system: [NKPC; DIS with Taylor substituted])
G0 ← 2 2 ⍴ 1 (-kappa) (sigma×phi_pi) (1+sigma×phi_y)
G1 ← 2 2 ⍴ beta 0 sigma 1 ⍝ FIXED: sigma is positive here
A ← (⌹G0) +.× G1 ⍝ A = Γ₀⁻¹Γ₁
⍝ Eigenvalues of A (assuming you have a Python bridge for ⎕PY)
⍝ ⎕PY.Import 'numpy as np'
⍝ eigs ← A ⎕PY.Call 'np.linalg.eigvals'
⍝ |eigs
⍝ C matrix: columns for [u shock, r^n shock]
G0_inv ← ⌹G0
Psi_r ← 0 sigma ⍝ r^n enters DIS only
Psi_u ← 1 0 ⍝ u enters NKPC only
C ← G0_inv +.× (2 2 ⍴ Psi_u , Psi_r)
⍝ State transition
Phi ← 2 2 ⍴ rho_u 0 0 rho_r
⍝ Sylvester equation: Ω = A Ω Φ + C
kron ← {4 4 ⍴ 0 2 1 3 ⍉ ⍺ ∘.× ⍵}
Phi_t ← ⍉Phi
KronPA ← A kron Phi_t
⍝ FIXED: Use outer product to generate the 4x4 Identity Matrix
I4 ← (⍳4) ∘.= ⍳4
vec_C ← , C
vec_Omega ← vec_C ⌹ (I4 - KronPA) ⍝ b ⌹ A solves Ax = b
Omega ← 2 2 ⍴ vec_Omega
⍝'Omega'
⍝Omega ⍝ [ω_π_u ω_π_r; ω_x_u ω_x_r]
⍝ Impulse responses: response to unit u shock (initial state: 1 0)
H ← 20
⍝ Use a dfn {Phi+.×⍵} for the power operator to repeat the matrix multiplication
irf_u ← {Omega +.× {Phi +.× ⍵}⍣⍵ ⊢ 1 0} ¨ ⍳H
⍝ Extract values (using simplified indexing)
pi_irf ← {⍵[0]} ¨ irf_u ⍝ inflation impulse response
x_irf ← {⍵[1]} ¨ irf_u ⍝ output gap impulse response
⍝ --- Formatted Output ---
'--- MSV Solution: Impact Matrix (Omega) ---'
' u-shock rn-shock'
(2 1⍴'pi' 'x'), Omega
'--- Impulse Responses to u-shock (20 periods) ---'
'Period | Inflation | Output Gap'
'-------|-----------|-----------'
(⍪⍳H) (⍪pi_irf) (⍪x_irf)Python¶
import numpy as np
beta, kappa, sigma, phi_pi, phi_y = 0.99, 0.15, 1.0, 1.5, 0.5
rho_u, rho_r = 0.5, 0.0
# Structural matrices
G0 = np.array([[1, -kappa], [sigma*phi_pi, 1+sigma*phi_y]])
G1 = np.array([[beta, 0], [-sigma, 1]])
A = np.linalg.inv(G0) @ G1
# Check Taylor principle
eigs = np.linalg.eigvals(A)
print(f"Eigenvalues of A: {np.abs(eigs)} (both > 1: {np.all(np.abs(eigs)>1)})")
# Shock loadings (C matrix)
G0_inv = np.linalg.inv(G0)
Psi = np.array([[1, 0], [0, sigma]]) # [u in NKPC, r^n in DIS]
C = G0_inv @ Psi
# State transition matrix
Phi = np.diag([rho_u, rho_r])
# Sylvester equation: Omega = A @ Omega @ Phi + C
# Vectorized: (I - Phi' ⊗ A) vec(Omega) = vec(C)
from numpy import kron
KronPA = np.kron(Phi.T, A)
I4 = np.eye(4)
vec_Omega = np.linalg.solve(I4 - KronPA, C.flatten(order='F'))
Omega = vec_Omega.reshape(2, 2, order='F')
print(f"\nMSV solution matrix Ω:\n{np.round(Omega,3)}")
print(f"Interpretation: π̂_t = {Omega[0,0]:.3f}·u_t + {Omega[0,1]:.3f}·r^n_t")
print(f" x̂_t = {Omega[1,0]:.3f}·u_t + {Omega[1,1]:.3f}·r^n_t")
# Impulse responses to cost-push shock u (column 0 of Omega × Phi^h × e_u)
H = 20
e_u = np.array([1, 0]) # unit shock to u
irf_pi = np.zeros(H); irf_x = np.zeros(H)
state = e_u.copy()
for h in range(H):
response = Omega @ state
irf_pi[h] = response[0]; irf_x[h] = response[1]
state = Phi @ state
import matplotlib.pyplot as plt
fig, (ax1, ax2) = plt.subplots(1,2, figsize=(10,4))
ax1.bar(range(H), irf_pi, color='steelblue')
ax1.axhline(0, color='k', lw=0.5); ax1.set_title('Inflation IRF (cost-push shock)')
ax1.set_xlabel('Quarters')
ax2.bar(range(H), irf_x, color='tomato')
ax2.axhline(0, color='k', lw=0.5); ax2.set_title('Output gap IRF (cost-push shock)')
ax2.set_xlabel('Quarters')
plt.tight_layout(); plt.show()Julia¶
using LinearAlgebra
beta, kappa, sigma, phi_pi, phi_y = 0.99, 0.15, 1.0, 1.5, 0.5
rho_u, rho_r = 0.5, 0.0
G0 = [1 -kappa; sigma*phi_pi 1+sigma*phi_y]
G1 = [beta 0; -sigma 1]
A = inv(G0) * G1
eigs = eigvals(A)
println("Eigenvalues of A: $(round.(abs.(eigs),digits=3)) (>1: $(all(abs.(eigs).>1)))")
G0_inv = inv(G0)
Psi = [1 0; 0 sigma]
C = G0_inv * Psi
Phi = diagm([rho_u, rho_r])
# Sylvester: Ω = A*Ω*Φ + C → (I - Φ'⊗A)vec(Ω) = vec(C)
KronPA = kron(Phi', A)
I4 = I(4)
vec_Omega = (I4 - KronPA) \ vec(C)
Omega = reshape(vec_Omega, 2, 2)
println("\nΩ (MSV solution):\n", round.(Omega, digits=3))
# IRF to unit cost-push shock
H = 20
irf = [Omega * (Phi^h * [1.0, 0.0]) for h in 0:H-1]
pi_irf = [r[1] for r in irf]
x_irf = [r[2] for r in irf]
println("\nInflation IRF (first 5): $(round.(pi_irf[1:5], digits=3))")
println("Output IRF (first 5): $(round.(x_irf[1:5], digits=3))")R¶
beta<-0.99; kappa<-0.15; sigma<-1; phi_pi<-1.5; phi_y<-0.5
rho_u<-0.5; rho_r<-0.0
G0 <- matrix(c(1,sigma*phi_pi,-kappa,1+sigma*phi_y),2,2)
G1 <- matrix(c(beta,-sigma,0,1),2,2)
A <- solve(G0) %*% G1
eigs <- eigen(A)$values
cat(sprintf("Eigenvalue moduli: %.3f, %.3f (Taylor principle: %s)\n",
Mod(eigs[1]), Mod(eigs[2]), all(Mod(eigs)>1)))
Psi <- matrix(c(1,0,0,sigma),2,2)
C <- solve(G0) %*% Psi
Phi <- diag(c(rho_u, rho_r))
# Sylvester equation (using vec and Kronecker)
KronPA <- kronecker(t(Phi), A)
I4 <- diag(4)
vec_Omega <- solve(I4 - KronPA, as.vector(C))
Omega <- matrix(vec_Omega, 2, 2)
cat("\nΩ (MSV solution):\n"); print(round(Omega,3))
# IRF
H <- 20
state <- c(1, 0)
pi_irf <- x_irf <- numeric(H)
for(h in 1:H) {
resp <- Omega %*% state; pi_irf[h] <- resp[1]; x_irf[h] <- resp[2]
state <- Phi %*% state
}
cat("\nInflation IRF (first 5):", round(pi_irf[1:5],3))18.7 Programming Exercises¶
Exercise 18.1 (APL — Determinacy Region)¶
Compute the determinacy region in space for the NK model. For each pair on a grid over : (a) compute ; (b) compute the eigenvalue moduli; (c) flag as determinate if both moduli exceed 1. Display as an APL Boolean matrix and verify the boundary matches .
Exercise 18.2 (Python — Forward Guidance)¶
“Forward guidance” is a commitment to keep rates at zero for periods beyond when liftoff would normally occur. In the NK model, this means setting for and returning to the Taylor rule at . (a) Solve the model recursively backward from (where the Taylor rule applies) to (where the peg applies). (b) Plot the impulse response of inflation and the output gap at as a function of for . (c) Observe the “forward guidance puzzle”: the effect grows exponentially in for standard calibrations.
Exercise 18.3 (Julia — Sunspot Volatility)¶
# Compare fundamental vs. sunspot volatility
beta, kappa, sigma = 0.99, 0.15, 1.0
# Indeterminate calibration: phi_pi = 0.8 (below Taylor principle)
phi_pi_ind = 0.8; phi_y_ind = 0.0
G0_ind = [1 -kappa; sigma*phi_pi_ind 1+sigma*phi_y_ind]
G1_ind = [beta 0; -sigma 1]
A_ind = inv(G0_ind) * G1_ind
eig_ind = eigvals(A_ind)
println("Indeterminate eigenvalues: $(round.(abs.(eig_ind),digits=3))")
# One eigenvalue inside unit circle → sunspots possible
lam_inside = eig_ind[argmin(abs.(eig_ind))]
println("Inside eigenvalue λ = $(round(lam_inside,digits=3))")
println("Sunspot process: ξ_t = $(round(1/abs(lam_inside),digits=3))·ξ_{t-1} + η_t")Exercise 18.4 — Hybrid NKPC ()¶
The hybrid NKPC (Galí and Gertler, 1999) has both forward- and backward-looking components:
Now is a predetermined state variable. (a) Write the system in the form with . (b) The system now has one predetermined variable () and two jump variables; the Blanchard–Kahn condition requires exactly one eigenvalue inside the unit circle. (c) Solve using the MSV approach and compare IRFs to the pure NKPC case.
18.8 Chapter Summary¶
Key results:
The scalar expectational equation has MSV solution , valid whenever ; unique bounded solution iff ; multiple solutions (sunspots) iff .
The method of undetermined coefficients: conjecture , substitute, match coefficients to get the Sylvester equation , solve via .
The NK model in canonical form is determinate iff both eigenvalues of lie outside the unit circle — the Blanchard–Kahn condition with free variables.
The Taylor principle () is necessary and sufficient for determinacy in the NK model.
In APL: the Kronecker product is
Phi_t kron Avia outer product∘.×; the Sylvester system is solved byvec_C ⌹ I4 - KronPA; IRFs are{Omega +.× Phi⍣⍵ +.× e_shock}¨⍳H.
Next: Chapter 19 — Time Series Methods for Macroeconomic Data