# Looping over deep parameter

**URL:** <https://forum.dynare.org/t/looping-over-deep-parameter/4633>\
**Category:** Dynare help (legacy posts)\
**Created:** [17 April 2015 14:39 UTC](https://forum.dynare.org/t/looping-over-deep-parameter/4633 "2015-04-17T14:39:08Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Daniel\_Bendel](https://forum.dynare.org/letter_avatar_proxy/v4/letter/d/ecc23a/32.png) [@Daniel\_Bendel](https://forum.dynare.org/u/Daniel_Bendel)\
**Post date:** [17 April 2015 14:39 UTC](https://forum.dynare.org/t/looping-over-deep-parameter/4633/1 "2015-04-17T14:39:08Z")

</div>

Dear users,

I know the topic has already been discussed in forum, however I do not know if anyone has posted a complete solution to that topic. The issue is the following one: one wants to solve the model for different parameter values using a for loop in matlab.

The problem is when this parameter changes the steady state of the model.

Can you check if my solution is correct?

1. run dynare model.
2. write an external steady state file for the model. use the initval command to set up the steady state starting values.
3. set the parameter values to loop over say: alphaa = linspace(0.3,0.50,50); (so 50 different values for alphaa between 0.3 and 0.5)
4. use the following code:

```auto

global M_ oo_ options_ 

for i = 1:length(alphaa)

        set_param_value('alphaa',alphaa)
        
        [oo_.dr,info,M_,options_,oo_] = resol(0,M_,options_,oo_);
        [oo_.steady_state,~] = *_steadystate(oo_.steady_state,]); % * stands for the model's name
       y_ = simult_(oo_.steady_state,oo_.dr,oo_.exo_simul,1);%first order simulation
end
```

I am not sure about the usage of the global command. In my case it only works if I set the globals.

Is this procedure right?

---

<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:** [20 April 2015 21:28 UTC](https://forum.dynare.org/t/looping-over-deep-parameter/4633/2 "2015-04-20T21:28:49Z")

</div>

This is hard to tell without seeing the full example. The best post is [[Loop over parameters](https://forum.dynare.org/t/loop-over-parameters/3335/1)). A relatively correct example of this [[Help looping over two parameters](https://forum.dynare.org/t/help-looping-over-two-parameters/4637/1)) (efficiency could still be improved)
