Unformatted Attachment Preview
USEMMP - Simulation exercise
Part 1
A. Please open MatLab, copy the code below and run it.
You now run the behavioural macromodel of chapter one of De Grauwe’s book.
B. Run it a couple of times.
C. Interpret the results, particularly:
a. Highlight a period where chartists take over and explain what happens to output.
b. Comment on the frequency with which spells occur in which chartists take over.
c. Comment on the autocorrelations in output and inflation and on the Kurtosis you
find and relate it to the empirical results mentioned in the book.
D. Set rho to 1 eliminating the capacity to forget. Run the model a couple of times again and
interpret the results again. Explain why the capacity to forget is necessary to generate
behavioural cycles.
E. Set the capacity to forget to its initial value. Now play with the willingness to learn. Set it very
high and very low and interpret the results again.
Part 2
You can do this exercise in MatLab building using parts of the code provided in part 1, but it can just
as well be done in an environment in which you are more familiar, like Excel or Stata. The choice is
yours; I do not care what software you use to solve this exercise.
A. Start form the macromodel in equation 1.1-1.3 of De Grauwe and the coefficient values in
appendix 1. Please plot the evolution of inflation, output and the nominal interest rate over
time if there is a positive shock of size one to output at time 0 (i.e. 𝜖0 = 1 and 𝜖𝑡 = 0 if 𝑡 ≠
0). Assume expectations are fundamentalist forever.
B. Explain the economics of what you see.
Hint: use the model in equation 1.22 𝑍𝑡 = 𝐴−1 [𝐵 𝐸̃𝑡 𝑍𝑡+1 + 𝐶𝑍𝑡−1 + 𝑏𝑟𝑡−1 + 𝜈𝑡 ] with for the
expectations equation 1.14 and equation 1.4 and for the interest rate equation 1.3.
𝑏
0
Also: please note that there is a typo in the DeGrauwe book. Matrix B equals ( 1
). You can
−𝑎2 𝑎1
see this is a typo by deriving equation 1.22 from equations 1.1 to 1.3.
C. Now assume expectations for both inflation and output are given forever by
𝐸̃𝑡 𝑦𝑡+1 = 𝑦𝑡−1 − 𝑦𝑡−2 and 𝐸̃𝑡 𝜋𝑡+1 = 𝜋𝑡−1 − 𝜋𝑡−2
Again plot the evolution and explain the economics.
D. Now assume expectations for both inflation and output are given forever by
𝐸̃𝑡 𝑦𝑡+1 = 0.5𝑦𝑡−1 and 𝐸̃𝑡 𝜋𝑡+1 = 0.5𝜋𝑡−1
Again plot the evolution and explain the economics.
E. Now assume expectations for both inflation and output are given by
𝐸̃𝑡 𝑦𝑡+1 = 0.5𝑦𝑡−1 and 𝐸̃𝑡 𝜋𝑡+1 = 0.5𝜋𝑡−1
For period 0 to 4 and are fundamentalist from period 5 onwards.
Again plot the evolution and explain the economics of what you see.
F. What does it mean when a model is stationary? And are models C-E stationary?
% Appendix 2 of De Grauwe Lectures on behavioural macroeconomics
% Adjustments by Jasper Lukkezen 11-3-2017.
% Parameters of the mode % Appendix 2 of De Grauwe Lectures on behavioural
macroeconomics
% Adjustments by Jasper Lukkezen 11-3-2017.
% Parameters of the model
% expectation formation
mm=1;
% switching parameter gamma in Brock Hommes /// ==
willingness to learn
rho=.5;
% rho in mean squares errors /// == capacity to forget
rhoBH=0.0;
% rho in forecast rule selection
pstar=0;
% the central bank's inflation target
eprational=0;
% if all agents have rational forecast of inflation
this parameter is 1
epextrapol=0;
% if all agents use inflation extrapolation this
parameter is 1
epfs=pstar;
% forecast inflation targeters
alfap=0.5;
% percentage of extrapolators in inflation in the first
period
alfay=0.5;
% percentage of extrapolators in output in the first
period
% length of the simulation
T=20000;
% length of simulation
TI=300;
% plot length
xlimits=[1 TI];
% limits of x-axis
ylimits=[0 1];
% limit of y-axis
% parameters of the macro model (1.21)
a1=0.5;
% coefficent of expected output in output equation
a2=-0.2;
% a is the interest eleasticity of output demand
b1=0.5;
% b1 is coefficent of expected inflation in inflation
equation
b2=0.05;
% b2 is coefficient of outout in inflation equation
c1=1.5;
% c1 is coefficient of inflation in Taylor equation
c2=0.5;
% c2 is coefficient of output in Taylor equation
c3=0.5;
% interest smoothing parameter in Taylor equation
A=[1 -b2; -a2*c1 1-a2*c2];
B=[b1 0; -a2 a1];
C=[1-b1 0; 0 1-a1];
square = 0;
% set to 1 if you want to use the other interest rate
rule
smooth=[0; a2*c3]; % smoothing parameter of lagged interest rate
sigma1=0.5;
sigma2=0.5;
sigma3=0.5;
% standard deviation shocks output
% standard deviation shocks inflation
% standard deviation shocks Taylor
% the rho variables
% move slower, i.e.
rhoout=0.0;
rhoinf=0.0;
rhotayl=0.0;
insert autoregressive components, which makes variables
x(t) = rhox x(t-1) + other terms
% rho in shocks output
% rho in shocks inflation
% rho in shocks Taylor
% define empty time series (will be filled with the simulation results
p=zeros(T,1);
% inflation
y=zeros(T,1);
% output
plagt=zeros(T,1);
% lagged inflation
ylagt=zeros(T,1);
% lagged output
r=zeros(T,1);
% interest
epf=zeros(T,1);
% fundamental forecast inflation
epc=zeros(T,1);
% extrapolative forecast inflation
ep=zeros(T,1);
% combined forecast inflation
eyfunt=zeros(T,1); % fundamental forecast output
ey=zeros(T,1);
% combined forecast output
CRp=zeros(T,1);
% forecast error extrapolators inflation
FRp=zeros(T,1);
% forecast error fundamentalists inflation
alfapt=zeros(T,1); % percentage extrapolators in inflation
CRy=zeros(T,1);
% forecast error extrapolators output
FRy=zeros(T,1);
% forecast error fundamentalists output
alfayt=zeros(T,1); % percentage extrapolators output
anspiritsy=zeros(T,1); % animal spirits output
anspiritsp=zeros(T,1); % animal spirits inflation
epsilont=zeros(T,1); % shock in output
etat=zeros(T,1);
% shock in inflation
ut=zeros(T,1);
% shock in Taylor rule
%%%%%%%%%%%%%%%%%% %Behavioral Model% %%%%%%%%%%%%%%%%%%
for t=2:T
%%% provide schocks
epsilont(t)=rhoout*epsilont(t-1)+sigma1*randn;
equation (demand shock)
etat(t)=rhoinf*etat(t-1)+sigma2*randn;
equation (supply shock)
ut(t)=rhotayl*ut(t-1)+sigma3*randn;
(interest rate shock)
epsilon=epsilont(1);
eta=etat(t);
u=ut(t);
shocks=[eta;a2*u+epsilon];
%shocks in output
%shocks in inflation
%shocks in Taylor rule
%%% set expectations
% for inflation
epcs=p(t-1); % extrapolative forecast (1.14)
if eprational==1; % if everyone is a fundamentalist
epcs=pstar;
end
eps=alfap*epcs+(1-alfap)*epfs; % expectations are a combination of the
extrapolative forecsst and the fundamental forecast (1.16)
if epextrapol==1; % overwrite the previous result if all agents are
extrapolators
eps=p(t-1);
end
% for output
eychar=y(t-1); % chartist expectations (1.5)
eyfun=0+randn/2; % fundamentalist expectations (1.4)
eyfunt(t)=eyfun;
eys=alfay*eychar+(1-alfay)*eyfun; % combined expectations (1.6)
% expectatins
forecast=[eps; eys];
%%% evolution of the model
% initial bookkeeping
plag=p(t-1);
ylag=y(t-1);
rlag=r(t-1);
lag=[plag;ylag];
% calculate inflation and output using the model
D=B*forecast+C*lag+smooth*rlag+shocks; % (1.21)
X= A^(-1)*D; % (1.22)
p(t)=X(1,1);
y(t)=X(2,1);
r(t)=c1*p(t)+c2*y(t)+c3*r(t-1)+u; % (1.3)
% different interest rate rule, used if square == 1
if square==1;
r(t)=c1*(p(t))^2+c2*y(t)+c3*r(t-1)+u;
end
% final bookkeeping
plagt(t)=p(t-1);
ylagt(t)=y(t-1);
%%% evolution of the expectations
CRp(t)=rho*CRp(t-1)-(1-rho)*(epcs-p(t))^2; % forecast error of
extrapolators for inflation (1.24)
FRp(t)=rho*FRp(t-1)-(1-rho)*(epfs-p(t))^2; % forecast error of
fundamentatists for inflation (1.23)
CRy(t)=rho*CRy(t-1)-(1-rho)*(eychar-y(t))^2; % forecast error of
extrapolators for output (1.24)
FRy(t)=rho*FRy(t-1)-(1-rho)*(eyfun-y(t))^2; % forecast error of
fundamentatists for output (1.23)
alfap=rhoBH*alfapt(t-1)+(1rhoBH)*exp(mm*CRp(t))/(exp(mm*CRp(t))+exp(mm*FRp(t))); % percentage of
extrapolators in inflation (1.19)
alfay=rhoBH*alfayt(t-1)+(1rhoBH)*exp(mm*CRy(t))/(exp(mm*CRy(t))+exp(mm*FRy(t))); % percentage of
extrapolators in output (1.19)
alfapt(t)=alfap; % bookkeeping
alfayt(t)=alfay; % bookkeeping
if eychar>0;
anspiritsy(t)=alfay;
end
if eychar0;
anspiritsp(t)=alfap;
end
if eps