High-Dimensional Dynamic Programming

Annotated notebooks on occasionally binding constraints and sovereign default, using three approaches to dynamic programming.

JAX Accelerated array computation

Implementations using accelerated array computation and automatic differentiation in Python.

  1. JAX · Python

    Occasionally Binding Constraints Model

    Time iteration with JIT-compiled policy updates. The multiplier identifies where the collateral constraint binds.

    Policy functions and Kuhn–Tucker multipliers from the JAX occasionally binding constraints notebook
    Policy function and Kuhn–Tucker multiplier
  2. JAX · Python

    Sovereign Default Model with Long-Term Debt

    Smoothed value-function iteration with endogenous long-term bond prices. The summary pairs expected debt choices with the default-risk surface.

    Expected sovereign debt policies and a heatmap of default probabilities from the JAX notebook
    Expected debt policy and default-risk surface

ASG Adaptive sparse grids

Julia and Python implementations using sparse-grid approximation to manage higher-dimensional state spaces.

  1. ASG · Julia

    Occasionally Binding Constraints Model

    Adaptive policy iteration in Julia. Grid nodes concentrate where the collateral constraint creates a kink in the policy function.

    Debt policy functions and adaptive sparse-grid nodes from the Julia occasionally binding constraints notebook
    Policy function and adaptive grid points
  2. ASG · Python

    Occasionally Binding Constraints Model

    DDSG/Tasmanian approximation with a coarse warm start and adaptive refinement. Node colors report the collateral multiplier.

    Debt policy functions and multiplier-colored sparse-grid nodes from the Python adaptive-grid notebook
    Policy function and multiplier-colored grid points
  3. ASG · Julia

    Sovereign Default Model with Long-Term Debt

    Adaptive approximations for repayment and default values, combined with endogenous long-term debt prices.

    Sovereign debt policies and adaptive repayment-value grid nodes from the Julia notebook
    Debt policy and repayment-value grid points

ANN Artificial neural networks

Neural-network function approximation using Flux.jl and PyTorch.

  1. ANN · Flux.jl

    Occasionally Binding Constraints Model

    A bounded Flux.jl policy network trained on a Fischer–Burmeister equilibrium residual.

    Training loss and learned debt policy from the Flux neural-network notebook
    Training history and learned policy
  2. ANN · PyTorch

    Occasionally Binding Constraints Model

    A bounded PyTorch policy network with stochastic collocation and complementary-slackness training.

    Training loss and learned debt policy from the PyTorch neural-network notebook
    Training history and learned policy

Heterogeneous Agents

From individual income risk to aggregate uncertainty. Each discrete-time example pairs a readable implementation with an efficient solver and one figure. These are teaching examples, with documented simplifications relative to the papers.

  1. 1993 · Huggett

    The Risk-Free Rate in Heterogeneous-Agent Incomplete-Insurance Economies

    Precautionary saving and a market-clearing bond price. Seven income states and Young's method describe the stationary asset distribution.

    Huggett saving policies and the stationary asset distribution, including mass at the borrowing limit
    Saving policies and stationary assets
  2. 1994 · Aiyagari

    Uninsured Idiosyncratic Risk and Aggregate Saving

    A production economy in which household saving determines aggregate capital, wages, and the interest rate.

    Also available: continuous-time version.

    Aiyagari saving policies and the stationary distribution of household assets
    Saving policies and stationary assets
  3. 1998 · Krusell & Smith

    Income and Wealth Heterogeneity in the Macroeconomy

    Individual employment risk meets aggregate productivity shocks. Households use a simple forecasting rule for aggregate capital, updated until it agrees with the simulated economy.

    Time-averaged Krusell–Smith asset distribution and an out-of-sample comparison of aggregate capital with its one-step forecast
    Asset distribution and aggregate-capital forecast

Other Replications

  1. 1993 · Froot et al.

    Risk Management: Coordinating Corporate Investment and Financing Policies

    View code

  2. 1995 · Duan

    The GARCH Option Pricing Model

    View code

  3. 2008 · Arellano

    Default Risk and Income Fluctuations in Emerging Economies

    View code

  4. 2010 · Rampini & Viswanathan

    Collateral, Risk Management, and the Distribution of Debt Capacity

    View code

  5. 2011 · Bianchi

    Overborrowing and Systemic Externalities in the Business Cycle

    View code

  6. 2014 · Schmitt-Grohé & Uribe

    Finite-State Approximation of VAR Processes: A Simulation Approach

    View code

  7. 2022 · Arce et al.

    A Macroprudential Theory of Foreign Reserve Accumulation

    View code