Loop over parameters to find maximized welfare

  1. In your case, you only need to read out the welfare. As you are not computing a consumption-equivalent, you do not need the function I write.
  2. Welfare is a stochastic property of the model, but you are reading out the steady state instead of the unconditional mean. The steady state will always be the same. You need to read out the respective element of oo_.mean and for that cannot use nomoments. Also, you need to add welfare to the variables after stoch_simul to get its moments.
  3. Are you sure your shock size is correct. It seems you multiply by 100 to have them in percentages. But at second order you cannot do that as the model solution is not certainty equivalent anymore. You will get wrong results. A 1 percent shock is 0.01, not 1.

Use


dynare welfare_TRY2.mod
rhogrid = 0.6:0.2:1.0;
% result_y = ones(length(rhogrid),1);
welfare_pos=strmatch('welfare',var_list_,'exact');
results_cell = zeros(length(rhogrid),1);
for i = 1:length(rhogrid)

    set_param_value('rho',rhogrid(i))

    info = stoch_simul(var_list_);
    
    if info ==0
        results_cell(i) = oo_.mean(welfare_pos);
    else 
        fprintf('Here is an error!\n');
    end
end

welfare_TRY2_steadystate.m (5.7 KB)
welfare_TRY2.mod (8.1 KB)
Run_welfare_TRY_outside2.m (677 Bytes)

1 Like