%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%Some Observations in the High Frequency Versions of a Standard New-Keynesian Model%%%%
%%%%%%by Reiner Franke & Stephen Sacht (Bulletin of Economic Research, forthcoming)%%%%%%%
%%%%%%%%%%%%%%%%%Matlab/Dynare Source Code (c) by Stephen Sacht (2008)%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%Robustness Check: 2D & 3D Plots%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
for d=1:99; //0.01 < theta < 0.99
var pip y i v piphd yhd ihd vh;
varexo a;
parameters beta rho sigma eta theta omega chi phi_p phi_y alpha_v rf x h gammaf gammab lambda ah bh gammafhd gammabhd;
beta=0.99; //Intertemporal discount rate
rho=(1-beta)/beta; //Natural real rate of interest (households' preference rate)
sigma=1; //Intertemporal elasticity of substitution in consumption
eta=1; //Intertemporal elasticity of substitution of labour
theta=d*0.01; //Calvo degree of price stickiness (sensitivity parameter)
omega=0.3; //[SET] value of the rule-of-thumb parameter in price setting
chi=0.6; //[SET] value of the habit-formation parameter in consumption
phi_p=1.5; //Weight on inflation in the Taylor rule
phi_y=0.125; //Weight on the output gap in the Taylor rule
alpha_v=0.5; //Persistence of the shock process
rf=100; //Length of the impulse response functions (must be equal to the value for 'irf' in stoch_simul)
x=3; //[SET] frequency of decision making (e.g. three times within a quarter := monthly frequency)
h=1/x; //Length of the period (relative to a quarter, where h=1)
gammaf=(beta*theta)/(theta+omega*(1-theta*(1-beta)));
gammab=omega/(theta+omega*(1-theta*(1-beta)));
lambda=((1-omega)*(sigma+eta)*(1-theta)*(1-beta*theta))/(theta+omega*(1-theta*(1-beta)));
ah=omega+((1+h*(1-omega)*rho)*(1-h*(1-theta)))/(1+h*rho);
bh=((1-omega)*(sigma+eta)*(1-theta)*(1+rho-theta))/ah;
gammafhd=(1-h*(1-theta))/((1+h*rho)*ah);
gammabhd=omega/ah;
model(linear);
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%//Baseline Economy (h=1)
pip=gammaf*pip(+1)+gammab*pip(-1)+lambda*y;
y=(1/(1+chi))*y(+1)+(chi/(1+chi))*y(-1)-((1-chi)/(sigma*(1+chi)))*(i-pip(+1)-rho);
i=rho+phi_p*pip+phi_y*y+v;
v=alpha_v*v(-1)+a;
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%//h-Economy (0 Computation of d_t (deviations in relation to the impact effect in %): |(**)-(*)|/(impact matrix for t=0)
YHO=abs((Y-YHM)*XY)*100;
PH2=abs((PIP-PIPHM)*XPIPT2)*100; //(t=0) -> Computation of d_t (deviations in relation to the impact effect in %): |(**)-(*)|/(impact matrix for t=1)
YH2=abs((Y-YHM)*XYT2)*100;
PHA(d)=abs((2/3*PIP(1,d)+1/3*PIP(2,d)-PIPPIP(2,d))*1/(2/3*PIP(1,d)+1/3*PIP(2,d)))*100;
YHA(d)=abs((2/3*Y(1,d)+1/3*Y(2,d)-YHYH(2,d))*1/(2/3*Y(1,d)+1/3*Y(2,d)))*100;
end;
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%//Graphs
TYHO=YHO'; //Transpose for 3D plot (viewpoint)
TPHO=PHO';
TYH2=YH2'; //Transpose for 3D plot (viewpoint)
TPH2=PH2';
TPHA=PHA';
TYHA=YHA';
jj=[0:99]; //Number of quarters
ll=[0:98]; //Range of price stickiness
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%//2D Plots
figure('Name','Robustness Check - 2D Plots','NumberTitle','off');
tt(1:99)=0.5;
kk1=[0:98];
subplot(1,2,1);
plot(kk1,TYHA,'--g',kk1,TYHO(:,1),'-b',kk1,TYH2(:,2),':','LineWidth',1.7);
xlim([50 90]);
ylim([0 100]);
xlabel('price stickiness','FontSize',12)
ylabel('deviations d_t','FontSize',12)
legend('t=1/3','t=0','t=1');
title('output gap','FontSize',14)
subplot(1,2,2);
plot(kk1,TPHA,'--g',kk1,TPHO(:,1),'-b',kk1,TPH2(:,2),':','LineWidth',1.7);
xlim([50 90]);
ylim([0 100]);
xlabel('price stickiness','FontSize',12)
ylabel('deviations d_t','FontSize',12)
legend('t=1/3','t=0','t=1');
title('inflation rate','FontSize',14)
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%//3D Plots
for g=1:10;
for v=1:99;
C(g,v)=1/Y(g,v);
D(g,v)=1/PIP(g,v);
YH(g,v)=abs((Y(g,v)-YHM(g,v))*C(g,v))*100;
PH(g,v)=abs((PIP(g,v)-PIPHM(g,v))*D(g,v))*100;
end;
end;
YHA=YH(1:6,50:90);
PHA=PH(1:6,50:90);
TYH=YHA';
TPH=PHA';
ABC(1:6,1:41)=50;
ABC1=ABC';
jj=[0:5];
ll=[0.50:0.01:0.90];
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%//Truncation
tr=100; //Truncated at 'tr' %...
A1=TYH(:,:)