# Parameter loop in Dynare 5.x

**URL:** <https://forum.dynare.org/t/parameter-loop-in-dynare-5-x/20293>\
**Category:** Stochastic simulations\
**Created:** [4 May 2022 20:57 UTC](https://forum.dynare.org/t/parameter-loop-in-dynare-5-x/20293 "2022-05-04T20:57:34Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![Robert](https://forum.dynare.org/letter_avatar_proxy/v4/letter/r/e95f7d/32.png) [@Robert](https://forum.dynare.org/u/Robert)\
**Post date:** [4 May 2022 20:57 UTC](https://forum.dynare.org/t/parameter-loop-in-dynare-5-x/20293/1 "2022-05-04T20:57:34Z")

</div>

Hi everyone,

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

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

---

<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:** [5 May 2022 07:37 UTC](https://forum.dynare.org/t/parameter-loop-in-dynare-5-x/20293/2 "2022-05-05T07:37:16Z")

</div>

Without the files it is impossible to tell.

---

<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:** [5 May 2022 08:24 UTC](https://forum.dynare.org/t/parameter-loop-in-dynare-5-x/20293/3 "2022-05-05T08:24:47Z")

</div>

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

```auto

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

```

---

<div class="post-metadata">

**Author:** ![Robert](https://forum.dynare.org/letter_avatar_proxy/v4/letter/r/e95f7d/32.png) [@Robert](https://forum.dynare.org/u/Robert)\
**Post date:** [5 May 2022 08:42 UTC](https://forum.dynare.org/t/parameter-loop-in-dynare-5-x/20293/4 "2022-05-05T08:42:50Z")

</div>

Thanks Johannes!

---

<div class="post-metadata">

**Author:** ![egal](https://forum.dynare.org/letter_avatar_proxy/v4/letter/e/c57346/32.png) [@egal](https://forum.dynare.org/u/egal)\
**Post date:** [9 September 2025 10:59 UTC](https://forum.dynare.org/t/parameter-loop-in-dynare-5-x/20293/5 "2025-09-09T10:59:52Z")

</div>

Sorry to reopen this thread, but I have a very similar problem which I believe is the result of a stupid mistake I am making, but that I cannot manage to solve it.

I am trying to loop multiple parameters in my model to conduct sensitivity analysis. As in the case above, changes in the parameters will affect the steady state. I am stuck with the no steady state error:

> Error using **[print\_info](matlab:matlab.lang.internal.introspective.errorDocCallback(‘print\_info’, ‘/Applications/Dynare/6.2-arm64/matlab/print\_info.m’, 33))** ([line 33](matlab: opentoline(‘/Applications/Dynare/6.2-arm64/matlab/print\_info.m’,33,0)))  
> The steadystate file did not compute the steady state
> 
> Error in **[stoch\_simul](matlab:matlab.lang.internal.introspective.errorDocCallback(‘stoch\_simul’, ‘/Applications/Dynare/6.2-arm64/matlab/stochastic\_solver/stoch\_simul.m’, 119))** ([line 119](matlab: opentoline(‘/Applications/Dynare/6.2-arm64/matlab/stochastic\_solver/stoch\_simul.m’,119,0)))  
> print\_info(info, options\_.noprint, options\_);  
> ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^  
> Error in **[temp](matlab:matlab.lang.internal.introspective.errorDocCallback(‘temp’, ‘/Users/ettoreg/Documents/GitHub/Pereira Serra - Gallo 2025/dynare/temp.m’, 9))** ([line 9](matlab: opentoline(‘/Users/ettoreg/Documents/GitHub/Pereira Serra - Gallo 2025/dynare/temp.m’,9,0)))  
> [info, oo\_] = stoch\_simul(M\_, options\_, oo\_, var\_list\_);  
> ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

I am sure the model reaches the steady state with all values of _taur_ in the sequence, but it seems that the steady state does not update when _taur_ changes.

> [temp.m](https://forum.dynare.org/uploads/short-url/kC7Yhql69nFrn7ENoDAI15oHyTm.m) (564 Bytes)
> 
> [temp.mod](https://forum.dynare.org/uploads/short-url/83zzV6Rjx03AXkoHTKRpMXk4G86.mod) (8.7 KB)

I am attaching both the Matlab function and the .mod file (in which the problem most likely lies). Could you please clarify what I am getting wrong and how to solve this?

Thank you in advance for your help @jpfeifer !

Best,

Ettore

---

<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:** [9 September 2025 18:24 UTC](https://forum.dynare.org/t/parameter-loop-in-dynare-5-x/20293/6 "2025-09-09T18:24:22Z")

</div>

It seems you are having a whole bunch of objects that depend on `taur` that are set only once before the `model` block. Definitions like

```auto
sp = xi * (Inbar + Iebar) / ((1 - taur) * (Ynbar - wpbar * Lbar - (1 - xi) * (Inbar + Iebar)));

```

belong in the `steady_state_model` block.

[temp.mod](https://forum.dynare.org/uploads/short-url/9GqqLoLbTSDYuSdowsGhwb9HqVb.mod) (8.7 KB)  
[temp.m](https://forum.dynare.org/uploads/short-url/kC7Yhql69nFrn7ENoDAI15oHyTm.m) (564 Bytes)
