Optimal simple rule (OSR) in OccBin

Dear all,

My goal is to find an OSR with presence of occasionally binding constraint.
I know there is an osr command in Dynare, but it is only applicable with stoch_simul.

Hence, it seems I should write a loop over parameters and call .mod file each iteration. Moreover, each iteration I want to save the mean to find the largest one then. I have looked through the forum but found not solution to OccBin case. Any help would be great! Below I present the code I have for the moment.

rho = 0.4:0.2:0.6;
first_time = 1;
for i=1:length(rho)
    if first_time == 1
        dynare GS_rep noclearall;
        first_time = 0;
    else
        set_param_value('rho_ib',rho(i));
        
        occbin_setup;
        occbin_solver(simul_periods=200,simul_check_ahead_periods=200);
        mean_s(i) = mean(oo_.occbin.simul.piecewise(1:end,2));

    end
end

NB: GS_rep is the name of my file, it works perfectly with OccBin, no problems.

The better way is

rho = 0.4:0.2:0.6;
first_time = 1;
for i=1:length(rho)
    if first_time == 1
        dynare GS_rep noclearall;
        first_time = 0;
    else
        set_param_value('rho_ib',rho(i));
        
        [oo_, out]= occbin.solver(M_, oo_, options_);
        if ~out.error_flag
            mean_s(i) = mean(oo_.occbin.simul.piecewise(1:end,2));
        else
            mean_s(i) = NaN;
        end
    end
end
1 Like

Professor,

Thank you very much!

Could you help me please, if I want to proceed with the analysis of the loss function, then I should explicitly define it, something like loss = weight_1*[std(oo_.occbin.simul.piecewise(var1))]^2 + weight_2*[std(oo_.occbin.simul.piecewise(var2))]^2 and then iterate over desired parameters to find a combination for which the loss function is minimal? Is this a right approach?

Depending on your answer to Second-order Welfare analysis and Occasionally Binding borrowing constraint - #8 by jpfeifer that would be correct.

Professor,

Thank you!