Contains Jupyter Notebooks showcasing the ConSav package.
The main tool in the ConSav package is the ModelClass class with predefined methods for e.g. saving and loading. The main selling point is that it provides an easy interface to calling Python functions jit compilled with Numba, and C++ functions. Each concrete model inherits these methods and then adds methods for e.g. solving and simulating. The simplest full example is the canonical buffer-stock consumption model, see the BufferStockModel notebook.
The DurableConsumptioModel notebook contains more advanced examples. Specifically, it implements the solution methods proposed in A Guide On Solving Non-Convex Consumption-Saving Models. See also the results notebook for this paper.
Turtorial: The DynamicProgramming/ folder contains a simple introduction to both dynamic programming and the ConSav package. If you are new to Python then try out this online course, Introduction to programming and numerical analysis.
To get started:
- Install the ConSav package (requires git):
pip install git+https://github.com/NumEconCopenhagen/ConsumptionSaving
- Clone or download this repository
- Open your notebook of choice
We recommend running the notebooks in JupyerLab. A set of guides on how to install Python and JupyterLab is available here.
The main notebooks are:
- DynamicProgramming/
- BufferStockModel/
- BufferStockModel: Guide on solving and simulating the model
- Example with run file and C++: Advanced examples
- DurableConsumptionModel/
- DurableConsumptioModel: Guide on solving and simulating the model
- Results for A Guide to Solve Non-Convex Consumption-Saving Models (paper)
- G2EGM/
- Python version of the G2EGM algorithm from A General Endogenous Grid Method for Multi-Dimensional Models with Non-Convexities and Constraints, Druedahl and Jørgensen, 2017, Journal of Economic Dynamics and Control, 74 (MATLAB version)
- Tools/
- Linear interpolation: Showcase the linear_interp module
- Optimization: Showcase the numerical optimizer modules
- Upper envelope: Showcase the upperenvelope module
- Numba and C++/
- Working with Numba: Simple Numba examples
- Calling C++: Examples for interfacing to C++
- Using NLopt in C++: Example of using the NLopt optimizers in C++
Additional projects based on ConSav:
- WealthHet: On explaining wealth inequality.