Schmitt-Grohe and Uribe 2004b replicate in dynare

Hi all

I am trying to replicate the standard growth model as in SGU 2004b. (
However when I am writing my dynare code, although I can replicate exactly the steady state values as they appear in the paper, (−0.8734, −1.7932, 0) I cannot get the same values for the the coefficients of the linear terms gx, hx or the coeefficients of the quadratic terms gxx, hxx etc. (i get values only for some coefficients)

Apparently I am writing something in the wrong way which I cannot figure out. I attach the mod file
I would appreciate any help.
SGU_neoclassical2.mod (695 Bytes)


If I remember correctly, SGU do not use the same representation of the reduced form model. Dynare, as you can see in the reported results for the policy rules and transition equations, expresses the control as a function of the endogenous state variable (time t-1), the exogenous states at time t-1 and the innovations at time t, while SGU writes the control variables as a function of the endogenous states and the exogenous states at time t. For instance, for consumption in an RBC model, Dynare reduced form is something like:

c_t = a0 + a1k_{t-1} + a2a_{t-1} + a3*e_t

while SGU reduced form looks like (also note that they do not use the same timing convention for the endogenous states but this is irrelevant wrt your question):

c_t = a0 + a1k_{t} + b2a_{t}

This may explain the differences you observe. You should compare the IRFs or asymptotic moments instead.


Dear Stephane

Thanks a lot for the quick reply. I will test your suggestion

Indeed the state space representation of SGU differs from Dynare representation.
But I think there must be a way (meaning that if you right a proper dynare code) to replicate the results exactly.

For example in the Technical Appendix (see the attached p. 136) of * Andreasen, Martin M., Jesús Fernández-Villaverde and Juan F. Rubio-Ramírez (2013): “The Pruned State-Space System for Non-Linear DSGE Models: Theory and Empirical Applications”*, the authors say that under the correct notation, one can implement exactly SGU in dynare.
Thanks again
Appendix_Pruning.pdf (602 KB)

You have a simple timing mistake in technology in the Euler equation. For a running replication file, see

Thanks a lot.Problem solved!!

p.s: Looking at you replication file, is there any reason you include an additional block with the steady state equations?? I haven’t seen it before in other mod files or in any documentation.

Defining a steady_state_model-block is more efficient than an initval-block if you know the analytical steady state. I try to use this whenever I can compute the steady state. Dynare 4.4 will even contain an example of this in the examples folder.

If you are interested in replication this might be of interest to you: ReplicationWiki


Though an old post, I have a problem in replication.

When using persistence of technology not equal to zero in Dynare , based on the replication file for Schmitt-Grohe available at - ‘a’ is also a state and we have additional terms in hx, gx, hxx and gxx. These terms are not there when replicating the matlab code from those authors. Is there any discrepancy in my implementation ? Is there any way I can reconcile these results.
Any help is appreciated.


I am not sure I understand your question. If you have persistence of a, you will be getting a lagged value for a that does not drop out of the model. This will add a state variable in Dynare. In SGU’s notation, the exogenous processes are handled somewhat differently. Dynare allows more generic shock processes than the linear structure of SGU (2004)'s equation following equation (1).
Because Dynare reports decision rules somewhat differently the a(-1) shows up.

Hi Johannes,

Thank you for the response. Let me give more details on the question. Thank you for confirming my doubts - there is a difference in SGU and dynare’s notation.

To replicate SGU’s paper with zero persistence, I use the replication file in your repository. The results are same as suggested by you earlier in this post.

However, if I want to use nonzero persistence, I understand I have to modify the SGU’s notation to get a dynare equivalent notation. I follow the advise in the Technical Appendix (pg. 138) of Andreasen, Martin M., Jesús Fernández-Villaverde and Juan F. Rubio-Ramírez (2015): “The Pruned State-Space System for Non-Linear DSGE Models: Theory and Empirical Applications”. I am attaching the dynare code I am using (this is referred from the replication code and just the persistence is changed) and also the modification I did in SGU’s model file based on the suggestion in the Appendix.
As you can see in compare.csv, the decision rules are different.

I just want to confirm if what I did is incorrect or I have to modify the decomposition code or this is how it is supposed to be and I should compare simulated results.

Thank you again.
compare.pdf (15.2 KB)
SGU2004_4.mod (3.14 KB) (11.3 KB)
Andreasen2016.pdf (1010 KB)

Why did you introduce a new state variable in the SGU code?

Dear Johannes,

Thank you for your response, about adding the state variable. You may ignore my question.
I have been able to match the simulated series and understand more clearly the way state variables enter in Dynare and SGU notations.


I have implemented a slightly modified version of SGU04. To compare the results, I also implemented the model in dynare. All the coefficients are identical except for the ones wich are bold below.

SGU Output:
gxx(:,:,3) =
-0.0109 -0.0876 -0.0880
hxx(:,:,3) =
0.1434 0.0876 0.0880

Dynare Output: c k
epsilon ,epsilon 0.059474 0.724165.

Can someone explain me why these coefficients on A^2 (or epsilon^2 in dynare) do not match?


neoclassical_model_ss.m (1.14 KB)
neoclassical_model_run.m (1.89 KB)
neoclassical_model.m (1.76 KB)
sgu_mod.mod (801 Bytes)

Has no one an idea?

Hi Hmz,

From my experience it is a better idea to compare the simulated series and not the decision rule.
As we take persistence as non zero (which is not the case in SGU, they take rho=0), the decision rules will be different.

If you look closely the solution method is different for SGU (they explicitly differ in state and control variables) and Dynare doesn’t. This leads to difference in decision rules (if I am correct mainly for epsilon and da).

In my problem, I extended my matlab program and compared the simulated series (non-pruned) and they matched.

Hope this helps.

They do not match because of the difference in timing conventions. You have that

SGU treat A as an exogenous state and present the response to A. Dynare splits A into two states:


Because of this, you are looking at different objects.

Thanks for the responses.

Doesn’t this mean that actually the x_t SGU define has to be x_t = [k_t; log(A_{t+1})] rather than x_t = [k_t; log(A_t)] as it is on p. 758?

No. At time t, A_t is predetermined (because exogenous). A_t+1 is not yet know and therefore associated with an expectational error.