%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%By Marco Bernardini & Gert Peersman (June 2017)
%Figure 4
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
clearvars;close all;clc
dg=[51,101,0]./255;
%%
[dataBP,textBP]=xlsread('figMATLAB.xls','Fig4_BP_data');
dataBP=dataBP(1:12,:);
[dataDN,textDN]=xlsread('figMATLAB.xls','Fig4_DN_data');
dataDN=dataDN(1:12,:);
time=dataBP(:,1);
zz=zeros(size(time));
%
figure('visible','on')
subplot(2,3,1) %Gross Domestic Product
    %Main Low
    grpyat=[time,dataBP(:,strmatch('upmulsdA_gdp_90',textBP));flipud(time),flipud(dataBP(:,strmatch('lomulsdA_gdp_90',textBP)))];
    patch(grpyat(:,1),grpyat(:,2),[255,204,204]./255,'edgecolor',[255,204,204]./255);hold on,
    plot(time,zz,'k-'),hold on,
    plot(time,dataBP(:,strmatch('bmulsdA_gdp',textBP)),'r-o','linewidth',2),hold on,
    %Main High
    plot(time,dataBP(:,strmatch('bmulsdB_gdp',textBP)),'b-^',time,dataBP(:,strmatch('upmulsdB_gdp',textBP)),'b--',time,dataBP(:,strmatch('lomulsdB_gdp',textBP)),'b--','linewidth',2),hold on,...
    axis tight,box off, ylim([0,3]),set(gca,'xtick',[0 3 7 11]','xticklabel',[' Q1';' Q4';' Q8';'Q12'])
    title({'GDP multiplier';''})
subplot(2,3,2) %Consumption
    %Main Low
    grpyat=[time,dataBP(:,strmatch('upmulsdA_con_90',textBP));flipud(time),flipud(dataBP(:,strmatch('lomulsdA_con_90',textBP)))];
    patch(grpyat(:,1),grpyat(:,2),[255,204,204]./255,'edgecolor',[255,204,204]./255);hold on,
    plot(time,zz,'k-'),hold on,
    plot(time,dataBP(:,strmatch('bmulsdA_con',textBP)),'r-o','linewidth',2),hold on,
    %Main High
    plot(time,dataBP(:,strmatch('bmulsdB_con',textBP)),'b-^',time,dataBP(:,strmatch('upmulsdB_con',textBP)),'b--',time,dataBP(:,strmatch('lomulsdB_con',textBP)),'b--','linewidth',2),hold on,...
    axis tight,box off, ylim([-0.1,0.9]),set(gca,'xtick',[0 3 7 11]','xticklabel',[' Q1';' Q4';' Q8';'Q12'])
    title({'Consumption multiplier';''})
subplot(2,3,3) %Investment
    %Main Low
    grpyat=[time,dataBP(:,strmatch('upmulsdA_inv_90',textBP));flipud(time),flipud(dataBP(:,strmatch('lomulsdA_inv_90',textBP)))];
    patch(grpyat(:,1),grpyat(:,2),[255,204,204]./255,'edgecolor',[255,204,204]./255);hold on,
    plot(time,zz,'k-'),hold on,
    plot(time,dataBP(:,strmatch('bmulsdA_inv',textBP)),'r-o','linewidth',2),hold on,
    %Main High
    plot(time,dataBP(:,strmatch('bmulsdB_inv',textBP)),'b-^',time,dataBP(:,strmatch('upmulsdB_inv',textBP)),'b--',time,dataBP(:,strmatch('lomulsdB_inv',textBP)),'b--','linewidth',2),hold on,...
    axis tight,box off, ylim([-0.4,0.6]),set(gca,'xtick',[0 3 7 11]','xticklabel',[' Q1';' Q4';' Q8';'Q12'])
    title({'Investment multiplier';''})
subplot(2,3,4) %Gross Domestic Product
    %Difference
    grpyat=[time,dataBP(:,strmatch('upmulsdBA_gdp_90',textBP));flipud(time),flipud(dataBP(:,strmatch('lomulsdBA_gdp_90',textBP)))];
    patch(grpyat(:,1),grpyat(:,2),[204,255,204]./255,'edgecolor',[204,255,204]./255);hold on,
    plot(time,zz,'k-'),hold on,
    plot(time,dataBP(:,strmatch('bmulsdBA_gdp',textBP)),'g','linewidth',2),hold on,
    axis tight,box off, ylim([-0.5,2]),set(gca,'xtick',[0 3 7 11]','xticklabel',[' Q1';' Q4';' Q8';'Q12'])
    %title({'GDP multiplier')
subplot(2,3,5) %Consumption
    %Difference
    grpyat=[time,dataBP(:,strmatch('upmulsdBA_con_90',textBP));flipud(time),flipud(dataBP(:,strmatch('lomulsdBA_con_90',textBP)))];
    patch(grpyat(:,1),grpyat(:,2),[204,255,204]./255,'edgecolor',[204,255,204]./255);hold on,
    plot(time,zz,'k-'),hold on,
    plot(time,dataBP(:,strmatch('bmulsdBA_con',textBP)),'g','linewidth',2),hold on,
    axis tight,box off, ylim([-0.1,0.9]),set(gca,'xtick',[0 3 7 11]','xticklabel',[' Q1';' Q4';' Q8';'Q12'])
    %title({'Consumption multiplier')
subplot(2,3,6) %Investment
    %Difference
    grpyat=[time,dataBP(:,strmatch('upmulsdBA_inv_90',textBP));flipud(time),flipud(dataBP(:,strmatch('lomulsdBA_inv_90',textBP)))];
    patch(grpyat(:,1),grpyat(:,2),[204,255,204]./255,'edgecolor',[204,255,204]./255);hold on,
    plot(time,zz,'k-'),hold on,
    plot(time,dataBP(:,strmatch('bmulsdBA_inv',textBP)),'g','linewidth',2),hold on,
    axis tight,box off, ylim([-0.3,0.6]),set(gca,'xtick',[0 3 7 11]','xticklabel',[' Q1';' Q4';' Q8';'Q12'])
    %title({'Investment multiplier')
set(findall(gcf,'type','text'),'FontSize',8) 
set(findall(gcf,'type','axes'),'FontSize',8)
set(gcf,'PaperUnits', 'inches','PaperPosition',[0,0,8,4]);
print('fig4_BP','-depsc')
%
figure('visible','on')
subplot(2,3,1) %Gross Domestic Product
    %Main Low
    grpyat=[time,dataDN(:,strmatch('upmulsdA_gdp_90',textDN));flipud(time),flipud(dataDN(:,strmatch('lomulsdA_gdp_90',textDN)))];
    patch(grpyat(:,1),grpyat(:,2),[255,204,204]./255,'edgecolor',[255,204,204]./255);hold on,
    plot(time,zz,'k-'),hold on,
    plot(time,dataDN(:,strmatch('bmulsdA_gdp',textDN)),'r-o','linewidth',2),hold on,
    %Main High
    plot(time,dataDN(:,strmatch('bmulsdB_gdp',textDN)),'b-^',time,dataDN(:,strmatch('upmulsdB_gdp',textDN)),'b--',time,dataDN(:,strmatch('lomulsdB_gdp',textDN)),'b--','linewidth',2),hold on,...
    axis tight,box off, ylim([0,7]),set(gca,'xtick',[0 3 7 11]','xticklabel',[' Q1';' Q4';' Q8';'Q12'])
    title({'GDP multiplier';''})
subplot(2,3,2) %Consumption
    %Main Low
    grpyat=[time,dataDN(:,strmatch('upmulsdA_con_90',textDN));flipud(time),flipud(dataDN(:,strmatch('lomulsdA_con_90',textDN)))];
    patch(grpyat(:,1),grpyat(:,2),[255,204,204]./255,'edgecolor',[255,204,204]./255);hold on,
    plot(time,zz,'k-'),hold on,
    plot(time,dataDN(:,strmatch('bmulsdA_con',textDN)),'r-o','linewidth',2),hold on,
    %Main High
    plot(time,dataDN(:,strmatch('bmulsdB_con',textDN)),'b-^',time,dataDN(:,strmatch('upmulsdB_con',textDN)),'b--',time,dataDN(:,strmatch('lomulsdB_con',textDN)),'b--','linewidth',2),hold on,...
    axis tight,box off, ylim([-0.5,1.5]),set(gca,'xtick',[0 3 7 11]','xticklabel',[' Q1';' Q4';' Q8';'Q12'])
    title({'Consumption multiplier';''})
subplot(2,3,3) %Investment
    %Main Low
    grpyat=[time,dataDN(:,strmatch('upmulsdA_inv_90',textDN));flipud(time),flipud(dataDN(:,strmatch('lomulsdA_inv_90',textDN)))];
    patch(grpyat(:,1),grpyat(:,2),[255,204,204]./255,'edgecolor',[255,204,204]./255);hold on,
    plot(time,zz,'k-'),hold on,
    plot(time,dataDN(:,strmatch('bmulsdA_inv',textDN)),'r-o','linewidth',2),hold on,
    %Main High
    plot(time,dataDN(:,strmatch('bmulsdB_inv',textDN)),'b-^',time,dataDN(:,strmatch('upmulsdB_inv',textDN)),'b--',time,dataDN(:,strmatch('lomulsdB_inv',textDN)),'b--','linewidth',2),hold on,...
    axis tight,box off, ylim([-1,2.5]),set(gca,'xtick',[0 3 7 11]','xticklabel',[' Q1';' Q4';' Q8';'Q12'])
    title({'Investment multiplier';''})
subplot(2,3,4) %Gross Domestic Product
    %Difference
    grpyat=[time,dataDN(:,strmatch('upmulsdBA_gdp_90',textDN));flipud(time),flipud(dataDN(:,strmatch('lomulsdBA_gdp_90',textDN)))];
    patch(grpyat(:,1),grpyat(:,2),[204,255,204]./255,'edgecolor',[204,255,204]./255);hold on,
    plot(time,zz,'k-'),hold on,
    plot(time,dataDN(:,strmatch('bmulsdBA_gdp',textDN)),'g','linewidth',2),hold on,
    axis tight,box off, ylim([-1,6]),set(gca,'xtick',[0 3 7 11]','xticklabel',[' Q1';' Q4';' Q8';'Q12'])
    %title({'GDP multiplier')
subplot(2,3,5) %Consumption
    %Difference
    grpyat=[time,dataDN(:,strmatch('upmulsdBA_con_90',textDN));flipud(time),flipud(dataDN(:,strmatch('lomulsdBA_con_90',textDN)))];
    patch(grpyat(:,1),grpyat(:,2),[204,255,204]./255,'edgecolor',[204,255,204]./255);hold on,
    plot(time,zz,'k-'),hold on,
    plot(time,dataDN(:,strmatch('bmulsdBA_con',textDN)),'g','linewidth',2),hold on,
    axis tight,box off, ylim([-.5,1.5]),set(gca,'xtick',[0 3 7 11]','xticklabel',[' Q1';' Q4';' Q8';'Q12'])
    %title({'Consumption multiplier')
subplot(2,3,6) %Investment
    %Difference
    grpyat=[time,dataDN(:,strmatch('upmulsdBA_inv_90',textDN));flipud(time),flipud(dataDN(:,strmatch('lomulsdBA_inv_90',textDN)))];
    patch(grpyat(:,1),grpyat(:,2),[204,255,204]./255,'edgecolor',[204,255,204]./255);hold on,
    plot(time,zz,'k-'),hold on,
    plot(time,dataDN(:,strmatch('bmulsdBA_inv',textDN)),'g','linewidth',2),hold on,
    axis tight,box off, ylim([-0.5,2.5]),set(gca,'xtick',[0 3 7 11]','xticklabel',[' Q1';' Q4';' Q8';'Q12'])
    %title({'Investment multiplier')
set(findall(gcf,'type','text'),'FontSize',8) 
set(findall(gcf,'type','axes'),'FontSize',8)
set(gcf,'PaperUnits','inches','PaperPosition',[0,0,8,4]);
print('fig4_DN','-depsc')