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

Dear Professor Pfeifer,

here are the files you requested. :slight_smile:

Demetrio (14.7 KB)

Your global variable operates in a different workspace. In your case, add

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

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:

Please have a look at the replication file for Born/Pfeifer (2014): “Risk Matters: A comment” at At the end of the mod-file, it provides a full framework for running a loop over resol() and simult_.

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,

Problem solved.

Thank you anyhow! Merry Christmas to the Dynare Community!