Benjamin Moll

Heterogeneous Agent Models

in Continuous Time

This is a collection of codes that solve a number of heterogeneous agent models in continuous time using finite difference methods.

Huggett Model

HJB equation, explicit method (Section 1.1)

HJB equation, implicit method (Section 1.2)

KFE Equation (Section 2, using matrix from HJB implicit method)

Plotting the asset supply function (Section 3.1)

Finding the equilibrium interest rate (Section 3.2)

Transition Dynamics (Section 4)

All of (4a)-(4c) need inputs huggett_initial.m, huggett_terminal.m

(4a) simple updating rule

HJB equation with diffusion, implicit method (section 5.1)

KFE Equation (Section 5.2, using HJB matrix)

Consumption-Saving Problem with Endogenous Labor Supply

Aiyagari Model

Stationary Equilibrium with Poisson Process

Steady State Asset Supply Function with Poisson Process

Python version (Jupyter notebook)

“MIT Shock” with Poisson Income Process

Stationary Eq. with Diffusion (Section 6.1, courtesy of Galo Nuno)

Transition Dynamics with Diffusion (Section 6.2)


Julia code for MIT Shock with Diffusion (courtesy of Matthieu Gomez): aiyagari_diffusion_MITshock.jl

Make movie of evolution of wealth distribution (Section 6.4)

Aiyagari Model with Fat-tailed Wealth Distribution (Section 8)

fat_tail_partialeq.m, uses non-uniform grid as explained in Section 7

Sequence-Space Methods for Models with Aggregate Shocks

Adrien Bilal and Shlok Goyal’s continuous-time sequence-space methods

For reference: original discrete-time implementation by Adrien Auclert, Bence Bardóczy, Matt Rognlie, and Ludwig Straub

Lifecycle Model

Partial Equilibrium

Two Endogenous State Variables: Wealth and Human Capital

Partial Equilibrium

Investment under Uncertainty by Heterogeneous Firms

Partial Equilibrium

Model with Two Assets and Kinked Adjustment Costs

Partial Equilibrium

Handling Non-Convexities I

Neoclassical Growth Model with Convex-Concave Production Function (Skiba, 1978)

Finding the “Skiba point”

Handling Non-Convexities II

Entrepreneurship and Financial Frictions

Stationary Equilibrium

Handling Non-Convexities III

Partial Equilibrium

Stopping Time Problem I

Exercising an Option

Solve as Linear Complementarity Problem (LCP)

Python version of LCP solver (courtesy of Saeed Shaker)

LCP_Python.ipynb (Python version of LCP.m)

Stopping Time Problem II

Firm Entry and Exit (Hopenhayn, 1992)

Solve as Linear Complementarity Problem (LCP)

hopenhayn.m plus LCP.m (LCP solver)

Julia version of code: hopenhayn.jl (courtesy of Chase Abram)

Stopping Time Problem III

An Indivisible Durable

Solve as Linear Complementarity Problem (LCP)

Stopping Time Problem IV

Liquid and Illiquid Assets and Fixed Adjustment Costs

Solve as Linear Complementarity Problem (LCP)

liquid_illiquid_LCP.m plus LCP.m (LCP solver) and lininterp1.m (interpolation routine)

Stopping Time Problem V

Consumption and Saving with Default
(courtesy of Gustavo Mellior and Katsuyuki Shibayama)

Solve as LCP

default.m plus LCP.m (LCP solver) and cTsolver.m (subroutine)

Consumption, Saving and Wealth Distribution with Hansen-Sargent Robustness Concerns


Labor-Market Matching with Precautionary Savings

Description of Model and Algorithm courtesy of Bence Bardoczy


Additional Codes

No uncertainty, explicit method (Section 1.1)

No uncertainty, implicit method (Section 1.2)

Neoclassical Growth Model, explicit method (Section 2.1)

Neoclassical Growth Model, implicit method (Section 2.2)

RBC Model with diffusion for TFP, implicit method

João Duarte's Python Codes

João Duarte’s GitHub Repository with python versions of many of the codes on this website

Matthieu Gomez's GitHub Repository

Matthieu Gomez’s GitHub Repository with great Julia codes, incl. the Bansal-Yaron (2004) Long-Run Risk Model

Constantin Schesch's Spectral Methods (Collocation Methods)

Schesch (JEDC, 2024) “Pseudospectral methods for continuous-time heterogeneous-agent models”

Constantin Schesch’s GitHub Repository with codes for solving heterogeneous agent models using pseudo-spectral methods (collocation methods).

Perturbation methods for heterogeneous agent models with aggregate shocks

Codes for Nuno and Moll (2017)

Old codes for Huggett Model without using Matlab's sparse matrix routines (slower)

Close Menu