PyMacroFin Documentation¶
PyMacroFin is dedicated to solving a common structure of general equilibrium problems found in macro-finance. In particular, the package is built for problems formulated in continuous-time with one to two state variables.
Installation¶
PyMacroFin is available on PyPi. Install with the following command [1]:
pip install PyMacroFin
You can then import and use objects from the package as follows:
from PyMacroFin.model import macro_model
from PyMacroFin.system import system
import PyMacroFin.utilities as util
Note that if you are using Anaconda with Python, you should run the installation command from the Anaconda Prompt.
Current Development Stage¶
The library is currently in an beta phase. If you have a question, please ask the question on stackoverflow, including the package name (PyMacroFin) in the question title. If you find a bug, please use the issues feature on GitHub and include a minimal working example that reproduces the error. Please also use the issues feature on GitHub for feature requests, comments, and suggestions. If you would like to contribute, please contact the primary developer: damon.petersen [at] chicagobooth.edu.
Citation¶
If you use the package for a publication or project, please cite PyMacroFin as follows:
@software{pymacrofin,
author = {Adrien d'Avernas and Damon Petersen and Quentin Vandeweyer},
title = {Macro-financial Modeling in Python: PyMacroFin},
url = {https://adriendavernas.org/pymacrofin/index.html},
version = {0.0.1},
date = {2021-11-18},
}
@article{solutionmethod,
author = {Adrien d'Avernas and Damon Petersen and Quentin Vandeweyer},
title = {A Solution Method for Continuous-Time General Equilibrium Models},
url = {http://www.adriendavernas.com/papers/solutionmethod.pdf},
date = {2021-11-18},
}
Getting Started¶
The recommended way to get started with PyMacroFin is to go over examples, found here. There are two examples, one for a one-dimensional problem and another for a two-dimensional problem. For syntax and detailed documentation on classes, functions, and other objects, the module documentation pages will be useful. The general overview below is also a valuable resource with a concise description of solution methods employed with a link to a paper with further detail on the solution methods.
General Overview¶
The core of the library is a macro_model
class to which the user assigns
parameters, endogenous variables, intermediate variables, and equations. The user
specifies a 2-dimensional grid to define the state space. The user specifies a system
of equations (potentially nonlinear) to solve to determine the values of the endogenous
variables (i.e. from market clearing and optimality conditions). The model uses a finite
difference scheme across the grid both for the endogenous system of equations and for a
dynamic component that solves backward in time toward equilibrium according to the following
equation:
where \(X\) is the system state, \(m\) is the number of state variables, \(\mu_i\) and \(\sigma_i\) are drifts and volatilities corresponding to the laws of motion of state variables, and \(F(X,t)\) is a variable whose equilibrium value can be found by iterating backward in time to convergence (from an initial guess). For more detail on the solution procedure and model structure accepted, see this paper.
The model
module documentation goes over the primary model inputs. The parameters
module documentation
describes setting parameter values as well as the many options available for the package. The system
module
documentation goes over constraint systems, the kolmogorov
module goes over stationary distribution calculation,
and the dash_utils
module documentation describes the accompanying visualization application.