Parameter loop in Dynare 5.x

Hi everyone,

Quick question, I am using the following adjusted code from above:

OMEGARS = 1:1:5; %specifies the different values I want to loop over
first_time = 1;

for i = 1:length(OMEGARS)
    if first_time           
        dynare mymodfile noclearall;
        first_time = 0;
    else                 
        set_param_value('OMEGAR',OMEGARS(i));        
        info = stoch_simul(M_, options_, oo_, var_list_);
        %results_cell{i} = oo_ ;
        plot(oo_.irfs.variable_eps_j);
        hold on;
        %disp('I am plotting');       
    end 
        if info
          disp(['Computation fails for OMEGAR = ' num2str(OMEGARS)]);
        end
        
 end

Inside the mod file I call the ‘load parameter_file’ where all parameters are set, including the parameter of interest OMEGAR. The mod file also contains the steady state which was derived by hand. As OMEGAR changes, the steady state changes but this doesn’t seem to be a problem when we loop over stoch_simul.

So, here is the problem. When I loop over dynare (which we shouldn’t do), I get different irfs for the different OMEGARs. However, when I use the code in the m.file above, it seems the irfs get overwritten as I end up with five times the same values. Has anyone got an idea what I am doing wrong? Thanks for your help!

Rob

1 Like

Without the files it is impossible to tell.

For Dynare 5, you forgot to output the results from stoch_simul:


clear all;

OMEGARS = 1:1:5;
first_time = 1;

for i = 1:length(OMEGARS)
    if first_time           
        dynare rentalhousing noclearall;
        first_time = 0;
    else                 
        set_param_value('OMEGAR',OMEGARS(i));        
        [info, oo_] = stoch_simul(M_, options_, oo_, var_list_);
        if info
          disp(['Computation fails for rho = ' num2str(OMEGARS)]);
        else
        %results_cell{i} = oo_ ;
        plot(oo_.irfs.data_QQ_eps_j);
        hold on;
        disp('I am plotting');
        oo_.irfs.data_QQ_eps_j
        end
    end 
        
 end

3 Likes

Thanks Johannes!