Got Claude to write a brief explanation of exactly what Benjamin Moll’s transition path in Huggett (1993) model example codes are solving, and the differences between the three. Mainly so later if I decide to then it will be easy to build three toolkit examples that can be exactly compared to these to see things like accuracy, runtimes, and number of iterations.
The model
Continuous-time Huggett (1993) — Aiyagari–Bewley–Huggett with pure risk-sharing and no capital:
- Income z \in \{z_1, z_2\} = \{0.1, 0.2\}, two-state Poisson, rates \lambda_1 (low→high) and \lambda_2 (high→low).
- Agents hold a bond a paying r, CRRA \sigma = 2, \rho = 0.05, borrowing limit a \ge \underline{a} = -0.15 imposed as a state constraint (the
dVb(1,:) = (z + r*amin)^(-s) boundary condition).
- Bonds are in zero net supply, so equilibrium r is whatever makes S \equiv \int a \, g(a,z) \, da \, dz = 0.
Solved as HJB (backward, upwind finite differences, implicit) plus Kolmogorov Forward (forward, using the transpose of the same generator matrix A).
The experiment
An unanticipated permanent MIT shock at t = 0: \lambda_2 jumps from 0.5 (huggett_initial.m) to 0.8 (huggett_terminal.m), with \lambda_1 = 0.6 throughout. Good-income spells shorten from 2 years to 1.25; the stationary share in the low state rises from 0.5/1.1 = 45.5\% to 0.8/1.4 = 57.1\%. More income risk → stronger precautionary saving → lower equilibrium r in the new steady state. Agents learn the new \lambda_2 and the entire path \{r_t\} at t = 0, and have perfect foresight thereafter.
The three problems
1. Initial (huggett_initial.m). Stationary equilibrium at \lambda_2 = 0.5: bisect on r until S(r) = 0. Its only role in the transition is to deliver g_0 — the initial condition for the distribution, which is predetermined and cannot jump. (r00 is used only to draw the pre-shock segment of the plot.)
2. Terminal (huggett_terminal.m). Stationary equilibrium at \lambda_2 = 0.8. Delivers v_{st} — the terminal condition for the value function, which is forward-looking and does jump at t = 0 — and r_{st} as the initial guess for the path.
3. Transition (huggett_transition.m). A two-point boundary value problem on [0,T], with T = 20 and N = 100 nodes: find \{r_t\} such that
\rho v = u(c) + \partial_a v \cdot (z + r_t a - c) + \lambda_z (v_{-z} - v), \qquad v(\cdot, T) = v_{st}
\partial_t g = -\partial_a (s_t g) + \text{switching}, \qquad g(\cdot, 0) = g_0
\int a \, g_t \, da \, dz = 0 \quad \text{for all } t
Note how market clearing is actually imposed: the code computes dS(n), the change in aggregate wealth over each step, and drives that to zero. Since S(0) = 0 is inherited from the initial steady state, \dot{S}_t = 0 for all t is equivalent to S_t = 0. This works because the KFE conserves mass exactly, so the level condition never needs re-imposing. T must be long enough that the economy has effectively reached the terminal steady state by then.
The structural point: v depends on the future path of r, while g depends on the past — so you cannot iterate forward in time. You must guess the whole path, sweep backward for v (storing every A_t), then forward for g using those same A_t, and check market clearing.
What differs across the files
| File |
Update on the r-path |
huggett_transition.m |
Relaxation: r^{new} = r - \xi_t \odot dS, with \xi_t = 20(e^{-0.05t} - e^{-0.05N}) — hand-tuned, decaying in t so late periods move less. Robust-ish, slow, uses no derivative information. |
huggett_newton.m + huggett_subroutine.m |
Treats F : \mathbb{R}^{100} \to \mathbb{R}^{100}, F(r) = dS(r), and solves F = 0. Jacobian at the initial guess by forward differences — 100 full transition solves, the expensive part — then dampened Broyden (\xi = 0.1) with rank-one updates J \leftarrow J + f \, dx' / (dx' dx). rank(J) is checked because a singular Jacobian signals the price path is not identified. |
huggett_newton_myAD.m + huggett_subroutine_myAD.m |
Identical Newton scheme, but the 100 \times 100 Jacobian comes from forward-mode automatic differentiation in a single pass — exact rather than finite-differenced, and far cheaper. This is the real payoff of the AD version. |
The subroutine is literally the inner loop of huggett_transition.m refactored to return dS as a residual vector, which is what makes it usable as F(x) for a root-finder.