Skip to main content

Solve nonlinear perfect foresight models with heterogeneous agents

Project description

Solve nonlinear heterogeneous agent models using automatic differentiation

https://img.shields.io/badge/GitHub-gboehl%2Feconpizza-blue.svg?style=flat https://github.com/dfm/emcee/workflows/Tests/badge.svg https://readthedocs.org/projects/econpizza/badge/?version=latest https://badge.fury.io/py/econpizza.svg

Econpizza is a framework to solve and simulate fully nonlinear perfect foresight models, with or without heterogeneous agents. A parser allows to express economic models in a simple, high-level fashion as yaml-files. Generic and robust routines for steady state search are provided.

The baseline method for representative agent models builds on the shooting methods of, e.g., Boucekkine (1995) and Juillard (1996). It is faster and more reliable than the nonlinear solver in dynare due to the use of a Newton method in combination with automatic differentiation and efficient jacobian decompositions. Nonlinear perfect-foresight transition dynamics can - even for large-scale nonlinear models with several occassionally binding constraints - be computed in less than a second.

The package can solve nonlinear models with heterogeneous agents, such as HANK models with portfolio choice. Steady state and nonlinear impulse responses (including, e.g., the ELB) can typically be found within a few seconds. The approach to deal with heterogeneity extends the Sequence-Space Jacobian method (Auclert et al., 2022, ECMA) to fully nonlinear models by iteratively using jacobian-vector producs to construct the inverse jacobian during each Newton iteration. This not only allows to study the dynamics of aggregate variables, but also the complete nonlinear transition dynamics of the distribution of assets across agents.

The package builds heavily on automatic differentiation via JAX.

A central philosophy of this package is to consequently separate the low-level routines for model solution (which is what happens under the hood) from model specification (via a yaml file) and the high-level interface for model simulation and analysis (what the user does with the model).

A model parser allows for the simple and generic specification of models (with or without heterogeneity) in yaml format.

Documentation

The documentation and some tutorials can be found here.

Installation

Installing the repository version from PyPi is as simple as typing

pip install econpizza

in your terminal or Anaconda Prompt. Alternatively, the most recent version from GitHub with some experimental features can be installed via

pip install git+https://github.com/gboehl/grgrlib
pip install git+https://github.com/gboehl/econpizza

Note that the latter requires git to be installed.

Installation on Windows

Econpizza needs JAX to be installed. This is not a problem for MacOS and Linux, but the time for JAX to fully support Windows has not yet come. Fortunately, there is help out there (see this link for the somewhat cryptic original reference). To install JAX, run

pip install "jax[cpu]===0.3.20" -f https://whls.blob.core.windows.net/unstable/index.html --use-deprecated legacy-resolver

prior to installing Econpizza. Econpizza should then run just fine (proof).

In case you run into an error with ptxas (like in this case), a workaround is to disable CUDA by running the following before importing econpizza or JAX:

import os; os.environ["CUDA_VISIBLE_DEVICES"] = "-1"

References

econpizza is developed by Gregor Boehl to simulate nonlinear perfect foresight models. Please cite it with

@Misc{boehl2022pizza,
title         = {Econpizza: solving nonlinear heterogeneous agents models using machine learning techniques},
author        = {Boehl, Gregor},
howpublished  = {\url{https://econpizza.readthedocs.io/_/downloads/en/latest/pdf/}},
year = {2022}
}

For the Boehl-Hommes method: Boehl and Hommes (2021). Rational vs. Irrational Beliefs in a Complex World. IMFS Working papers

@techreport{boehl2021rational,
title         = {Rational vs. Irrational Beliefs in a Complex World},
author        = {Boehl, Gregor and Hommes, Cars},
year          = 2021,
institution   = {IMFS Working Paper Series}
}

I appreciate citations for econpizza because it helps me to find out how people have been using the package and it motivates further work.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

econpizza-0.4.2.tar.gz (1.0 MB view details)

Uploaded Source

Built Distribution

econpizza-0.4.2-py3-none-any.whl (459.5 kB view details)

Uploaded Python 3

File details

Details for the file econpizza-0.4.2.tar.gz.

File metadata

  • Download URL: econpizza-0.4.2.tar.gz
  • Upload date:
  • Size: 1.0 MB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.10.9

File hashes

Hashes for econpizza-0.4.2.tar.gz
Algorithm Hash digest
SHA256 31d2e3793a53f8d0eb99a7f0fb18b7ef29cbabe7f11bd3d24ae77f50c70c1f94
MD5 d6a3893ad881046bfed8c6f08f6cc8db
BLAKE2b-256 606f5b9567ce8d0a0b6460295cfca945fd3ef1d91cea505c0ba1b173a752edb3

See more details on using hashes here.

Provenance

File details

Details for the file econpizza-0.4.2-py3-none-any.whl.

File metadata

  • Download URL: econpizza-0.4.2-py3-none-any.whl
  • Upload date:
  • Size: 459.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.10.9

File hashes

Hashes for econpizza-0.4.2-py3-none-any.whl
Algorithm Hash digest
SHA256 e6df436299c8d28e1b75d3567fcf686c6036f0709d040f0b4903e59913ec613a
MD5 8e4b89c7039778802c5123fd5617e409
BLAKE2b-256 70fc231d433dd9245d13f9ea3160d3a85f5e002685d4332a7d28ca56bc77e7aa

See more details on using hashes here.

Provenance

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page