Solve nonlinear perfect foresight models with heterogeneous agents
Project description
Solve nonlinear heterogeneous agent models using automatic differentiation
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 package can solve nonlinear models with heterogeneous agents, such as HANK models with one or two assets and 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.
To solve models with representative agent the shooting methods of Laffargue (1990), Boucekkine (1995) and Juillard (1996) is implemented. It is faster and more reliable than the extended path method in dynare due to the use of automatic differentiation for the efficient jacobian decompositions during each Newton-step. 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 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.
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.25" -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
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file econpizza-0.4.7.tar.gz
.
File metadata
- Download URL: econpizza-0.4.7.tar.gz
- Upload date:
- Size: 744.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.10.9
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 8a4f06b02583f1f5dab3bd3d321785cf563a9351fd7d4142ffedeb137421d76a |
|
MD5 | ffd95ff374427778be2d9a0d8338328c |
|
BLAKE2b-256 | cbb8e185b975232f69f905e7900d4b9a9781fcb60ede7570dae357466475f956 |
Provenance
File details
Details for the file econpizza-0.4.7-py3-none-any.whl
.
File metadata
- Download URL: econpizza-0.4.7-py3-none-any.whl
- Upload date:
- Size: 165.2 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.10.9
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | e922a19a19c89567e77666e552266ae2565722a2820542a2504d8f9e2d464bdf |
|
MD5 | 3878f726927247de7bf5223e601d28c1 |
|
BLAKE2b-256 | f1f88ecfb9448d0eb01de8c6728ea88353f84a1c0e53f59e05fd208688316af0 |