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

This forum is closed. You can read the posts but cannot write. We have migrated the forum to a new location where you will have to reset your password.
Forum rules
This forum is closed. You can read the posts but cannot write. We have migrated the forum to a new location (https://forum.dynare.org) where you will have to reset your password.

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

Postby Demetrio.Rodriguez » Tue Jul 21, 2015 9:03 am

Dear Professor Pfeifer,

here are the files you requested. :)

Best,
Demetrio
Attachments
clear_all_bug.zip
testcase for the issue
(14.73 KiB) Downloaded 147 times
Demetrio.Rodriguez
 
Posts: 1
Joined: Wed Jun 24, 2015 5:09 pm

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

Postby jpfeifer » Tue Jul 21, 2015 9:09 am

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.
------------
Johannes Pfeifer
University of Cologne
https://sites.google.com/site/pfeiferecon/
jpfeifer
 
Posts: 6940
Joined: Sun Feb 21, 2010 4:02 pm
Location: Cologne, Germany

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

Postby JerseyBoy1910 » Mon Nov 23, 2015 7:21 pm

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
JerseyBoy1910
 
Posts: 2
Joined: Wed May 29, 2013 8:08 pm

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

Postby jpfeifer » Tue Nov 24, 2015 7:10 pm

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_.
------------
Johannes Pfeifer
University of Cologne
https://sites.google.com/site/pfeiferecon/
jpfeifer
 
Posts: 6940
Joined: Sun Feb 21, 2010 4:02 pm
Location: Cologne, Germany

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

Postby POLICYQUANTSPHD » Sun Dec 11, 2016 5:17 pm

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,
POLICYQUANTSPHD
 
Posts: 2
Joined: Sun Dec 11, 2016 5:10 pm

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

Postby POLICYQUANTSPHD » Sun Dec 11, 2016 5:33 pm

Problem solved.

Thank you anyhow! Merry Christmas to the Dynare Community!
POLICYQUANTSPHD
 
Posts: 2
Joined: Sun Dec 11, 2016 5:10 pm


Return to Dynare help

Who is online

Users browsing this forum: Google [Bot] and 6 guests