% This Matlab file (dated September 2022) produces Figure 1 in the paper "A Model of Post-2008 Monetary Policy"
% (B. Diba and O. Loisel, September 2022), using the data produced by the Dynare file MOD_Data_Fig1.mod.

clear all;

% 1 x QE2
factor = 1;
save('Factor.mat','factor');
dynare MOD_Data_Fig1;
Tm = 30;
NM1 = 1+oo_.exo_simul([2:Tm+1],1);
pi1 = oo_.endo_simul(6,[2:Tm+1]);
iim1 = oo_.endo_simul(11,[2:Tm+1])-oo_.endo_simul(9,[2:Tm+1]);
inflation1 = 400*pi1;
spread1 = 40000*iim1;
save('Simulation1.mat','NM1','inflation1','spread1');

% 2 x QE2
factor = 2;
save('Factor.mat','factor');
dynare MOD_Data_Fig1;
Tm = 30;
NM2 = 1+oo_.exo_simul([2:Tm+1],1);
pi2 = oo_.endo_simul(6,[2:Tm+1]);
iim2 = oo_.endo_simul(11,[2:Tm+1])-oo_.endo_simul(9,[2:Tm+1]);
inflation2 = 400*pi2;
spread2 = 40000*iim2;
save('Simulation2.mat','NM2','inflation2','spread2');

% 3 x QE2
factor = 3;
save('Factor.mat','factor');
dynare MOD_Data_Fig1;
Tm = 30;
NM3 = 1+oo_.exo_simul([2:Tm+1],1);
pi3 = oo_.endo_simul(6,[2:Tm+1]);
iim3 = oo_.endo_simul(11,[2:Tm+1])-oo_.endo_simul(9,[2:Tm+1]);
inflation3 = 400*pi3;
spread3 = 40000*iim3;
save('Simulation3.mat','NM3','inflation3','spread3');

% 4 x QE2
factor = 4;
save('Factor.mat','factor');
dynare MOD_Data_Fig1;
Tm = 30;
NM4 = 1+oo_.exo_simul([2:Tm+1],1);
pi4 = oo_.endo_simul(6,[2:Tm+1]);
iim4 = oo_.endo_simul(11,[2:Tm+1])-oo_.endo_simul(9,[2:Tm+1]);
inflation4 = 400*pi4;
spread4 = 40000*iim4;

% Plotting the data
load('Simulation1.mat');
load('Simulation2.mat');
load('Simulation3.mat');
Tm = 30;
tm = 1:Tm;
f1=figure('Name','Effect of QE2','PaperUnits','inches','PaperPosition',[-0.77 0 9.6 3],'PaperSize',[8 3]);
subplot(1,3,1);
plot(tm,NM1,'-k*',tm,NM2,'-k',tm,NM3,'--k',tm,NM4,':k');
title('Nominal reserves $M_t$','Interpreter','latex');
xlabel('Quarters');
ylabel('Trillions of US Dollars');
subplot(1,3,2);
plot(tm,spread1,'-k*',tm,spread2,'-k',tm,spread3,'--k',tm,spread4,':k');
title('Spread $I_t-I^m_t$','Interpreter','latex');
xlabel('Quarters');
ylabel('Basis points per annum');
subplot(1,3,3);
plot(tm,inflation4,':k',tm,inflation3,'--k',tm,inflation2,'-k',tm,inflation1,'-k*');
title('Inflation $\pi_t$','Interpreter','latex');
xlabel('Quarters');
ylabel('Percentage points per annum');
legend({'4 $\times$ QE2','3 $\times$ QE2','2 $\times$ QE2','1 $\times$ QE2'},'Interpreter','latex','FontSize',10,'Location','northeast');
print(f1,'-dpdf','fig1');
