# Shock on an exogenous shifter

Hi,
I’m simulating new keynesian model with stiky wages and stiky prices.
It’s a deterministic model in which is required to solve it expressing the variables as deviations from the steady states (so we have to express the exogenous and endogenous variables as exp^(lvar) ?), with the exception of i (interest rate), and inflation. Since we have both the inflation on prices and on wages, do we have to put the two inflations as log or just the inflation on prices?
moreover, how is it possible to shock a parameter just for n periods? (I’ve tried with the attached code (for eta) but it doesn’t work)
how is possible to shock a exogenous
variable?: I have to shock the exogeneous shifter d. but we don’t know the initial value, and the value of the shock. I only know that the shock must be positive.

``````
var lc, lh, pp, lpw, lw, lgdp, ly, i, lg,e;

varexo ld,lz,eps_eta ;

parameters sigma, beta, teta, chi, tau, ni,  gamma, phi, psi, phip, phiy,eta  ;
eta=0.2;
sigma = 1 ;
beta = 0.997;
teta = 7.67;
chi = 3.5;

tau = 0.2;
ni = 0.28;

gamma = 100;
phi = 50 ;
psi = 90 ;
phip = 1.5;
phiy = 0.125;

model;

1=beta*exp(ld(+1))*(1+(i*4))/(1+pp)*((exp(lc)/exp(lc(+1)))^(sigma));
gamma*pp(-1)*(1+pp(-1))= teta*((exp(lw)/exp(lz))-1)+beta*exp(ld(+1))* ((exp(lc)/exp(lc(+1)))^sigma) * (exp(ly(+1))/exp(ly))*gamma*pp*(1+pp);
chi*((exp(lh))^(ni))*((exp(lc))^sigma)+(1-tau)*(1-chi)*exp(lw)+(phi/psi)*(exp(-(exp(lpw)))-1)*(1+exp(lpw))=beta*exp(ld(+1))*(phi/psi)*(exp(-psi*exp(lpw(+1)))-1)*(1+exp(lpw(+1)))*(exp(lh(+1))/exp(lh))*((exp(lc)/exp(lc(+1)))^sigma);
(exp(lw)/exp(lw(-1)))=(1+exp(lpw))/(1+pp(-1));
i*4= max(0,(1/(beta*exp(ld(+1))))-1+phip*pp(-1)+phiy*ln((exp(lgdp))/(exp(ly))));
exp(ly)=exp(lz)*exp(lh);
exp(lgdp)=(1-(gamma/2)*(pp(-1)^2))*exp(ly);
exp(lgdp)= exp(lc)+exp(lg);
exp(lg)= eta*exp(ly);
e=eta+eps_eta;
end;

check;

shocks;
var eps_eta;
periods 0:4;
values 0.05;
end;

simul(periods=100);
1. The logging only has to do with the interpretation of percentages instead of levels. Therefore, it does not matter for the solution as long as it is done consistently.
2. What exactly are you trying to achieve? You appended an additional equation

```e=eta+eps_eta; ```
where the shock eps_eta only affects e, but leaves eta unaffected. Please have a look at e.g. github.com/JohannesPfeifer/DSGE_mod/blob/master/Solow_model/Solow_growth_rate_changes.mod to see how to “shock parameters”. If you want to set eta, define eta as an exogenous variable and then set it via the shocks command. Most probably you want something along the lines of (tested with the unstable version of Dynare/4.5)

[code]
var lc, lh, pp, lpw, lw, lgdp, ly, i, lg;

varexo ld,lz,eta ;

parameters sigma, beta, teta, chi, tau, ni, gamma, phi, psi, phip, phiy ;
sigma = 1 ;
beta = 0.997;
teta = 7.67;
chi = 3.5;

tau = 0.2;
ni = 0.28;

gamma = 100;
phi = 50 ;
psi = 90 ;
phip = 1.5;
phiy = 0.125;

model;

1=betaexp(ld(+1))(1+(i4))/(1+pp)((exp(lc)/exp(lc(+1)))^(sigma));
gammapp(-1)(1+pp(-1))= teta*((exp(lw)/exp(lz))-1)+betaexp(ld(+1)) ((exp(lc)/exp(lc(+1)))^sigma) * (exp(ly(+1))/exp(ly))gammapp*(1+pp);
chi*((exp(lh))^(ni))((exp(lc))^sigma)+(1-tau)(1-chi)exp(lw)+(phi/psi)(exp(-(exp(lpw)))-1)(1+exp(lpw))=betaexp(ld(+1))(phi/psi)(exp(-psiexp(lpw(+1)))-1)(1+exp(lpw(+1)))(exp(lh(+1))/exp(lh))((exp(lc)/exp(lc(+1)))^sigma);
(exp(lw)/exp(lw(-1)))=(1+exp(lpw))/(1+pp(-1));
i4= max(0,(1/(betaexp(ld(+1))))-1+phippp(-1)+phiyln((exp(lgdp))/(exp(ly))));
exp(ly)=exp(lz)exp(lh);
exp(lgdp)=(1-(gamma/2)
(pp(-1)^2))exp(ly);
exp(lgdp)= exp(lc)+exp(lg);
exp(lg)= eta
exp(ly);
end;

initval;
eta = 0.2;
end;

check;

shocks;
var eta;
periods 0:4;
values 0.25;
end;

simul(periods=100);
rplot lg ly eta;[/code]

thank you very much.
now i would like to plot two figures:
figure 1 with shock ld
and figure two with ld and shock eta
there is some kind of loop that simulate the the model without the necessity to write it down twice?

[code]var lc, lh, pp, lpw, lw, lgdp, ly, lg, i;

varexo ld, lz, eta;

parameters sigma, beta, teta, chi, tau, ni, gamma, phi, psi, phip, phiy;

sigma = 1;
beta = 0.997;
teta = 7.67;
chi = 3.5;
tau = 0.2;
ni = 0.28;
gamma = 100;
phi = 50;
psi = 0;
phip = 1.5;
phiy = 0.125;

model;
1=betaexp(ld(+1))(1+(i4))/(1+pp)((exp(lc)/exp(lc(+1)))^(sigma));
gammapp(-1)(1+pp(-1))=teta*((exp(lw)/exp(lz))-1)+betaexp(ld(+1))((exp(lc)/exp(lc(+1)))^sigma)(exp(ly(+1))/exp(ly))gammapp(1+pp);
-(chi*((exp(lh))^(ni))+(1-tau)(1-chi)exp(lw))+phi(exp(lpw))(1+exp(lpw))=beta*(exp(ld(+1)))phi(exp(lpw(+1)))(1+(exp(lpw(+1))))(exp(lh(+1))/exp(lh))((exp(lc)/exp(lc(+1)))^sigma);
(exp(lw)/exp(lw(-1)))=(1+exp(lpw))/(1+pp(-1));
i
4= max(0,(1/(betaexp(ld(+1))))-1+phippp(-1)+phiy*ln((exp(lgdp))/(exp(ly))));
exp(ly)=exp(lz)exp(lh);
exp(lgdp)=(1-(gamma/2)
(pp(-1)^2))exp(ly);
exp(lgdp)=exp(lc)+exp(lg);
exp(lg)=eta
exp(ly);
end;

initval;
pp=0;
i=0;
lz=0;
eta=0.2;
end;

check;

shocks;
var ld;
periods 0:4;
values 0.03;
var eta;
periods 0:4;
values 0.25;
end;

simul(periods=100);

lcphi(:,1)=lc;
lhphi(:,1)=lh;
ppphi(:,1)=pp;
lpwphi(:,1)=lpw;
lwphi(:,1)=lw;
lgdpphi(:,1)=lgdp;
lyphi(:,1)=ly;
lgphi(:,1)=lg;
iphi(:,1)=i;

phi=0;

simul(periods=100);

check;

N=101;
x=0:N-1;
figure(2);

subplot(3,3,1)
xlabel(‘t’)
ylabel(‘c’)
title(‘Consumption’,‘Color’,‘r’)

subplot(3,3,2)
xlabel(‘t’)
ylabel(‘h’)
title(‘Labour’,‘Color’,‘r’)

subplot(3,3,3)
xlabel(‘t’)
ylabel(‘pp’)
title(‘Prices Inflation’,‘Color’,‘r’)

subplot(3,3,4)
xlabel(‘t’)
ylabel(‘wp’)
title(‘Wages Inflation’,‘Color’,‘r’)

subplot(3,3,5)
xlabel(‘t’)
ylabel(‘w’)
title(‘Wages’,‘Color’,‘r’)

subplot(3,3,6)
xlabel(‘t’)
ylabel(‘gdp’)
title(‘GDP’,‘Color’,‘r’)

subplot(3,3,7)
xlabel(‘t’)
ylabel(‘y’)
title(‘Production’,‘Color’,‘r’)

subplot(3,3,8)
xlabel(‘t’)
ylabel(‘g’)
title(‘Public Expenditure’,‘Color’,‘r’)

subplot(3,3,9)
xlabel(‘t’)
ylabel(‘i’)
title(‘Interest Rate’,‘Color’,‘r’)[/code]

Yes, you can have multiple deterministic simulations in the same mod-file.
After you finish the first simulation, use the

block to reset the shocks to the values you want and then use a new simul-command. Note that if your shocks affect the terminal value, you will also need to put a new endval block here. If you want to be one the safe side, provide initval, endval, and shocks(overwrite).