Page 4 of 4
Re: Loop over parameters
Posted:
Thu Apr 06, 2017 4:10 pm
by zhanshuo
HI, everyone, I wonder if there is now a more convenient way to loop over parameters using dynare 4.5(unstable).
If there is , I am so honored if you let me know.
and I am learning about the code above, and have some questions?
first_time = 1;
for i=1:length(rhos)
if first_time
set_param_value('rho',rhos(i));
dynare your_mod_file_here noclearall;
first_time = 0;
else
set_param_value('rho',rhos(i));
info = stoch_simul(var_list_);
if info;
disp(['Computation fails for rho = ' num2str(rho)]);
end;
end
end
1, why should "info=1" be judged? so when info=1, the model is wrong?
2, " info = stoch_simul(var_list_);" Since the "var_list_" is sometime empty,how should I do?
Re: Loop over parameters
Posted:
Thu Apr 06, 2017 4:30 pm
by zhanshuo
Another question is, how could I save results of every loop, using the above code?
Thanks a lot!
Re: Loop over parameters
Posted:
Thu Apr 06, 2017 5:19 pm
by jpfeifer
1. Yes, that is still the proper way to do it.
2. info is the error code from stoch_simul. If info is not 0, the model could not be solved (for various possible reasons). It's not necessarily the case that the model is wrong, but rather that the particular parameter draw in the loop is problematic.
3.
- Code: Select all
var_list_
will typically be created by Dynare in the first run and you do not need to set it in this case. If in your application you need to set it manually, you should be able to set it to an empty character array
- Code: Select all
var_list_ = char();
4. That depends on what you want to save. To put the results from different runs into a cell array, you could add
- Code: Select all
results_cell{i}=oo_;
within the loop.
Re: Loop over parameters
Posted:
Mon May 08, 2017 12:10 pm
by Zen
Hi everyone
If I'm not mistaken, resol only works for a first- and second-order approximation of the model, but not for a third. Is there another function which does the same as resol, but also works with a third-order approximation?
Many thanks
Re: Loop over parameters
Posted:
Mon May 08, 2017 12:22 pm
by jpfeifer
It also works for third order. But you have to make sure
- Code: Select all
options_.qz_criterium
Has been set
Re: Loop over parameters
Posted:
Mon May 08, 2017 2:39 pm
by Zen
Thanks for your quick answer. I had also to set manually option_.k_order_solver = 1 in order to get any results.
Re: Loop over parameters
Posted:
Thu May 11, 2017 1:06 pm
by PPilo
Hello
I am simulating a very simple RBC model and would like to let the constant tax rate vary. I can do this manually by just resetting the paramter every time I run the code. However, is it possible to perform this automatically? Say, I want the tax rate to increase by 0.1 every time (from 0 to 0.5).
Can I do this in my mod-file or do I have to write a m-file?
Thanks a lot,
PPilo
Re: Loop over parameters
Posted:
Sun May 14, 2017 10:13 am
by jpfeifer
What is the command you want to loop over, stoch_simul?