Page 2 of 2

Re: Linking Dynare to Matlab code

PostPosted: Sun Jul 12, 2015 8:01 am
by jpfeifer
Theory imposes that in your model the growth rate of any variable is just
Code: Select all
growth

(or a transformation of this like (1-capitalshare)*growth)). Thus, what you should match is the average z. Alternatively, you can define the model-implied growth rate of any variable and match this mean growth rate to the one in the data. This is a simple matter of defining the correct observation equation in undemeaned first differences.

Re: Linking Dynare to Matlab code

PostPosted: Sun Jul 12, 2015 9:11 pm
by macroresearch123
Thanks for the reply (again)! I don't follow entirely though? Indeed, the model implies a growth rate -- for example, two separate shock processes to X and Z in the production function
Y= F((Ax*X),(Az*Z))

where F is a CES. But when you compute the growth rate of the variables, e.g.,
Z_grow = (Z_t - Z_t-1)/Z_t-1
you end up getting an average of zero when averaging over the time series.

Is there an example you could point to that would make it more concrete? All the examples in Dynare I've seen just focus on business cycle fluctuations, not long run growth.

Re: Linking Dynare to Matlab code

PostPosted: Mon Jul 13, 2015 7:54 am
by jpfeifer
Take a look at section 5 of my Guide to Observation Equations. There you can see how to transform a growing model into a detrended one that can be entered into Dynare.

Short outline: Write e.g. actual output Y as detrended output y times the trending TFP X:
Code: Select all
Y=y*X;

Enter the model in detrended form. That will include a process for the growth rate of X:
Code: Select all
mu_x=X-X(-1)

The growth rate of Y is then given by
Code: Select all
d_Y=y-y(-1)+mu_x

The mean of d_Y is the mean of mu_x, which is non-zero.

Re: Linking Dynare to Matlab code

PostPosted: Sun Jul 19, 2015 3:54 am
by macroresearch123
Hey Johannes,

I thought it would be worth posting here for some recurring issues that might be relevant for others too. Just FYI for readers, the "simul_" command is key here -- feed in the long run growth after recovering the decision rules in a model without long run growth.

The main problem is that dynare continues to either not find a steady state or violate rank condition when iterating over different parameters. Other than adjusting the bounds when using fmincon to conduct the SMM, I'm not sure what other alternatives there are? Every time dynare stops due to lack of a steady state or violations to the rank condition, the moment conditions arent necessarily satisfied, so it's NOT as if it stops at a location that's almost ideal.

Looking forward to your tips!

Re: Linking Dynare to Matlab code

PostPosted: Sun Jul 19, 2015 12:38 pm
by jpfeifer
What do you mean with the first part? It sounds as if your rational expectations model solved under no growth is fed with a shock process that is inconsistent with rational expectations.

REgarding the problem you describe, you need to filter these cases out where no unique and bounded solution is found (for whatever reason that happens). In this case, Dynare, or more precise resol.m or stoch_simul.m will return an error code that allows assigning a penalty for these parameter values to steer the optimizer to a different parameter value.

Re: Linking Dynare to Matlab code

PostPosted: Mon Jul 20, 2015 6:29 pm
by macroresearch123
Hmm, but if Dynare computes the decision rules, then other shocks can be plugged in since the policy function has already been solved?

And indeed I took after your suggestion in that paper where I filtered the results, but maybe I didn't do it 100% right. Here's what I wrote below -- there are 12 parameters I'm estimating and two shock processes.

[oo_.dr,info,M_,options_,oo_] = resol(0,M_,options_,oo_); %run model solution in Dynare

if info %solution was not successful
fval=10e6+sum([xopt(1),xopt(2),xopt(3),xopt(4), xopt(5), xopt(6), xopt(7), ...
xopt(8), xopt(9), xopt(10), xopt(11), xopt(12)].^2); %return with penalty
else
shocks=[oo_.exo_simul(:,1)+P.ga oo_.exo_simul(:,2)+P.ge];

Re: Linking Dynare to Matlab code

PostPosted: Tue Jul 21, 2015 9:25 am
by jpfeifer
Rational expectations means that the assumed shock distribution is the correct one. If you feed in shocks yourself, you must make sure this distribution is consistent with the assumptions (0 mean, variance sigma^2). Having a trend may not be consistent with RE as agents expect shocks to be mean 0.

Re: Linking Dynare to Matlab code

PostPosted: Tue Jul 21, 2015 8:15 pm
by macroresearch123
Got it, thanks for pushing on it -- completely agreed now just not sure the alternative -- am looking into using just one growth rate so that I can detrend the technology component easily. Any idea what might have been going wrong with the SMM -- that is, why it would stop even after putting in that resol command?

Edit: I think the best resolution is to just make sure that a steady state computed from another solver is passed through to Dynare each time iterates a new set of parameters. I'll keep working on it!