Dear all, I do not understand why the ‘res’ variable do not change when I run the loop below. The parameters are changing but my initial guess is that the stochastic simulation is not changing. The problem is that I cannot figure out why. Do you have any suggestions? Thank you all in advance.
alp_admin_um_ = 0.30:0.05:1.0;
alp_admin_dois_ = 0.10:0.05:1.0;
alp_admin_tres_ = 0.03:0.005:1.0;
alp_admin_quatro_ = 0.0:0.05:1.0;
var_inflation = zeros(length(alp_admin_um_),41);
var_inflation_benchmark = [0 -0.08 -0.13 -0.18 -0.24 -0.22 -0.22 -0.21 -0.20 -0.18 -0.17 -0.16 -0.16 -0.15 -0.15 -0.14];
min = 0.3;
iteration = 0; % Initialize counter
for iParam=1:length(alp_admin_um_)
for jParam=1:length(alp_admin_dois_)
for kParam=1:length(alp_admin_dois_)
for lParam=1:length(alp_admin_dois_)
iteration = iteration + 1;
set_param_value('alp_admin_um',alp_admin_um_(iParam))
set_param_value('alp_admin_dois',alp_admin_dois_(jParam))
set_param_value('alp_admin_tres',alp_admin_tres_(kParam))
set_param_value('alp_admin_quatro',alp_admin_quatro_(lParam))
stoch_simul(order=1, irf=16, nograph);
res = sum(abs(oo_.conditional_forecast.cond.Mean.infl_cheia_12m(1:16)' - var_inflation_benchmark));
disp(['Iteration: ', num2str(iteration)])
disp([alp_admin_um alp_admin_dois alp_admin_tres alp_admin_quatro])
disp(res)
disp('...')
if res<min
min = res;
stop_flag = true; % Set flag to stop loops
break; % Break out of the innermost loop
end
end
end
end
end
@#include "main.mod"
clc;
%--------------------------------------------------------------------------------------------------------------------------------------
% 6. "Optimal" parameters
%--------------------------------------------------------------------------------------------------------------------------------------
alp_admin_um_ = 0.30:0.05:1.0;
alp_admin_dois_ = 0.10:0.05:1.0;
alp_admin_tres_ = 0.03:0.005:1.0;
alp_admin_quatro_ = 0.0:0.05:1.0;
var_inflation = zeros(length(alp_admin_um_),41);
var_inflation_benchmark = [0 -0.08 -0.13 -0.18 -0.24 -0.22 -0.22 -0.21 -0.20 -0.18 -0.17 -0.16 -0.16 -0.15 -0.15 -0.14];
min = 0.3;
iteration = 0; % Initialize counter
for iParam=1:length(alp_admin_um_)
for jParam=1:length(alp_admin_dois_)
for kParam=1:length(alp_admin_dois_)
for lParam=1:length(alp_admin_dois_)
iteration = iteration + 1;
set_param_value('alp_admin_um',alp_admin_um_(iParam))
set_param_value('alp_admin_dois',alp_admin_dois_(jParam))
set_param_value('alp_admin_tres',alp_admin_tres_(kParam))
set_param_value('alp_admin_quatro',alp_admin_quatro_(lParam))
stoch_simul(order=1, irf=16, nograph);
res = sum(abs(oo_.conditional_forecast.cond.Mean.infl_cheia_12m(1:16)' - var_inflation_benchmark));
disp(['Iteration: ', num2str(iteration)])
disp([alp_admin_um alp_admin_dois alp_admin_tres alp_admin_quatro])
disp(res)
disp('...')
if res<min
min = res;
stop_flag = true; % Set flag to stop loops
break; % Break out of the innermost loop
end
end
end
end
end
I understand that after the set_param_value( . ) commands, I change the parameters and perform a different stochastic simulation (with stoch_simul(.)), right? Do I need to call ‘dynare main.mod’ again within the loop or is there another way?