Policy frontier


#21

It should most probably be

% find position of variables in variable_weights
L_pos=strmatch('L',M_.endo_names,'exact');
q_pos=strmatch('q',M_.endo_names,'exact');
Y_pos=strmatch('Y',M_.endo_names,'exact');

% find position of variables in M_.endo_names
L_pos_M_.endo_names=strmatch('L',M_.endo_names,'exact');
q_pos_M_.endo_names=strmatch('q',M_.endo_names,'exact');
Y_pos_M_.endo_names=strmatch('Y',M_.endo_names,'exact');

weight_grid_L=0:0.1:1;        //I want to have this weight on credit fixed at 1. Not sure how to go about it !! Please help !
weight_grid_q=0:0.05:0.5;     //Only allow the weights of q and Y to vary from [0, 1]  
weight_grid_Y=0:0.1:1;

n_grid_points_L = length(weight_grid_L);
n_grid_points_q = length(weight_grid_q);
n_grid_points_Y = length(weight_grid_Y);

var_L_CcCR=NaN(n_grid_points_L,n_grid_points_q,n_grid_points_Y);  
var_q_CcCR=NaN(n_grid_points_L,n_grid_points_q,n_grid_points_Y);
var_Y_CcCR=NaN(n_grid_points_L,n_grid_points_q,n_grid_points_Y);

for grid_iter_L=1:n_grid_points_L
    for grid_iter_q=1:n_grid_points_q
        for grid_iter_Y=1:n_grid_points_Y
            M_.osr.variable_weights(L_pos,L_pos) = weight_grid_L(grid_iter_L);
            M_.osr.variable_weights(q_pos,q_pos) = weight_grid_q(grid_iter_q);
            M_.osr.variable_weights(Y_pos,Y_pos) = weight_grid_Y(grid_iter_Y);
            oo_.osr = osr(M_.endo_names,M_.osr.param_names,M_.osr.variable_indices,M_.osr.variable_weights);
            if oo_.osr.error_indicator==0
                var_L_CcCR(grid_iter_L,grid_iter_q,grid_iter_Y)=oo_.var(L_pos_M_.endo_names,L_pos_M_.endo_names);
                var_q_CcCR(grid_iter_L,grid_iter_q,grid_iter_Y)=oo_.var(q_pos_M_.endo_names,q_pos_M_.endo_names);
                var_Y_CcCR(grid_iter_L,grid_iter_q,grid_iter_Y)=oo_.var(Y_pos_M_.endo_names,Y_pos_M_.endo_names);
            end
        end
    end
end

because the variances need to be three-dimensional objects if you trace out all the possible combination of three parameters.


#22

Thank you very much Prof JPfeifer.


#24

Good day Prof Pfeifer,

In the above example of the code you provided earlier, will I be correct to re-specify the code as:

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) = 1; % Fixed the weight on pi to 1.
    M_.osr.variable_weights(y_pos,y_pos) = 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

If I only want the weight on y_hat to vary in the range [0, 1] while the one on pi_hat is fixed at 1?

Please assist.

Regards,


#25

Without seeing the whole file it is always hard to tell, but what you posted looks right.


#26

Dear Prof Pfeifer,
after following the discussion above, I was trying to replicate Iacoviello (2005) in order to plot the policy frontier, but the code doesn’t run:

Error using cmaes (line 316)
Initial search point, and problem dimension, not determined

Error in dynare_minimize_objective (line 364)
[x, fval, COUNTEVAL, STOPFLAG, OUT, BESTEVER] =
cmaes(func2str(objective_function),start_par_value,H0,cmaesOptions,varargin{:});

Error in osr1 (line 132)
[p, f, exitflag] =
dynare_minimize_objective(str2func(‘osr_obj’),t0,options_.osr.opt_algo,options_,M_.osr.param_bounds,cellstr(M_.param_names(i_params,:)),[],[],
i_params,…

Error in osr (line 63)
osr_res = osr1(i_params,i_var,W);

Error in iacoviello_aer_policy_frontier_bis (line 420)
oo_.osr = osr(var_list_,M_.osr.param_names,M_.osr.variable_indices,M_.osr.variable_weights);

Error in dynare (line 223)
evalin(‘base’,fname) ;

Attached the .mod file. Can you help finding the problem?

Thanks so much.
iacoviello_aer_policy_frontier_oscar.mod (5.2 KB)


#27

I resolved the problem. No need to go over it. Thanks