Bookmark and Share

Notice: On April 23, 2014, Statalist moved from an email list to a forum, based at

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

RE: st: code for dynamic programming

From   Nick Cox <>
To   "''" <>
Subject   RE: st: code for dynamic programming
Date   Fri, 2 Mar 2012 14:41:01 +0000

I agree with a general view that one should use other software when more appropriate than Stata; who doesn't? 

But I disagree at least partly with the detailed comments here, which in my judgement are expressed too dogmatically. 

What is that makes MATLAB [sic], R or C++ more appropriate for this? It may well be a good supply of similar example code. But I don't think it is the nature of any of these languages. I've already given a real example in a publicly available package of a Stata program with a dynamic programming algorithm at its core. I had no difficulty translating that from other languages because of any of Stata's language quirks. 

It seems that no-one has solved Osei's problem previously in Stata, and that no-one is willing to chase up the literature, find out the equations and write a Stata program for that program, but that's still not a limitation in principle. 


Partho Sarkar

Osei, from your post it is not clear to me exactly  what you are
trying to do- I think you would get more help if you explain that
clearly.  Some remarks & suggestions below , for what they are worth:

If it is an exercise in simulating/solving a dynamic programming (DP)
problem  as such (e.g., inter-temporal utility maximization of a
consumer, which is what your post suggests) , then Stata is simply not
the tool for it- Stata is by definition geared toward *statistical*
problems.  Sure, like any statistical package, it uses some
maximization algorithms, e.g., for maximum likelihood estimation, but
these are by their nature specific to that particular class of
problem.  (It might be possible to somehow manipulate   these to told
to solve a DP problem, but it doesn't seem very promising!)

For DP as such, which is a *mathematical/computational* problem, there
are many programs available in other languages/packages- Matlab would
be my first choice (or R or C++ ).  Have a look at (the
Matlab section) -there are many other sources for DP algorithms in
Matlab.  ( It is some time since I have worked on this type of
exercise, so you might find more upto date information. )

On the other hand, if you are trying to *estimate* a dynamic discrete
choice model, then that is a *statistical* problem in which you can
utilize Stata's estimation tools (the key here would be  formulating
the estimation problem/equations properly, and not the algorithm).  I
have no experience of this, but if you search around, I am sure you
will be able to find some sources.  E.g., just at random,I found a
link to this recent paper :

From	  Osei Kuffour Wiafe <>

I'm quite new to stata and I need help with coding a backward recursive
problem. It is in the form of the Epstein-Zin utility and similar to the
Bellman equation. I'd appreciate any other dynamic programming code which
would relate to what I am doing. That should give me a clue to finding my
solution. For now I have no idea where to begin!

*   For searches and help try:

© Copyright 1996–2017 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   Site index