Page 1 of 1

Looping over deep parameter

PostPosted: Fri Apr 17, 2015 2:39 pm
by Daniel Bendel
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:
Code: Select all

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?

Re: Looping over deep parameter

PostPosted: Mon Apr 20, 2015 9:28 pm
by jpfeifer
This is hard to tell without seeing the full example. The best post is http://www.dynare.org/phpBB3/viewtopic.php?f=1&t=4891. A relatively correct example of this http://www.dynare.org/phpBB3/viewtopic.php?f=1&t=6727 (efficiency could still be improved)