Looping over deep parameter
Posted: Fri Apr 17, 2015 2:39 pm
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:
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?
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?