Page 1 of 1

changing Dynare order outside the .mod file

PostPosted: Fri Oct 10, 2014 7:32 am
by ghazika1
Hi,

I need to do a grid search for a range of parameters, for which I use
Code: Select all
set_param_value('param', value(i));
stoch_simul(var_list_);


but in each iteration, I need to get the derivatives both for the first and third order expansions. That is, for each parameter, I need to get two sets of derivatives (for 1st and 3rd order). Could you please let me know if/how I can do this.
Note: I have already tried to just change the order using
Code: Select all
options_.order = 3;
, but I wasn't successful.

Many thanks in advance,
Soroush

Re: changing Dynare order outside the .mod file

PostPosted: Fri Oct 10, 2014 9:18 am
by jpfeifer
What do you mean? Which error do you get? You need to run Dynare at order 3 first. That is, you use
Code: Select all
stoch_simul(order=3)

in the mod-file and call it with
Code: Select all
dynare yourmodfile noclearall

at the beginning of your code. This will create all required files. Then you can switch between first and third order by setting
Code: Select all
options_.order

Re: changing Dynare order outside the .mod file

PostPosted: Fri Oct 10, 2014 10:18 am
by ghazika1
Thank you very much jpfeifer, it works now. As you correctly guessed, I was using the wrong order. Just a quick follow up question, and please don't bother if there is not a good answer for that. When I tried the following piece of code:
Code: Select all
dynare afr0test
f_11_3 = [oo_.dr.ghx oo_.dr.ghu];

stoch_simul(var_list_);
f_11_test3 = [oo_.dr.ghx oo_.dr.ghu];

sum(vec(f_11_test3 -f_11_3)) %showing if the first order derivatives have changed


to see if running the same file from outside (i.e. using the stoch_simul) has changed the first-order derivatives, I got 2.14e-6. Admittedly, I have a lot of variables in the models (66 variables), which means each derivative is just changed a tiny bit, but do you know why there is a change in the first place?

Thanks again.

Re: changing Dynare order outside the .mod file

PostPosted: Fri Oct 10, 2014 11:50 am
by jpfeifer
Hard to tell without the model. Do you use a steady state file?
In any case, a better test is
Code: Select all
max(max(abs(f_11_test3 -f_11_3)))