# Second order approximation for large model and Ramsey proble

We are solving Ramsey policy for a New Keynesian DSGE model with heterogeneous agents. We used to employ Schimitt-Grohe Uribe’s code for deriving and solving Ramsey equilbiurm. However, this time due to large size of model (which due to heterogeneity), we get ‘out of memory’ warning when trying to get second order solution. The problem is that SGU’s code (e.g., gxx_hxx.m, line 35) generates a matrix when solving second order terms which is too big to be stored in Matlab. Then we are now considering solving this Ramsey problem using Dynare. My questions are:

1. Has anyone else encountered this kind of ‘out of memory’ problem when using SGU orginal code? We have total number of 120 equations (52 states) in Ramsey equilibrium. Or does anyone know how to resolve this issue, or if SGU has a modified more efficient version of their code?
2. Would the second order solution solver in Dynare be more efficient than SGU (or Kim et al) solver? In particular, can Dynare solve second order approximation for a large model of 120 equations?
3. We are also looking at multiple instruments in our Ramsey optimal policy problem. Is it possible to do Ramsey problem with multiple instruemnts in Dynare? I came across some posts saying that I may need to use ‘unstable’ version of Dynare. Any advice on this would be very helpful.
By the way, we are looking at distortedsteady state and need to solve a nonlinear Ramsey problem (thus not doing linear-quadratic problem using linearized model).
Any suggestions will be highly appreciated!

I will have to look into your question in more detail when I have more time later. But quickly: SGU have a version of their code working with sparse matrices at columbia.edu/~mu2166/2nd_order/gxx_hxx_sparse.m
Did you try that one? That would save any coversion costs.

Thank you very much for your reply, I am using gxx_hxx_sparse now. However, it seems very slow for a large model and has been running for 24 hours.

How efficient is Dynare compared with SGU original code in solving large scale models? We may still turn to Dynare to solve our model if SGU costs too much running time.

Best wishes,
Xiaoshan

1. Dynare in principle is a lot more efficient than the SGU-codes due to storing the results differently.
2. A second order approximation of 120 equations should be possible.
3. Yes, several instruments work. But you need the unstable version, because of a bug in 4.4.3 (see dynare.org/DynareWiki/KnownBugs)
4. The part with the distorted steady state may currently be a problem. I am still in the process of investigating whether Dynare’s Ramsey returns correct results in this case, see [Ramsey policy is not optimal). If you have a model I can use to test, that would be very helpful. Otherwise, it might take some time.

Hi Johannes,

The dynare code worked for my model. Thanks a lot for your suggestion!

best wishes,
Xiaoshan