CompEcon in Python

Last couple of years I’ve been working from time to time on porting from Matlab to Python the CompEcon toolbox that comes with the textbook by Miranda and Fackler (2002).

A major difference in this implementation is that much of the code is object-oriented, providing classes to represent:

  • Interpolation bases: Chebyshev, Spline, and Linear
  • Dynamic programming models: with discrete and/or continuous state and action variables
  • Nonlinear problems
  • Optimization problems

Some other differences are:

  • The solution of dynamic models is returned as a pandas dataframe, as opposed to a collection of vectors and matrices.
  • Some additional functionality is included, most notably for Smolyak interpolation.
  • Basis objects are callable, so they can be used to interpolation function by “calling” the basis.

Although I haven’t finished this task, there is some progress; to see what is available so far, check these Jupyter notebooks to see which demos have already been replicated with the Python version.

I have shared the source code in Github for some time now, but to make it easy to final users to start using the toolbox right away, I have uploaded it to PyPI. Assuming you have pip on your computer –as will be the case if you’ve installed Anaconda–, you can install the latest release of compecon by typing:

pip install compecon

at a terminal point.

Leave a Reply

Your email address will not be published. Required fields are marked *