% Payment Habits in Canada % Tatjana Dahlhaus (12/2020) %modified by Angelika Welte (01/2021) % This code computes the local projection regressions (linear) clear close all clc warning off; %head directory %cd '/home/wela/DW/MEDRC/MATLAB' cd '/home/wela/DW/MEDRC/MATLAB' % filenames for excel output modelout = '../Output300/simplereg.xlsx'; %filename = '../Output300/IRFchart.xlsx'; %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %IMPORTANT INPUT (sample window) %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % hor=20; % horizon horizon = 250; % horizon: 250 days to cover first year ) %lags lags = 10; %position of shock rpos=lags+2; %track whether file has been written to overwrite = 1; for i = 1:1:4 for shock = 1:1:2 hor = horizon; ind = i; local_projection; end %all shocks ind = i; regressions; end %write the IRFout matrix to exceland make charts for ind = 1:1:4 hold on figure(g(1, ind)) ax1 = gca; hold off hold on figure(g(2, ind)); ax2 = gca; hold off %define a commom y axis ymin = min(ax2.YLim(1), ax1.YLim(1)); ymax = max(ax2.YLim(2), ax1.YLim(2)); hold on; figure(g(1, ind)); ylim([ymin ymax]); g(1, ind) = gcf; hold off hold on figure(g(2, ind)); ylim([ymin ymax]); g(2, ind) = gcf; hold off hold on figure(h(1, ind)) ax1 = gca; hold off hold on figure(h(2, ind)); ax2 = gca; hold off %define a commom y axis ymin = min(ax2.YLim(1), ax1.YLim(1)); ymax = max(ax2.YLim(2), ax1.YLim(2)); hold on; figure(h(1, ind)); ylim([ymin ymax]); h(1, ind) = gcf; hold off hold on figure(h(2, ind)); ylim([ymin ymax]); h(2, ind) = gcf; hold off end for shock = 1:1:2 for ind = 1 : 1 : 4 hold on figure( h(shock, ind)); legend('Location', 'southwest'); if shock ==1 if ind ==1 saveas(gcf, '../Output300/InteracACSSABMval1.png'); elseif ind ==2 saveas(gcf, '../Output300/InteracACSSABMvol1.png'); elseif ind ==3 saveas(gcf, '../Output300/InteracACSSPOSval1.png'); elseif ind ==4 saveas(gcf, '../Output300/InteracACSSPOSvol1.png'); end elseif shock ==2 if ind ==1 saveas(gcf, '../Output300/InteracACSSABMval2.png'); elseif ind ==2 saveas(gcf, '../Output300/InteracACSSABMvol2.png'); elseif ind ==3 saveas(gcf, '../Output300/InteracACSSPOSval2.png'); elseif ind ==4 saveas(gcf, '../Output300/InteracACSSPOSvol2.png'); end end hold off; hold on figure( g(shock, ind)); legend('Location', 'southwest'); if shock ==1 if ind ==1 saveas(gcf, '../Output300/cashcardval1new.png'); elseif ind ==2 saveas(gcf, '../Output300/cashcardvol1new.png'); elseif ind ==3 saveas(gcf, '../Output300/ABMav1new.png'); elseif ind ==4 saveas(gcf, '../Output300/POSav1new.png'); end elseif shock==2 if ind ==1 saveas(gcf, '../Output300/cashcardval2new.png'); elseif ind ==2 saveas(gcf, '../Output300/cashcardvol2new.png'); elseif ind ==3 saveas(gcf, '../Output300/ABMav2new.png'); elseif ind ==4 saveas(gcf, '../Output300/POSav2new.png'); end end hold off; end end