Checksum file/ preprocessing failed

Hi,

I am new to matlab and dynare and trying to run a code in my deterministic model with permanent shocks. the question i am trying to answer is “a permanent shock such that et = 0.015 starting from period 1 on”.q4b.mod (1.2 KB)

I do not have problem with establishing the model, but I think mistake is how I add the permanent shocks to model. Could you check it?

here is the dynare code:

/* preamble */
var c k n z y i w r;
varexo e;

parameters beta chi delta alpha rho ;

alpha = 0.33;
beta = 0.99;
delta = 0.023;
chi = 1.75;
rho = 0.95;

model;
(1/c) = beta*(1/c(+1))(1+alpha(k^(alpha-1))exp(z(+1))(n(+1))^(1-alpha)-delta);
chic/(1-n) = (1-alpha)(k(-1)^alpha)exp(z)(n^(-alpha));
c+ k-(1-delta)k(-1) = (k(-1)^alpha)exp(z)n^(1-alpha);
z = rho
z(-1)+e;
y = exp(z)
(k(-1)^alpha)
(n^(1-alpha));
i = y-c;
w = (1-alpha)exp(z)(k(-1)^alpha)(n^(-alpha));
r = alpha
exp(z)(k(-1)^(alpha-1))(n^(1-alpha));
end;

initval;
k = 9;
c = 0.76;
n = 0.3;
z = 0;
e = 0;
y = 0.92;
w = 2.06;
r = 0.03;
end;

endval;
k = 9;
c = 0.76;
n = 0.3;
z = 0;
e = 0.01;
end;
steady;
check;

simul(periods=200);

tt=1:202’;

subplot(2,2,1);
plot(tt,oo_.endo_simul(9,:),tt,oo_.steady_state(9)*ones(1,202),‘LineWidth’,2);
title(‘Y’)

subplot(2,2,2);
plot(tt,oo_.endo_simul(10,:),tt,oo_.steady_state(10)*ones(1,202),‘LineWidth’,2);

title(‘I’)

subplot(2,2,3);
plot(tt,oo_.endo_simul(11,:),tt,oo_.steady_state(11)*ones(1,202),‘LineWidth’,2);
title(‘W’);

subplot(2,2,4);
plot(tt,oo_.endo_simul(12,:),tt,oo_.steady_state(12)*ones(1,202),‘LineWidth’,2);
title(‘R’)

First, you probably want to add another steady; command after the initval block, unless you have written the exact steady state there. Otherwise your starting point won’t be the steady state.

Then, you are asking for nonexistent elements of oo_.endo_simul: this matrix has 8 lines (the number of endogenous variables, in their order of declaration) and has 202 columns (the number of simulation periods plus initial and terminal conditions). So you should fix the line indices that you use for accessing this matrix.

For more details, you may be interested in looking at my slides on perfect foresight simulations. See in particular slides 44 and 47.

Thank you, Sebastien!

I am still not clear about how I can fix the line indices, I did try a couple of times but did not work.

Try something like

posW=strmatch(‘W’,M_.endo_names,‘exact’);
plot(tt,oo_.endo_simul(posW,:),tt,oo_.steady_state(posW)*ones(1,202),‘LineWidth’,2);
title(‘W’);