shock on an exogenous shifter

This forum is closed. You can read the posts but cannot write. We have migrated the forum to a new location where you will have to reset your password.
Forum rules
This forum is closed. You can read the posts but cannot write. We have migrated the forum to a new location (https://forum.dynare.org) where you will have to reset your password.

shock on an exogenous shifter

Postby silviagil » Fri Dec 09, 2016 3:41 pm

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.
thank you for your help
Code: Select all

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;


steady;
check;
steady_old=oo_.steady_state;

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


simul(periods=100);
steady_new=oo_.steady_state;
silviagil
 
Posts: 2
Joined: Fri Dec 09, 2016 1:20 pm

Re: shock on an exogenous shifter

Postby jpfeifer » Sat Dec 10, 2016 8:54 am

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
Code: Select all
e=eta+eps_eta;

where the shock eps_eta only affects e, but leaves eta unaffected. Please have a look at e.g. https://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: Select all
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=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);
end;

initval;
eta = 0.2;
end;

steady;
check;
steady_old=oo_.steady_state;

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


simul(periods=100);
steady_new=oo_.steady_state;
rplot lg ly eta;
------------
Johannes Pfeifer
University of Cologne
https://sites.google.com/site/pfeiferecon/
jpfeifer
 
Posts: 6940
Joined: Sun Feb 21, 2010 4:02 pm
Location: Cologne, Germany

Re: shock on an exogenous shifter

Postby silviagil » Sat Dec 10, 2016 5:03 pm

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: Select all
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=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))+(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/(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);
end;

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

steady;
check;

steady1=oo_.steady_state;

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);

steady;
check;

steady2=oo_.steady_state;

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

subplot(3,3,1)
plot(x,lcphi(1:N,1),'b--',x,lc(1:N,1),'b')%,x,steady1(1,1)*ones(N,1),'k-.',x,steady2(1,1)*ones(N,1),'k')
xlabel('t')
ylabel('c')
title('Consumption','Color','r')

subplot(3,3,2)
plot(x,lhphi(1:N,1),'b--',x,lh(1:N,1),'b')%,x,steady1(2,1)*ones(N,1),'k-.',x,steady2(2,1)*ones(N,1),'k')
xlabel('t')
ylabel('h')
title('Labour','Color','r')

subplot(3,3,3)
plot(x,ppphi(1:N,1),'g--',x,pp(1:N,1),'g')%,x,steady1(3,1)*ones(N,1),'k-.',x,steady2(3,1)*ones(N,1),'k')
xlabel('t')
ylabel('pp')
title('Prices Inflation','Color','r')

subplot(3,3,4)
plot(x,lpwphi(1:N,1),'b--',x,lpw(1:N,1),'b')%,x,steady1(4,1)*ones(N,1),'k-.',x,steady2(4,1)*ones(N,1),'k')
xlabel('t')
ylabel('wp')
title('Wages Inflation','Color','r')

subplot(3,3,5)
plot(x,lwphi(1:N,1),'b--',x,lw(1:N,1),'b',x,steady1(5,1)*ones(N,1),'k-.',x,steady2(5,1)*ones(N,1),'k')
xlabel('t')
ylabel('w')
title('Wages','Color','r')

subplot(3,3,6)
plot(x,lgdpphi(1:N,1),'b--',x,lgdp(1:N,1),'b')%,x,steady1(6,1)*ones(N,1),'k-.',x,steady2(6,1)*ones(N,1),'k')
xlabel('t')
ylabel('gdp')
title('GDP','Color','r')

subplot(3,3,7)
plot(x,lyphi(1:N,1),'b--',x,ly(1:N,1),'b')%,x,steady1(7,1)*ones(N,1),'k-.',x,steady2(7,1)*ones(N,1),'k')
xlabel('t')
ylabel('y')
title('Production','Color','r')

subplot(3,3,8)
plot(x,lgphi(1:N,1),'b--',x,lg(1:N,1),'b')%,x,steady1(8,1)*ones(N,1),'k-.',x,steady2(8,1)*ones(N,1),'k')
xlabel('t')
ylabel('g')
title('Public Expenditure','Color','r')

subplot(3,3,9)
plot(x,iphi(1:N,1),'g--',x,i(1:N,1),'g')%,x,steady1(9,1)*ones(N,1),'k-.',x,steady2(9,1)*ones(N,1),'k')
xlabel('t')
ylabel('i')
title('Interest Rate','Color','r')
silviagil
 
Posts: 2
Joined: Fri Dec 09, 2016 1:20 pm

Re: shock on an exogenous shifter

Postby jpfeifer » Sun Dec 11, 2016 11:41 am

Yes, you can have multiple deterministic simulations in the same mod-file.
After you finish the first simulation, use the
Code: Select all
shocks (overwrite) ;

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).
------------
Johannes Pfeifer
University of Cologne
https://sites.google.com/site/pfeiferecon/
jpfeifer
 
Posts: 6940
Joined: Sun Feb 21, 2010 4:02 pm
Location: Cologne, Germany


Return to Dynare help

Who is online

Users browsing this forum: Google [Bot] and 5 guests