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

**1. Huggett Model (from Achdou et al., 2017):**

**Explanation of Algorithm**

HJB equation, explicit method (Section 1.1):

**HJB_stateconstraint_explicit.m**

HJB equation, implicit method (Section 1.2):

**HJB_stateconstraint_implicit.m**

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

**huggett_partialeq.m**

Plotting the asset supply function (Section 3.1):

**huggett_asset_supply.m**

Finding the equilibrium interest rate (Section 3.2):

**huggett_equilibrium_iterate.m**

Transition Dynamics (Section 4):

**huggett_transition.m**,

**huggett_initial.m**,

**huggett_terminal.m**

HJB equation with diffusion, implicit method (section 5.1):

**HJB_diffusion_implicit.m**

KFE Equation (Section 5.2, using HJB matrix):

**huggett_diffusion_partialeq.m**

Credit Crunch (courtesy of Gustavo Mellior):

**Explanation of Algorithm**,

**huggett_transition_cc.m**,

**huggett_initial_cc.m**,

**huggett_terminal_cc.m**,

**gifmaker.m**

Consumption-Saving Problem with Endogenous Labor Supply:

**Explanation of Algorithm**,

**HJB_labor_supply.m**,

**lab_solve.m**

**2. Aiyagari Model (from Achdou et al., 2017):**

**Explanation of Algorithm**

Stationary Equilibrium with Poisson Process:

**aiyagari_poisson_steadystate.m**

Steady State Asset Supply Function with Poisson Process:

**aiyagari_poisson_asset_supply.m**

Python version (Jupyter notebook):

**aiyagari_continuous_time.ipynb**, should be compared with

**QuantEcon's discrete-time version of the Aiyagari model**

"MIT Shock" with Poisson Income Process:

**aiyagari_poisson_MITshock.m**

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

**aiyagari_diffusion_equilibrium.m**

Julia version of code:

**aiyagari_diffusion_equilibrium.jl**(download Juno for nice GUI)

C++ version of code:

**aiyagari_diffusion_equilibrium.cpp**(instructions for Mac users, makefile)

Transition Dynamics with Diffusion (Section 6.2):

**aiyagari_diffusion_transition.m**

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):

**make_movie.m**

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

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

**3. Investment under Uncertainty by Heterogeneous Firms:**

**Description of Model and Algorithm**

Partial Equilibrium:

**firm.m**

**4. Model with Two Assets and Kinked Adjustment Costs:**

**Description of Model and Algorithm**

Partial Equilibrium:

**two_asset_kinked.m**

Subroutines:

**two_asset_kinked_cost.m**,

**two_asset_kinked_FOC.m**

**5. Handling Non-Convexities I: Neoclassical Growth Model with Convex-Concave Production Function (Skiba, 1978).**

**Description of Model and Algorithm**

Finding the "Skiba point":

**HJB_NGM_skiba.m**

**6. Handling Non-Convexities II: Entrepreneurship and Financial Frictions.**

**Description of Model and Algorithm**

Stationary Equilibrium:

**entrepreneurs.m**

MIT Shock:

**entrepreneurs_MIT_shock.m**

**7. Handling Non-Convexities III: Indivisible Housing and Mortgages.**

**Description of Model: see Section 4.3 of Achdou et al. (2017)**

Partial Equilibrium:

**housing.m**

**8. Stopping Time Problem I: Exercising an Option:**

**Description of Model and Algorithm**

Solve as Linear Complementarity Problem (LCP):

**option_simple_LCP.m**plus

**LCP.m**

**(LCP solver)**

**9. Stopping Time Problem II: An Indivisible Durable:**

**Description of Model and Algorithm**

Solve as Linear Complementarity Problem (LCP):

**car.m**plus

**LCP.m**

**(LCP solver)**

**10. Stopping Time Problem III: Liquid and Illiquid Assets and Fixed Adjustment Costs:**

**Description of Model and Algorithm**

Solve as Linear Complementarity Problem (LCP):

**liquid_illiquid_LCP.m**plus

**LCP.m**

**(LCP solver)**and

**lininterp1.m**(interpolation routine)

**11. Consumption, Saving and Wealth Distribution with Hansen-Sargent Robustness Concerns (with Edouard Djeutem):**

**Description of Model and Algorithm**

Code:

**robust.m**

**12. Labor-Market Matching with Precautionary Savings (courtesy of Bence Bardoczy):**

**Description of Model and Algorithm**

Codes:

**kms.zip**

**13. Additional Codes:**

**Explanation of Algorithm**

No uncertainty, explicit method (Section 1.1):

**HJB_simple.m**,

**HJB_no_uncertainty_explicit.m**

No uncertainty, implicit method (Section 1.2):

**HJB_no_uncertainty_implicit.m**

Neoclassical Growth Model, explicit method (Section 2.1):

**HJB_NGM.m**

Neoclassical Growth Model, implicit method (Section 2.2):

**HJB_NGM_implicit.m**

RBC Model with diffusion for TFP, implicit method:

**HJB_diffusion_implicit_RBC.m**

**14.**

**Matthieu Gomez's GitHub Repository**

**with great Julia codes, including the Bansal-Yaron (2004) Long-Run Risk Model**

**15. Perturbation methods for heterogeneous agent models with aggregate shocks:**

**Paper**,

**Codes**,

**Example 1: using the toolbox to solve Krusell-Smith model**,

**Example 2: using the toolbox to solve a one-asset HANK model**

**16. Codes for Nuno and Moll (2017),**

**"Social Optima in Economies with Heterogeneous Agents"**

**SOHA_codes.zip**

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

**HJB_stateconstraint_implicit_old.m**

**huggett_partialeq_old.m**

**huggett_asset_supply_old.m**

**huggett_equilibrium_iterate_old.m**

**HJB_diffusion_implicit_old.m**

**huggett_diffusion_partialeq_old.m**

**aiyagari_diffusion_equilibrium_old.m**