I am trying to loop over parameter values for a simple Taylor rule and then perform a stochastic simulation using stoch_simul so that I can extract the mean values for consumption (which will be used in a comparison with a Ramsey policy outcome later on). I run a 2nd order approximation and I get that the mean of consumption is a negative number when the parameter value for inflation takes on a value close to 1.
The loop (that I found on this forum) looks like:
- Code: Select all
phi_ys= 0:0.1:5;
phi_pis = 0:0.1:5;
first_time = 1;
res_alt=cell(length(phi_ys), length(phi_pis));
param_values_alt=cell(length(phi_ys), length(phi_pis));
mean_values_alt=cell(length(phi_ys), length(phi_pis));
for i=1:length(phi_ys)
for j=1:length(phi_pis)
if first_time
set_param_value('phi_y',phi_ys(i));
set_param_value('phi_pi',phi_pis(j));
dynare NK_hysterisis noclearall;
first_time = 0;
else
set_param_value('phi_y',phi_ys(i));
set_param_value('phi_pi',phi_pis(j));
info = stoch_simul(var_list_);
if info ==0;
res_alt{i,j} = oo_;
mean_values_alt{i,j} = res_alt{i,j}.mean(3); % Mean of consumption is the third value in the order.
param_values_alt{i,j} = M_.params;
else
fprintf('model cannot be solved for phi_y=%3.2f and phi_pi=%3.2f\n ',phi_ys(i), phi_pis(j));
end;
end
end
end
The loop works as expected with regards to changing the parameter values properly but the outcome is odd. In the .mod-file I have a "steady_state_model"-block which solves the model without any non-zero residuals so I believe that there is something wrong with the way I perform the stochastic simulations. As far as I've understood it, when the full Dynare routine is used in the first iteration the stoch_simul command in the loop will use the options provided in the stoch_simul included in the .mod-file. The options used are
- Code: Select all
stoch_simul(noprint, nograph, irf=0, pruning, drop=200, replic=1000, order=2);
I am not sure whether it is something I am missing about the stochastic simulation or if there is something else going on.
Help would be much appreciated.