# Stoch_simul from recursive estimations

Dear all,

I have recursively estimated my model and now I am trying to load all the recursively estimated parameters and run a stoch_simul in a separate mod file. However, when I reach any recession periods, stoch_simul crashes with unsatisfactory Blanchard & Kahn - indeterminacy, even though the estimation went without a problem.

I am setting all estimated parameters in a loop via set_param_value. So I have 2 questions:

1. Is there a better way to load the estimated results in a bulk?
2. What could cause the indeterminacy in B&K conditions? Am I missing something? Perhaps some steady-state information from the estimation?

Thank you very much for any insight!

Without seeing the specific example, it is impossible to tell. Something must be going wrong.

I’ll try being more specific and provide the code.

This is what I use to loop over the stoch_simul with every recursive estimation of each parameter:

``````for i = 1:96  %for 96 recursive estimations
if first_time
dynare model_loss noclearall;
first_time = 0;
result_var(i).ygap = oo_.var(1,1);
result_var(i).pi = oo_.var(2,2);
result_var(i).r = oo_.var(3,3)/4;
result_var(i).ugap = oo_.var(4,4);
result_var(i).t = t{i};
else
set_param_value('cpibar',p_cpibar(i));
set_param_value('crhointr',p_crhointr(i));
set_param_value('cry',p_cry(i));
set_param_value('crdy',p_crdy(i));
set_param_value('crpi',p_crpi(i));
set_param_value('cphi', p_cphi(i));
set_param_value('ch', p_ch(i));
set_param_value('comega', p_comega(i));
set_param_value('cv', p_cv(i));
set_param_value('cthetap', p_cthetap(i));
set_param_value('cthetaw', p_cthetaw(i));
set_param_value('cgammap', p_cgammap(i));
set_param_value('cgammaw', p_cgammaw(i));
set_param_value('cpsip', p_cpsip(i));
set_param_value('cpsiw', p_cpsiw(i));
set_param_value('calpha', p_calpha(i));
set_param_value('cthetae', p_cthetae(i));
set_param_value('cbetabar', p_cbetabar(i));
set_param_value('cebar', p_cebar(i));
set_param_value('ctaubar', p_ctaubar(i));
set_param_value('crhoa', p_crhoa(i));
set_param_value('crhob', p_crhob(i));
set_param_value('crhog', p_crhog(i));
set_param_value('crhoga', p_crhoga(i));
set_param_value('crhoq', p_crhoq(i));
set_param_value('crhor', p_crhor(i));
set_param_value('crhop', p_crhop(i));
set_param_value('cmup', p_cmup(i));
set_param_value('crhow', p_crhow(i));
set_param_value('crhos', p_crhos(i));
set_param_value('cmuw', p_cmuw(i));
set_param_value('cpsi', p_cpsi(i));
[info, oo_] = stoch_simul(M_, options_, oo_, var_list_);
if info
disp(['Computation fails for t = ' t{i}]);
else
result_var(i).ygap = oo_.var(1,1);
result_var(i).pi = oo_.var(2,2);
result_var(i).r = oo_.var(3,3)/4;
result_var(i).ugap = oo_.var(4,4);
end
end
end
for i = 1:96
result_var(i).t = t{i};
end
``````

With this being the mod file:
model_loss.mod (10.7 KB)

The stochastic simulation fails in some of the recession periods (2009 and 2019), I doubt that is a coincidence. I set parameter values of all estimated parameters, perhaps I am supposed to add something for each recursion?

(edit: formatting)

Can you please also provide the parameter file to run the code.

Of course, I forgot about that, sorry.

This is the file:
irf_params_all_10y.mat (26.4 KB)

I load it simply by running:

`load('irf_params_all_10y.mat')`

Please upload a zip file with code I can run. The mat file does not contain the parameters you are trying to set.

Here it is professor. Hopefully the error is replicable.

Loss_functions.zip (30.8 KB)

You need

``````        options_.qz_criterium=1-1e-6;
``````

in the second part of the loop. The problem is the different treatment of near unit roots in `estimation` and `stoch_simul`.

That solves the issue. Thank you, professor!