Page 1 of 1

Incorporating matlab function into dynare

PostPosted: Wed Jul 30, 2014 10:59 pm
by diatrochoi
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

Re: Incorporating matlab function into dynare

PostPosted: Thu Jul 31, 2014 7:36 am
by jpfeifer
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.

Re: Incorporating matlab function into dynare

PostPosted: Thu Jul 31, 2014 6:29 pm
by diatrochoi
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

Re: Incorporating matlab function into dynare

PostPosted: Fri Aug 01, 2014 5:56 am
by jpfeifer
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