%close all
clear all
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%SOLVE THE MODELS AND GENERATE IRFs
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
dynare FMS.mod
save('base');
%close all
clear all
copyfile('param_ERJ.m',['./OnlyCash/param_ERJ.m']);
cd(['./OnlyCash']);
dynare FMS.mod
delete('param_ERJ.m');
cd(['../'])
save('cash');
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%CHART
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
clear all
slist = {'a1';'r1'};
for jj=1:size(slist,1)
mshk = cell2mat(slist(jj,1));
%First chart
figure('units','normalized','outerposition',[0 0 1 1])
subplot(4,4,1)
mvar = 'Ytot1';
%mshk = 'a1';
mname = [mvar,'_e_',mshk];
load('base',mname);
eval(['tmp=',mname,';']);
plot([1:24],tmp,'-','linewidth',3,'color',[0 0 0]);
hold on
load('cash',mname);
eval(['tmp=',mname,';']);
plot([1:24],tmp,'--o','linewidth',3,'color',[0.4 0.4 0.4]);
grid on
xlim([1 24]);
legend('Full model','Model with only cash','Location','best');
title('Output (H)');
ax = gca;
ax.YAxis.Exponent = 0;
ax.GridAlpha = 0.9;  % Make grid lines less transparent.
ax.GridColor = [0.2 0.2 0.2]; % Dark 
set(gca,'fontsize',18);

subplot(4,4,2)
mvar = 'pi1';
%mshk = 'a1';
mname = [mvar,'_e_',mshk];
load('base',mname);
eval(['tmp=',mname,';']);
plot([1:24],tmp,'-','linewidth',3,'color',[0 0 0]);
hold on
load('cash',mname);
eval(['tmp=',mname,';']);
plot([1:24],tmp,'--o','linewidth',3,'color',[0.4 0.4 0.4]);
grid on
xlim([1 24]);
%legend('Full model','Model with only cash');
title('CPI inflation (H)');
ax = gca;
ax.YAxis.Exponent = 0;
ax.GridAlpha = 0.9;  % Make grid lines less transparent.
ax.GridColor = [0.2 0.2 0.2]; % Dark 
set(gca,'fontsize',18);

subplot(4,4,3)
mvar = 'r1';
%mshk = 'a1';
mname = [mvar,'_e_',mshk];
load('base',mname);
eval(['tmp=',mname,';']);
plot([1:24],tmp,'-','linewidth',3,'color',[0 0 0]);
hold on
load('cash',mname);
eval(['tmp=',mname,';']);
plot([1:24],tmp,'--o','linewidth',3,'color',[0.4 0.4 0.4]);
grid on
xlim([1 24]);
ytickformat('%.3f');
%legend('Full model','Model with only cash');
title('Risk-free (H)');
ax = gca;
ax.GridAlpha = 0.9;  % Make grid lines less transparent.
ax.GridColor = [0.2 0.2 0.2]; % Dark 
set(gca,'fontsize',18);

subplot(4,4,4)
mvar = 'REER12';
%mshk = 'a1';
mname = [mvar,'_e_',mshk];
load('base',mname);
eval(['tmp=',mname,';']);
plot([1:24],tmp,'-','linewidth',3,'color',[0 0 0]);
hold on
load('cash',mname);
eval(['tmp=',mname,';']);
plot([1:24],tmp,'--o','linewidth',3,'color',[0.4 0.4 0.4]);
grid on
xlim([1 24]);
%legend('Full model','Model with only cash');
title('Real FX (H/F)');
ax = gca;
ax.GridAlpha = 0.9;  % Make grid lines less transparent.
ax.GridColor = [0.2 0.2 0.2]; % Dark 
set(gca,'fontsize',18);

subplot(4,4,5)
mvar = 'Ytot2';
%mshk = 'a1';
mname = [mvar,'_e_',mshk];
load('base',mname);
eval(['tmp=',mname,';']);
plot([1:24],tmp,'-','linewidth',3,'color',[0 0 0]);
hold on
load('cash',mname);
eval(['tmp=',mname,';']);
plot([1:24],tmp,'--o','linewidth',3,'color',[0.4 0.4 0.4]);
grid on
xlim([1 24]);
%legend('Full model','Model with only cash');
title('Output (F)');
ax = gca;
ax.GridAlpha = 0.9;  % Make grid lines less transparent.
ax.GridColor = [0.2 0.2 0.2]; % Dark 
set(gca,'fontsize',18);

subplot(4,4,6)
mvar = 'pi2';
%mshk = 'a1';
mname = [mvar,'_e_',mshk];
load('base',mname);
eval(['tmp=',mname,';']);
plot([1:24],tmp,'-','linewidth',3,'color',[0 0 0]);
hold on
load('cash',mname);
eval(['tmp=',mname,';']);
plot([1:24],tmp,'--o','linewidth',3,'color',[0.4 0.4 0.4]);
grid on
xlim([1 24]);
%legend('Full model','Model with only cash');
title('CPI inflation (F)');
ax = gca;
ax.GridAlpha = 0.9;  % Make grid lines less transparent.
ax.GridColor = [0.2 0.2 0.2]; % Dark 
set(gca,'fontsize',18);

subplot(4,4,7)
mvar = 'r2';
%mshk = 'a1';
mname = [mvar,'_e_',mshk];
load('base',mname);
eval(['tmp=',mname,';']);
plot([1:24],tmp,'-','linewidth',3,'color',[0 0 0]);
hold on
load('cash',mname);
eval(['tmp=',mname,';']);
plot([1:24],tmp,'--o','linewidth',3,'color',[0.4 0.4 0.4]);
grid on
xlim([1 24]);
ax = gca;
ax.YAxis.Exponent = 0;
ytickformat('%.3f');
%legend('Full model','Model with only cash');
title('Risk-free rate (F)');
ax.GridAlpha = 0.9;  % Make grid lines less transparent.
ax.GridColor = [0.2 0.2 0.2]; % Dark 
set(gca,'fontsize',18);

subplot(4,4,8)
mvar = 'NEER12';
%mshk = 'a1';
mname = [mvar,'_e_',mshk];
load('base',mname);
eval(['tmp=',mname,';']);
plot([1:24],tmp,'-','linewidth',3,'color',[0 0 0]);
hold on
load('cash',mname);
eval(['tmp=',mname,';']);
plot([1:24],tmp,'--o','linewidth',3,'color',[0.4 0.4 0.4]);
grid on
xlim([1 24]);
%legend('Full model','Model with only cash');
title('\Delta FX (H/F)');
ax = gca;
ax.GridAlpha = 0.9;  % Make grid lines less transparent.
ax.GridColor = [0.2 0.2 0.2]; % Dark 
set(gca,'fontsize',18);

subplot(4,4,9)
mvar = 'M1';
%mshk = 'a1';
mname = [mvar,'_e_',mshk];
load('base',mname);
eval(['tmp=',mname,';']);
plot([1:24],tmp,'-','linewidth',3,'color',[0 0 0]);
hold on
load('cash',mname);
eval(['tmp=',mname,';']);
plot([1:24],tmp,'--o','linewidth',3,'color',[0.4 0.4 0.4]);
grid on
xlim([1 24]);
%legend('Full model','Model with only cash');
title('Cash (H)');
ax = gca;
ax.GridAlpha = 0.9;  % Make grid lines less transparent.
ax.GridColor = [0.2 0.2 0.2]; % Dark 
set(gca,'fontsize',18);

subplot(4,4,10)
mvar = 'B11';
%mshk = 'a1';
mname = [mvar,'_e_',mshk];
load('base',mname);
eval(['tmp=',mname,';']);
plot([1:24],tmp,'-','linewidth',3,'color',[0 0 0]);
hold on
load('cash',mname);
eval(['tmp=',mname,';']);
plot([1:24],tmp,'--o','linewidth',3,'color',[0.4 0.4 0.4]);
grid on
xlim([1 24]);
%legend('Full model','Model with only cash');
title('Domestic bonds (H)');
ax = gca;
ax.GridAlpha = 0.9;  % Make grid lines less transparent.
ax.GridColor = [0.2 0.2 0.2]; % Dark 
set(gca,'fontsize',18);

subplot(4,4,11)
mvar = 'B12';
%mshk = 'a1';
mname = [mvar,'_e_',mshk];
load('base',mname);
eval(['tmp=',mname,';']);
plot([1:24],tmp,'-','linewidth',3,'color',[0 0 0]);
hold on
load('cash',mname);
eval(['tmp=',mname,';']);
plot([1:24],tmp,'--o','linewidth',3,'color',[0.4 0.4 0.4]);
grid on
xlim([1 24]);
%legend('Full model','Model with only cash');
title('Foreign bonds (H)');
ax = gca;
ax.GridAlpha = 0.9;  % Make grid lines less transparent.
ax.GridColor = [0.2 0.2 0.2]; % Dark 
set(gca,'fontsize',18);

subplot(4,4,12)
mvar = 'DC1';
%mshk = 'a1';
mname = [mvar,'_e_',mshk];
load('base',mname);
eval(['tmp=',mname,';']);
plot([1:24],tmp,'-','linewidth',3,'color',[0 0 0]);
hold on
load('cash',mname);
eval(['tmp=',mname,';']);
plot([1:24],tmp,'--o','linewidth',3,'color',[0.4 0.4 0.4]);
grid on
xlim([1 24]);
%legend('Full model','Model with only cash');
title('CBDC (H)');
ax = gca;
ax.GridAlpha = 0.9;  % Make grid lines less transparent.
ax.GridColor = [0.2 0.2 0.2]; % Dark 
set(gca,'fontsize',18);


subplot(4,4,13)
mvar = 'M2';
%mshk = 'a1';
mname = [mvar,'_e_',mshk];
load('base',mname);
eval(['tmp=',mname,';']);
plot([1:24],tmp,'-','linewidth',3,'color',[0 0 0]);
hold on
load('cash',mname);
eval(['tmp=',mname,';']);
plot([1:24],tmp,'--o','linewidth',3,'color',[0.4 0.4 0.4]);
grid on
xlim([1 24]);
%legend('Full model','Model with only cash');
title('Cash (F)');
ax = gca;
ax.GridAlpha = 0.9;  % Make grid lines less transparent.
ax.GridColor = [0.2 0.2 0.2]; % Dark 
set(gca,'fontsize',18);

subplot(4,4,14)
mvar = 'B22';
%mshk = 'a1';
mname = [mvar,'_e_',mshk];
load('base',mname);
eval(['tmp=',mname,';']);
plot([1:24],tmp,'-','linewidth',3,'color',[0 0 0]);
hold on
load('cash',mname);
eval(['tmp=',mname,';']);
plot([1:24],tmp,'--o','linewidth',3,'color',[0.4 0.4 0.4]);
grid on
xlim([1 24]);
%legend('Full model','Model with only cash');
title('Domestic bonds (F)');
ax = gca;
ax.GridAlpha = 0.9;  % Make grid lines less transparent.
ax.GridColor = [0.2 0.2 0.2]; % Dark 
set(gca,'fontsize',18);


subplot(4,4,15)
mvar = 'B21';
%mshk = 'a1';
mname = [mvar,'_e_',mshk];
load('base',mname);
eval(['tmp=',mname,';']);
plot([1:24],tmp,'-','linewidth',3,'color',[0 0 0]);
hold on
load('cash',mname);
eval(['tmp=',mname,';']);
plot([1:24],tmp,'--o','linewidth',3,'color',[0.4 0.4 0.4]);
grid on
xlim([1 24]);
%legend('Full model','Model with only cash');
title('Foreign bonds (F)');
ax = gca;
ax.GridAlpha = 0.9;  % Make grid lines less transparent.
ax.GridColor = [0.2 0.2 0.2]; % Dark 
set(gca,'fontsize',18);

subplot(4,4,16)
mvar = 'DC2';
%mshk = 'a1';
mname = [mvar,'_e_',mshk];
load('base',mname);
eval(['tmp=',mname,';']);
plot([1:24],tmp,'-','linewidth',3,'color',[0 0 0]);
hold on
load('cash',mname);
eval(['tmp=',mname,';']);
plot([1:24],tmp,'--o','linewidth',3,'color',[0.4 0.4 0.4]);
grid on
xlim([1 24]);
%legend('Full model','Model with only cash');
title('CBDC (F)');
ax = gca;
ax.GridAlpha = 0.9;  % Make grid lines less transparent.
ax.GridColor = [0.2 0.2 0.2]; % Dark 
set(gca,'fontsize',18);
savefig(mshk);
print(mshk,'-dpng');
%close all


%Second chart
figure('units','normalized','outerposition',[0 0 1 1])
subplot(3,4,1)
mvar = 'Y1';
%mshk = 'a1';
mname = [mvar,'_e_',mshk];
load('base',mname);
eval(['tmp=',mname,';']);
plot([1:24],tmp,'-','linewidth',3,'color',[0 0 0]);
hold on
load('cash',mname);
eval(['tmp=',mname,';']);
plot([1:24],tmp,'--o','linewidth',3,'color',[0.4 0.4 0.4]);
grid on
xlim([1 24]);
legend('Full model','Model with only cash','Location','best');
title('Domestic demand (H)');
ax = gca;
ax.GridAlpha = 0.9;  % Make grid lines less transparent.
ax.GridColor = [0.2 0.2 0.2]; % Dark 
set(gca,'fontsize',18);

subplot(3,4,2)
mvar = 'Y12';
%mshk = 'a1';
mname = [mvar,'_e_',mshk];
load('base',mname);
eval(['tmp=',mname,';']);
plot([1:24],tmp,'-','linewidth',3,'color',[0 0 0]);
hold on
load('cash',mname);
eval(['tmp=',mname,';']);
plot([1:24],tmp,'--o','linewidth',3,'color',[0.4 0.4 0.4]);
grid on
xlim([1 24]);
title('Imports (H)');
ax = gca;
ax.GridAlpha = 0.9;  % Make grid lines less transparent.
ax.GridColor = [0.2 0.2 0.2]; % Dark 
set(gca,'fontsize',18);

subplot(3,4,3)
mvar = 'C1';
%mshk = 'a1';
mname = [mvar,'_e_',mshk];
load('base',mname);
eval(['tmp=',mname,';']);
plot([1:24],tmp,'-','linewidth',3,'color',[0 0 0]);
hold on
load('cash',mname);
eval(['tmp=',mname,';']);
plot([1:24],tmp,'--o','linewidth',3,'color',[0.4 0.4 0.4]);
grid on
xlim([1 24]);
title('Consumption (H)');
ax = gca;
ax.GridAlpha = 0.9;  % Make grid lines less transparent.
ax.GridColor = [0.2 0.2 0.2]; % Dark 
set(gca,'fontsize',18);

subplot(3,4,4)
mvar = 'I1';
%mshk = 'a1';
mname = [mvar,'_e_',mshk];
load('base',mname);
eval(['tmp=',mname,';']);
plot([1:24],tmp,'-','linewidth',3,'color',[0 0 0]);
hold on
load('cash',mname);
eval(['tmp=',mname,';']);
plot([1:24],tmp,'--o','linewidth',3,'color',[0.4 0.4 0.4]);
grid on
xlim([1 24]);
title('Investments (H)');
ax = gca;
ax.GridAlpha = 0.9;  % Make grid lines less transparent.
ax.GridColor = [0.2 0.2 0.2]; % Dark 
set(gca,'fontsize',18);

subplot(3,4,5)
mvar = 'Y2';
%mshk = 'a1';
mname = [mvar,'_e_',mshk];
load('base',mname);
eval(['tmp=',mname,';']);
plot([1:24],tmp,'-','linewidth',3,'color',[0 0 0]);
hold on
load('cash',mname);
eval(['tmp=',mname,';']);
plot([1:24],tmp,'--o','linewidth',3,'color',[0.4 0.4 0.4]);
grid on
xlim([1 24]);
title('Domestic demand (F)');
ax = gca;
ax.GridAlpha = 0.9;  % Make grid lines less transparent.
ax.GridColor = [0.2 0.2 0.2]; % Dark 
set(gca,'fontsize',18);

subplot(3,4,6)
mvar = 'Y21';
%mshk = 'a1';
mname = [mvar,'_e_',mshk];
load('base',mname);
eval(['tmp=',mname,';']);
plot([1:24],tmp,'-','linewidth',3,'color',[0 0 0]);
hold on
load('cash',mname);
eval(['tmp=',mname,';']);
plot([1:24],tmp,'--o','linewidth',3,'color',[0.4 0.4 0.4]);
grid on
xlim([1 24]);
title('Imports (F)');
ax = gca;
ax.GridAlpha = 0.9;  % Make grid lines less transparent.
ax.GridColor = [0.2 0.2 0.2]; % Dark 
set(gca,'fontsize',18);

subplot(3,4,7)
mvar = 'C2';
%mshk = 'a1';
mname = [mvar,'_e_',mshk];
load('base',mname);
eval(['tmp=',mname,';']);
plot([1:24],tmp,'-','linewidth',3,'color',[0 0 0]);
hold on
load('cash',mname);
eval(['tmp=',mname,';']);
plot([1:24],tmp,'--o','linewidth',3,'color',[0.4 0.4 0.4]);
grid on
xlim([1 24]);
title('Consumption (F)');
ax = gca;
ax.GridAlpha = 0.9;  % Make grid lines less transparent.
ax.GridColor = [0.2 0.2 0.2]; % Dark 
set(gca,'fontsize',18);

subplot(3,4,8)
mvar = 'I2';
%mshk = 'a1';
mname = [mvar,'_e_',mshk];
load('base',mname);
eval(['tmp=',mname,';']);
plot([1:24],tmp,'-','linewidth',3,'color',[0 0 0]);
hold on
load('cash',mname);
eval(['tmp=',mname,';']);
plot([1:24],tmp,'--o','linewidth',3,'color',[0.4 0.4 0.4]);
grid on
xlim([1 24]);
title('Investments (F)');
ax = gca;
ax.GridAlpha = 0.9;  % Make grid lines less transparent.
ax.GridColor = [0.2 0.2 0.2]; % Dark 
set(gca,'fontsize',18);

subplot(3,4,9)
mvar = 'K1';
%mshk = 'a1';
mname = [mvar,'_e_',mshk];
load('base',mname);
eval(['tmp=',mname,';']);
plot([1:24],tmp,'-','linewidth',3,'color',[0 0 0]);
hold on
load('cash',mname);
eval(['tmp=',mname,';']);
plot([1:24],tmp,'--o','linewidth',3,'color',[0.4 0.4 0.4]);
grid on
xlim([1 24]);
title('Capital (H)');
ax = gca;
ax.GridAlpha = 0.9;  % Make grid lines less transparent.
ax.GridColor = [0.2 0.2 0.2]; % Dark 
set(gca,'fontsize',18);

subplot(3,4,10)
mvar = 'K2';
%mshk = 'a1';
mname = [mvar,'_e_',mshk];
load('base',mname);
eval(['tmp=',mname,';']);
plot([1:24],tmp,'-','linewidth',3,'color',[0 0 0]);
hold on
load('cash',mname);
eval(['tmp=',mname,';']);
plot([1:24],tmp,'--o','linewidth',3,'color',[0.4 0.4 0.4]);
grid on
xlim([1 24]);
title('Capital (F)');
ax = gca;
ax.GridAlpha = 0.9;  % Make grid lines less transparent.
ax.GridColor = [0.2 0.2 0.2]; % Dark 
set(gca,'fontsize',18);

subplot(3,4,11)
mvar = 'rk1';
%mshk = 'a1';
mname = [mvar,'_e_',mshk];
load('base',mname);
eval(['tmp=',mname,';']);
plot([1:24],tmp,'-','linewidth',3,'color',[0 0 0]);
hold on
load('cash',mname);
eval(['tmp=',mname,';']);
plot([1:24],tmp,'--o','linewidth',3,'color',[0.4 0.4 0.4]);
grid on
xlim([1 24]);
title('Returns on investments (H)');
ax = gca;
ax.GridAlpha = 0.9;  % Make grid lines less transparent.
ax.GridColor = [0.2 0.2 0.2]; % Dark 
set(gca,'fontsize',18);

subplot(3,4,12)
mvar = 'rk2';
%mshk = 'a1';
mname = [mvar,'_e_',mshk];
load('base',mname);
eval(['tmp=',mname,';']);
plot([1:24],tmp,'-','linewidth',3,'color',[0 0 0]);
hold on
load('cash',mname);
eval(['tmp=',mname,';']);
plot([1:24],tmp,'--o','linewidth',3,'color',[0.4 0.4 0.4]);
grid on
xlim([1 24]);
title('Returns on investments (F)');
ax = gca;
ax.GridAlpha = 0.9;  % Make grid lines less transparent.
ax.GridColor = [0.2 0.2 0.2]; % Dark 
set(gca,'fontsize',18);

savefig([mshk,'_bis']);
print([mshk,'_bis'],'-dpng');
%close all
end