More than 3 dimensions in Discrete Dynamic Programming

Hi all,

Thank you so much for the awesome python library and the lectures. They’ve helped me IMMENSELY.
I’m currently working on a dynamic problem, but it has both a state variable and price shocks in every period. This would mean that the reward and transition matrices should be a larger dimension than is currently allowed by the DP solver, is that correct? Is there some way to implement this with the library?

Thank you

Hi @Aleksandr_Michuda, glad to hear that the libraries have been useful to you :slightly_smiling_face::+1:

Which routines are you talking about? These bad boys?

Well, I think you could work with any dimension in principle. For example, a matrix can be stacked into one long column vector. Following that kind of idea, you need to specify a mapping from D dimensions down to 1 dimension and back again. Try to think of a way to enumerate (count) all your state elements.

Hope that helps…

Indeed it does! That’s the approach I decided to take, although I haven’t been able to figure out a nice way to go from D dimensions to 1, though. I was thinking of using dictionaries, or perhaps some sort of multi-index pandas dataframe, but I settled so far on doing a hacky matrix index approach (going through the transition matrix by some amount which is equal to the number of states I created for the other state, if that makes sense) .

That approach, however, is fraught with danger and I’d totally be open to tips on that.

In any case, thanks for the library, you’re computational econ textbook got me into Python in the first place, so cheers!

Glad to hear it :-)

I’m working on a new book, joint with Tom, that you can get a very preliminary version of here:

(Look for notes.pdf)

Good luck with your studies.