% Note: The chain provided with the code in mhall_RBC.mat has 25000 draws for file size considerations. 
% To produce the full posterior distribution the chain length should be set to S_.Options.EST.N = 750000 
% in line 20 of run_mcmc.m

addpath functions

%% Load estimation results
load mhall_RBC.mat

%% Setup
aus_data;

% Variable and dimensions

v_ = var_dim ;

n     = v_.dim.n    ;
n_    = v_.dim.n_    ;
ns    = v_.dim.ns    ;

%% Run fiscal cases at mode

x_ = params_xx_mode;

Tz = params_T_out_mode(1);
Tsig = params_T_out_mode(2);
T_ = [Tz, Tsig];


S_.options.fiscal = 'baseline';
y_non_gss_baseline_mode = fiscal_reaction(x_,T_,S_);

S_.options.fiscal = 'gyss_baseline';
y_non_gyss_baseline_mode = fiscal_reaction(x_,T_,S_);

%% Figure

t_ = 1983:0.25:2018+200/4;

from = 2000;
up_to = 2040;

T = 341;

figure('Name', "gy_ss Case", 'Position', [1 1 600 500])
set(0,'defaulttextinterpreter','latex')
subplot(2,2,1)
plot(t_,100*exp(y_non_gyss_baseline_mode(v_.gy_obs,:)), '--', 'Color', [0.6 0.6 0.6], 'LineWidth',2)
hold on
plot(t_,100*exp(y_non_gss_baseline_mode(v_.gy_obs,:)), 'Color', 'k', 'LineWidth',2)
title('Government Spending to Output Ratio')
xlim([from up_to])
set(gca, 'Box', 'off', 'TickDir', 'in', 'TickLabelInterpreter','latex')   
ax = gca;
ax.XAxis.FontSize = 14;
ax.YAxis.FontSize = 14;
ylabel('\%', 'FontWeight', 'Normal')

subplot(2,2,2)
plot(t_,100*(y_non_gyss_baseline_mode(v_.by_obs,:))./4,   '--', 'Color', [0.6 0.6 0.6], 'LineWidth',2)
hold on
plot(t_,100*(y_non_gss_baseline_mode(v_.by_obs,:))./4, 'Color', 'k', 'LineWidth',2)
title('Public Debt to Output Ratio')
xlim([from up_to])
set(gca, 'Box', 'off', 'TickDir', 'in', 'TickLabelInterpreter','latex')   
ax = gca;
ax.XAxis.FontSize = 14;
ax.YAxis.FontSize = 14;
ylabel('\%', 'FontWeight', 'Normal')

subplot(2,2,3)
plot(t_,100*exp(y_non_gyss_baseline_mode(v_.tax,:))./exp(y_non_gyss_baseline_mode(v_.y,:)),   '--', 'Color', [0.6 0.6 0.6], 'LineWidth',2)
hold on
plot(t_,100*exp(y_non_gss_baseline_mode(v_.tax,:))./exp(y_non_gss_baseline_mode(v_.y,:)), 'Color', 'k', 'LineWidth',2)
title('Tax Revenue to Output Ratio')
xlim([from up_to])
set(gca, 'Box', 'off', 'TickDir', 'in', 'TickLabelInterpreter','latex')   
ax = gca;
ax.XAxis.FontSize = 14;
ax.YAxis.FontSize = 14;
ylabel('\%', 'FontWeight', 'Normal')

subplot(2,2,4)
debt = plot(t_,100*(y_non_gyss_baseline_mode(v_.s,:))./exp(y_non_gyss_baseline_mode(v_.y,:)),   '--', 'Color', [0.6 0.6 0.6], 'LineWidth',2);
hold on
base = plot(t_,100*(y_non_gss_baseline_mode(v_.s,:))./exp(y_non_gss_baseline_mode(v_.y,:)), 'Color', 'k', 'LineWidth',2);
title('Primary Surplus to Output Ratio')
xlim([from up_to])
set(gca, 'Box', 'off', 'TickDir', 'in', 'TickLabelInterpreter','latex')   
ax = gca;
ax.XAxis.FontSize = 14;
ax.YAxis.FontSize = 14;
ylabel('\%', 'FontWeight', 'Normal')

lgnd = legend([debt,base], {'Constant $g/y$', 'Baseline'});
set(lgnd,'Box','off', 'Interpreter','latex', 'NumColumns',2)
lgnd.Position(1) = 0.1;
lgnd.Position(2) = 0.01;
lgnd.Position(3) = 0.8;

set(gcf,'Color','w')
set(findall(gcf,'-property','FontSize'),'FontSize',12);
print -depsc '-r600' Figure_9.eps