Incorporating matlab function into dynare

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.

Incorporating matlab function into dynare

Postby diatrochoi » Wed Jul 30, 2014 10:59 pm

Hi

I'm trying to use matlab to solve for the steady state and then use those steady state values as initial value in the dynare file.

My model_steadystate.m is as exactly as follows:

syms x1 x2 x3 x4 x5 x6 x7 x8 x9 x10 x11 x12 x13
h=solve(EQ1,EQ2...EQ13)
c1=h.x1(1)
c2=h.x2(1)
...
G=h.x13(1)

The corresponding part in my model.mod file is as follows:
model;
...
end;
model_steadstate.m; //the parameter values are passed from .mod to .m file from here I believe
initval;
c1=h.x1(1)
c2=h.x2(1)
...
G=h.x13(1)
end;

steady;
check;

However, I get "ERROR: model.mod: line 69, col 5: character unrecognized by lexer" (line 69 is the line c1=h.x1(1) in the dynare file) when I run the dynare file. How should I correct this? Is it because I'm not calling the .m file from the .mod file correctly?

Thanks
diatrochoi
 
Posts: 14
Joined: Tue Jul 08, 2014 10:45 pm

Re: Incorporating matlab function into dynare

Postby jpfeifer » Thu Jul 31, 2014 7:36 am

To cut the long story short: if you have a file to compute the steady state values, do not use initval, but write a full-fledged steady state file. An example is in Dynare 4.4.2 for the NK_baseline.mod. You just need to copy your steady state computation file in between the header and footer of that file and rename the file according to the naming conventions.
------------
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: Incorporating matlab function into dynare

Postby diatrochoi » Thu Jul 31, 2014 6:29 pm

I got it to run. But everytime the steady state file crash, the whole process is terminated. Im testing the model with 4 loops for 4 parameters. Is it possible to make it such that if 1 set of parameter values causes crash, the program moves on with the next set rather than terminating? (Im using to solve() function of matlab for my steady state file)

Thanks
diatrochoi
 
Posts: 14
Joined: Tue Jul 08, 2014 10:45 pm

Re: Incorporating matlab function into dynare

Postby jpfeifer » Fri Aug 01, 2014 5:56 am

Set noprint in stoch_simul to 1 to prevent Dynare crashing on errors. stoch_simul will then return an error code in info that can be used in an if-clause: http://www.dynare.org/phpBB3/viewtopic.php?f=1&t=4891
------------
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


Return to Dynare help

Who is online

Users browsing this forum: No registered users and 5 guests