Loop over differen steady state value (Not parameter)

Dear all,

I met some problems while i was coding in Dynare of RBC model. My goal was trying to loop over the “different steady-state value” of a variable. Not parameters. Taking the code from Professor Jpfeifer as an example:

Here, I want to loop different value of " k_hat " instead of paramters and i have already defined that k_hat_i =[0; 0.3; 0.5;0.7] in matlab .m file, but it does not run and said that something wrong with my dynare .mod codes.

var y_hat c_hat k_hat A_hat R_hat Pi_hat;
varexo eps_A;

parameters beta delta alpha rhoA phi_pi Rbar Pibar;

alpha   = 0.33;     // capital share
delta   = 0.025;    //deprecation rate
beta    = 0.99;     //discount factor
Pibar   = 1;
Rbar    = 1/beta;
phi_pi  = 1.5;
rhoA    = 0.97;     //TFP autocorr. from linearly detrended Solow residual


model(linear);
#k_ss=((1/beta-(1-delta))/alpha)^(1/(alpha-1));
#y_ss=k_ss^alpha;
#c_ss=y_ss-delta*k_ss;
-1/c_ss*c_hat=-1/c_ss*c_hat(+1)
            +beta*1/c_ss*alpha*k_ss^(alpha-1)*(A_hat(+1)+(alpha-1)*k_hat);
-c_hat=-c_hat(+1)+R_hat-Pi_hat(+1);
y_ss*y_hat=c_ss*c_hat+k_ss*k_hat-(1-delta)*k_ss*k_hat(-1);
y_hat=A_hat+alpha*k_hat(-1);
R_hat=phi_pi*Pi_hat;
A_hat=rhoA*A_hat(-1)+eps_A;
end;

steady_state_model;

**load kCurr;**
**set_param_value('k_hat_i',curr_k_hat_i);**  
 **// here i try to load the vector of 0, 0.3, 0.5 and 0.7 in matlab file but not work**

y_hat=0;
c_hat=0;
R_hat=0;
Pi_hat=0;
A_hat=0;
end;

shocks;
var eps_A=0.0068^2;
end;

steady;
check;

stoch_simul(order=1,irf=20,periods=250);
rplot Pi_hat;
rplot R_hat;
figure
plot(1:options_.periods,Pi_hat,'b-','LineWidth',1.5)
hold on
plot(1:options_.periods,zeros(options_.periods,1),'r--')
ylabel('Log deviation of gross inflation $\Pi_t$ from its steady state ($\hat \Pi_t$)','Interpreter','Latex')
ylim([-0.005 0.005])
print -depsc2 SimulatedTrajectory_Pi_hat

figure
plot(1:options_.periods,R_hat,'b-','LineWidth',1.5)
hold on
plot(1:options_.periods,zeros(options_.periods,1),'r--')
ylabel('Log deviation of gross quarterly interest rate $R_t$ from its steady state ($\hat R_t$)','Interpreter','Latex')
ylim([-0.005 0.005])
print -depsc2 SimulatedTrajectory_R_hat

varobs c_hat;
estimation(datafile=simulated_data_dynare_RBC_with_SS);

Really appreciate and thanks in advance.

Rosa

Please explain what you are trying to do. After all, steady state values are a function of the deep parameters. So they cannot be exogenously chosen without taking parameter dependence into account.

Dear Professor jpfeifer,

Thanks for replying. I will explain things and my goal in detail.
The given model is one of your replication work (JQ 2012 details see attachement) and what i want to do is comparing the IRFs with different steady-state value of e.g financial variables, like you may see from my modification of .mod file. (I set the financial variable with different steady-state value in 0.3, 0.5…by calling set_param_‘xxx’,xx). But it does not work. Not sure where the problem is.

Thank you in advance.

loop.m (1.5 KB) baseline_model.mod (4.6 KB)

It seems that “load xxx” and “set_param_value (‘xxx’ xxx)” only works for looping over different value of parameters, say, e.g alpha, betta… But it does not work for looping over different SS value of a certain variable, like in my task, looping over different steady-state value, xi /n/ or Z.

Thanks a lot.

Sorry, but I still don’t know what you are trying to achieve. You use

set_param_value('xi_i',curr_xi_i);

but there is no object xi_i that has been defined by you in the model.

Hello, i define a vector of xi_i value in loop.m file, like here:

xi_i = [0.1;0.3;0.5;0.7];
N = length(xi_i);
save PARxi

% Preparing a matrix for the IRFs
IRFs = zeros(50,N,8);
save IRF_for_looping IRFs

for j=1:N

load PARxi
curr_xi_i  = xi_i(j);
save senCurr j curr_xi_i


dynare baseline_model;

load IRF_for_looping
load senCurr


IRFs(:,j,1)     = yhat_eps_z;
IRFs(:,j,2)     = nhat_eps_z;
IRFs(:,j,3)     = chat_eps_z;
IRFs(:,j,4)     = ihat_eps_z;
IRFs(:,j,5)     = byhat_eps_z;
IRFs(:,j,6)     = dyhat_eps_z;
IRFs(:,j,7)     = vyhat_eps_z;
IRFs(:,j,8)     = muhat_eps_z;
save IRF_for_looping IRFs

end

load PARxi

And i want to compare the IRFs with different value of xi_i vector, not sure where the problem is.

Again: xi_i is neither a parameter nor a variable defined in the model. As the name of the command set_param_value says, it’s for changing parameter values.

Yes, indeed. The structural parameters defined here is beta, alpha…for sure xi is not a paramter. Actually, I research for some examples about how to loop over “steady-state value” but did not find good example about how to do it. I only find some topics about looping over parameters, so i tried. Since i am a beginner of Dynare, Professor, would you mind providing me some hints or examples about how to loop such “values like xi”?
Thank you very much in advance.

I only see many good examples for your answer about how to loop over different parameter values, but it seems nothing is mentioned about looping over, lets say, “a certain ss value”.
Many thanks for your answer.

As I wrote above

The exercise you have in mind does not make sense. You can loop over parameters that imply different steady state values. But you cannot loop over steady state values while keeping the parameters at values that would imply a different steady state.

Thank you very much for your answers.
I was wondering in this case, if i take parameter dependence into account, is it possible for me to loop over different kappa or variance and covariance of stochastic process of xi in order to obtain the different ss value of xi ?(like the authors did in sensitivity analysis part).

Would that implies we need to adopt different approach to set the “initval” is .mod file?

Thank you.

Rosa

Yes, as in my Jermann/Quadrini example, you would need to adjust the parameter governing that steady state ratio accordingly.