# Policy frontier

**URL:** <https://forum.dynare.org/t/policy-frontier/5910>\
**Category:** Optimal Policy\
**Created:** [4 December 2016 10:00 UTC](https://forum.dynare.org/t/policy-frontier/5910 "2016-12-04T10:00:36Z")\
**Posts on this page:** 1\
**Showing post:** 6

<div class="post-metadata">

**Author:** ![jpfeifer](https://forum.dynare.org/user_avatar/forum.dynare.org/jpfeifer/32/5044_2.png) [@jpfeifer](https://forum.dynare.org/u/jpfeifer)\
**Post date:** [18 December 2016 12:33 UTC](https://forum.dynare.org/t/policy-frontier/5910/6 "2016-12-18T12:33:37Z")

</div>

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

```auto
% 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)
```

---

_[View the full topic](https://forum.dynare.org/t/policy-frontier/5910)._
