Transition Experiment in Stochastic Environment

I study a transition experiment in Chapter 11 of Ljungqvist and Sargent’s book. I found Dynare codes from the accompanying programs with “Practice Dynare”. It is about a permanent increase in the government spending. But when I attempted to extend it to the stochastic environment, I found something weird to me. I attach my revised codes here:

var c k A;
varexo taui tauc tauk g epis;
parameters bet gam del alpha rho sigma;
bet=.95;
gam=2;
del=.2;
alpha=.33;
rho=0.95;
sigma=0.007;

model;
k=Ak(-1)^alpha+(1-del)k(-1)-c-g;
c^(-gam)= bet
(c(+1)^(-gam))
((1+tauc(-1))/(1+tauc))((1-taui)(1-del)/(1-taui(-1))+
((1-tauk)/(1-taui(-1)))alphaAk(-1)^(alpha-1));
log(A)=rho
log(A(-1))+epis;
end;

initval;
k=1.5;
c=0.6;
A=1;
g = 0.2;
tauc = 0;
taui = 0;
tauk = 0;
end;
steady;

shocks;
var epis;
stderr sigma;
var g;
periods 1:9 10:100;
values 0.2 0.4;
end;

stoch_simul(periods=100,drop=0);

k0=oo_.endo_simul(2,:);
c0=oo_.endo_simul(1,:);
figure
subplot(1,2,1)
plot(k0)
title(‘k’)
subplot(1,2,2)
plot(c0)
title(‘c’)


The idea is that instead of fixed productivity, I want to the transition path with uncertainty. I can generate a graph but it is quite different from the one in the deterministic environment (see Figure 6 in the handout “Practice Dynare”): first, the consumption even increases in the beginning and second, both variables have quite different levels compared to the deterministic case. So I wonder if I can really use Dynare to accomplish my objective. If so, then what is wrong with my codes?

Thanks a lot!

Your setup looks weird. You just look at one particular simulation path, but you did not control for the initial shock epis (or the other shocks subsequently happening). Either directly use the simult_ function or do several replications to integrate the shocks out (you will find the get_simul_replic function on my homepage).

Excuse me, Johannes! I typed
[sim_array]=get_simul_replications(M_,options_)

But an error came:
??? Error using ==> get_simul_replications at 34
Cannot open Fig1131stoch_simul

Why is the identifier smaller than 3?

Please provide the full file to replicate the issue.

Hi Johannes! In the end, I found that I should have typed “forecast” in the end. Now the qualitative property is the same as the graph in the book of Sargent and Ljungqvist. But I still have a question: why doesn’t the simulation start from the steady state? I replicate the codes in the attachment.
Fig1131stoch.mod (717 Bytes)

You must be more precise. Which simulation of which command does not return the expected results in which sense?

I’m replicating Figure 6 in this file, but in the stochastic environment. I guess I should use Command “forecast”. The qualitative property is exactly the same, yet the simulation doesn’t start from the original steady state, which puzzles me. Thank you!
AP_tom16.pdf (479 KB)

You really need to think more about what you are trying to do. It seems you are confusing the different meaning of initval, endval, and histval in stochastic contexts. See the manual for details. In addition, you need to think about around which steady state you want to approximate your model.

Regarding your initial question: the forecast command shows response in the first period. You start at the initial steady state, but it is not shown. That initial steady state is the one you entered with your endval command!