Page 1 of 1

Issue #974: Running dynare from inside of a matlab function

PostPosted: Tue Jul 21, 2015 9:03 am
by Demetrio.Rodriguez
Dear Professor Pfeifer,

here are the files you requested. :)

Best,
Demetrio

Re: Issue #974: Running dynare from inside of a matlab funct

PostPosted: Tue Jul 21, 2015 9:09 am
by jpfeifer
Your global variable operates in a different workspace. In your case, add
Code: Select all
global alpha_p;

to your mod-file before your first call to alpha_p and it will work.

Re: Issue #974: Running dynare from inside of a matlab funct

PostPosted: Mon Nov 23, 2015 7:21 pm
by JerseyBoy1910
I am running into a similar problem as that in the above post.

Essentially I am running "dynare xxxx.mod" inside a custom-written Matlab function. The function is supposed to compute the policy functions and then simulate / compute moments of the model using "simult_". Finally it spits out some GMM-based criterion value.

However when I try this and run the initial "dynare xxx.mod", I cannot access the "oo_" or "M_", which I need to run the "simult_()." Matlab says these objects ("oo_, M_") do not exist (when I debug the function). What is going wrong exactly? Any help is much appreciated.

The dynare command I run is:
Code: Select all
dynare xxxxx.mod nowarn noclearall

Re: Issue #974: Running dynare from inside of a matlab funct

PostPosted: Tue Nov 24, 2015 7:10 pm
by jpfeifer
Please have a look at the replication file for Born/Pfeifer (2014): "Risk Matters: A comment" at https://www.aeaweb.org/articles.php?doi=10.1257/aer.104.12.4231. At the end of the mod-file, it provides a full framework for running a loop over resol() and simult_.

Re: Issue #974: Running dynare from inside of a matlab funct

PostPosted: Sun Dec 11, 2016 5:17 pm
by POLICYQUANTSPHD
I m running a mod file inside a .m function, however, when I try to access steady state vars from oo_.steady_state( ) in the .m function (outside of the .mod) , i get an error message. I am trying to pass my steady state values into the .m function and then out of the function to repeat a guess and verify procedure (guessing on parameter values that minimize distance between model Steady state and data targets).

I hope this makes sense. I would appreciate help from anyone who has a simple code to help fix this problem.

Kind regards,

Re: Issue #974: Running dynare from inside of a matlab funct

PostPosted: Sun Dec 11, 2016 5:33 pm
by POLICYQUANTSPHD
Problem solved.

Thank you anyhow! Merry Christmas to the Dynare Community!