Some questions on Loop over parameters

There are two issues here:

  1. phi is entering your steady state computations for the initial values. If you run a loop without updating initval, Dynare converges to a different steady state. Given the presence of multiple steady states, you should use an analytical steady state to select the correct/intended one.
  2. Your error handling is wrong. In Dynare 5, it should be
stoch_simul(order=2, irf=0, ar=0, nofunctions, hp_filter=1600);

para_rigid = 0.8:0.1:0.9;
for i=1:length(para_rigid)
    set_param_value('phi',para_rigid(i));
    set_dynare_seed('default');
    [info, oo_] = stoch_simul(M_, options_, oo_, var_list_);
    if info(1)
       fprintf('Here there is an error with this combination of paramters!\n');    
    else
       para_pos=strmatch('ye',M_.endo_names,'exact');
       variance.para(i)=oo_.var(para_pos,para_pos);
       mean.para(i)=oo_.mean(para_pos);      
    end
end
    disp(['Results of loop for Matlab routine'])
    disp(['optimal param of variance.para(i) : ' num2str(variance.para)]);
    disp(['optimal param of mean.para(i) : ' num2str(mean.para)]);

That is, only save the output if the model could be solved.

1 Like