Deep learning for solving dynamic economic models

Deep learning for solving dynamic economic models

This notebook solves a version of Krusell and Smith’s (1998) heterogenous-agent model with idiosyncrastic and aggregate shocks, incomplete markets and borrowing constraints. It uses a deep learning Euler-equation method introduced by Maliar, Maliar and Winant (2018) in the paper “Deep learning for solving dynamic economic models”, Journal of Monetary Economics 122, pp 76-101.

We show a version of the Euler equation method that minimizes the sum of squared residuals in the equilibrium conditions. See for documentation, updates and the other versions of the deep learning method (Bellman equation and life-time reward).




We introduce a unified deep learning method that solves dynamic economic models by casting them into nonlinear regression equations. We derive such equations for three fundamental objects of economic dynamics – lifetime reward functions, Bellman equations and Euler equations. We estimate the decision functions on simulated data using a stochastic gradient descent method. We introduce an all-in-one integration operator that facilitates approximation of high-dimensional integrals. We use neural networks to perform model reduction and to handle multicollinearity. Our deep learning method is tractable in large-scale problems, e.g., Krusell and Smith (1998). We provide a TensorFlow code that accommodates a variety of applications.


Live Interactive Notebook

This material includes a Jupyter Notebook version. You can directly launch and interact with the Notebook within your browser using MyBinder via the "Launch" button(s) below.

Binder badge logo

Material Source Code

Econ-ARK materials are open source and available to view and clone from GitHub.

View on GitHub

How to Execute this Notebook (with conda)

Install miniconda on your computer

  1. Open a Terminal (MacOS) or the Anaconda Prompt (Windows)
  2. At a command line, change the working directory to the one where you want to install
    • On MacOS/unix, if you install in the /tmp directory, the repo will disappear at reboot:
    • cd /tmp
  3. git clone --recursive
  4. cd deep-learning-euler-method-krusell-smith
  5. conda env create -f ./binder/environment.yml --prefix ./condaenv
    • This creates ./condaenv inside your clone of the repo, containing dependencies.
  6. conda run --prefix ./condaenv pip install jupyterlab
  7. conda run --prefix ./condaenv jupyter-lab


Edit metadata