
%addpath c:\dynare\4.6.3\matlab
clear gobal
clearvars
close all

dynare mymodel;
rho = 0.1:0.05:1;
std_y=NaN(1,length(rho));
first_time = 1;
%position of variable of interest in M_.endo_names
pos_y = strmatch('y',M_.endo_names);
%dynare mymodel
for ii=1:length(rho)
    if first_time      
        set_param_value('rho_a',rho(ii));
        [info, oo_, options_, M_] = stoch_simul(M_, options_, oo_, var_list_);
        %[oo_.dr, info, M_, options_, oo_] = resol(0, M_, options_, oo_);
        if info~=0
          disp('Computation fails for rho = ', num2str(M_.params(strmatch('rho_a',M_.param_names))));
        else
        first_time = 0;
        std_y(ii)=sqrt(oo_.var(pos_y,pos_y));
        end
    else
        set_param_value('rho_a',rho(ii));
        [info, oo_, options_, M_] = stoch_simul(M_, options_, oo_, var_list_);
        %[oo_.dr, info, M_, options_, oo_] = resol(0, M_, options_, oo_);
        if info~=0
            disp('Computation fails for rho = ', num2str(M_.params(strmatch('rho_a',M_.param_names))));
        else
            std_y(ii)= sqrt(oo_.var(pos_y,pos_y));
        end    
    end
end

plot(rho,std_y)

