# Linking Dynare to Matlab code

**URL:** <https://forum.dynare.org/t/linking-dynare-to-matlab-code/4779>\
**Category:** Dynare help (legacy posts)\
**Created:** [20 June 2015 07:06 UTC](https://forum.dynare.org/t/linking-dynare-to-matlab-code/4779 "2015-06-20T07:06:31Z")\
**Posts on this page:** 3\
**Page:** 2

<div class="post-metadata">

**Author:** ![macroresearch123](https://forum.dynare.org/letter_avatar_proxy/v4/letter/m/f05b48/32.png) [@macroresearch123](https://forum.dynare.org/u/macroresearch123)\
**Post date:** [20 July 2015 18:29 UTC](https://forum.dynare.org/t/linking-dynare-to-matlab-code/4779/21 "2015-07-20T18:29:21Z")

</div>

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](http://P.ga) oo\_.exo\_simul(:,2)+[P.ge](http://P.ge)];

---

<div class="post-metadata">

**Author:** ![jpfeifer](https://forum.dynare.org/user_avatar/forum.dynare.org/jpfeifer/32/5044_2.png) [@jpfeifer](https://forum.dynare.org/u/jpfeifer)\
**Post date:** [21 July 2015 09:25 UTC](https://forum.dynare.org/t/linking-dynare-to-matlab-code/4779/22 "2015-07-21T09:25:23Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![macroresearch123](https://forum.dynare.org/letter_avatar_proxy/v4/letter/m/f05b48/32.png) [@macroresearch123](https://forum.dynare.org/u/macroresearch123)\
**Post date:** [21 July 2015 20:15 UTC](https://forum.dynare.org/t/linking-dynare-to-matlab-code/4779/23 "2015-07-21T20:15:54Z")

</div>

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!

[Previous page](https://forum.dynare.org/t/linking-dynare-to-matlab-code/4779.md?page=1)
