Policy frontier

Starting with the unstable version of 12/18/2016 (Dynare 4.5), the following code should work for your mod-file

% make loop silent
options_.nofunctions=1;
options_.nocorr=1;
options_.noprint=1;
options_.irf=0;
options_.silent_optimizer=1;

options_.osr.opt_algo=9;

% find position of variables in variable_weights
y_pos=strmatch('y_hat',M_.endo_names,'exact');
pi_pos=strmatch('pi_hat',M_.endo_names,'exact');

% find position of variables in var_list_
y_pos_var_list_=strmatch('y_hat',var_list_,'exact');
pi_pos_var_list_=strmatch('pi_hat',var_list_,'exact');

weight_grid=0:0.01:1;
n_grid_points=length(weight_grid);
var_y=NaN(n_grid_points,1);
var_pi=NaN(n_grid_points,1);
for grid_iter=1:n_grid_points
    M_.osr.variable_weights(pi_pos,pi_pos) = weight_grid(grid_iter);
    M_.osr.variable_weights(y_pos,y_pos) = (1-weight_grid(grid_iter));
    oo_.osr = osr(var_list_,M_.osr.param_names,M_.osr.variable_indices,M_.osr.variable_weights);
    if oo_.osr.error_indicator==0
        var_y(grid_iter)=oo_.var(y_pos_var_list_,y_pos_var_list_);
        var_pi(grid_iter)=oo_.var(pi_pos_var_list_,pi_pos_var_list_);
    end
end
figure
plot(var_y,var_pi)
1 Like