% Main Code for reproducing results in "Thoughts on a Fiscal Union in EMU"
% by Josef Hollmayr, Niklas Gaddatsch and Nikolai Stähler


%% Step zero; Housekeeping
clear all;
close all;
clc;

% First Step is to simulate all fiscal union scnearios with the estimated  parameters 
dynare Buba_Fiskal_Erweiterung_FU_baseline;
 xlswrite('Tables', [sqrt(oo_.var((strmatch('dgdp2_a_t',M_.endo_names,'exact')), (strmatch('dgdp2_a_t',M_.endo_names,'exact')))) sqrt(oo_.var((strmatch('c2_a_obs',M_.endo_names,'exact')), (strmatch('c2_a_obs',M_.endo_names,'exact')))) sqrt(oo_.var((strmatch('n2_a_obs',M_.endo_names,'exact')), (strmatch('n2_a_obs',M_.endo_names,'exact')))) sqrt(oo_.var((strmatch('dgdp2_b_t',M_.endo_names,'exact')), (strmatch('dgdp2_b_t',M_.endo_names,'exact')))) sqrt(oo_.var((strmatch('c2_b_obs',M_.endo_names,'exact')), (strmatch('c2_b_obs',M_.endo_names,'exact')))) sqrt(oo_.var((strmatch('n2_b_obs',M_.endo_names,'exact')), (strmatch('n2_b_obs',M_.endo_names,'exact'))))]', 'BC', 'B4');
 xlswrite('Tables', [oo_.autocorr{1,1}((strmatch('dgdp2_a_t',M_.endo_names,'exact')), (strmatch('dgdp2_a_t',M_.endo_names,'exact'))) oo_.autocorr{1,1}((strmatch('c2_a_obs',M_.endo_names,'exact')), (strmatch('c2_a_obs',M_.endo_names,'exact'))) oo_.autocorr{1,1}((strmatch('n2_a_obs',M_.endo_names,'exact')), (strmatch('n2_a_obs',M_.endo_names,'exact'))) oo_.autocorr{1,1}((strmatch('dgdp2_b_t',M_.endo_names,'exact')), (strmatch('dgdp2_b_t',M_.endo_names,'exact'))) oo_.autocorr{1,1}((strmatch('c2_b_obs',M_.endo_names,'exact')), (strmatch('c2_b_obs',M_.endo_names,'exact'))) oo_.autocorr{1,1}((strmatch('n2_b_obs',M_.endo_names,'exact')), (strmatch('n2_b_obs',M_.endo_names,'exact')))]', 'BC', 'B12');
 xlswrite('Tables', [oo_.var((strmatch('dgdp2_a_t',M_.endo_names,'exact')), (strmatch('dgdp2_b_t',M_.endo_names,'exact')))/(sqrt(oo_.var((strmatch('dgdp2_a_t',M_.endo_names,'exact')), (strmatch('dgdp2_a_t',M_.endo_names,'exact'))))*sqrt(oo_.var((strmatch('dgdp2_b_t',M_.endo_names,'exact')), (strmatch('dgdp2_b_t',M_.endo_names,'exact'))))) oo_.var((strmatch('c2_a_obs',M_.endo_names,'exact')), (strmatch('c2_b_obs',M_.endo_names,'exact')))/(sqrt(oo_.var((strmatch('c2_a_obs',M_.endo_names,'exact')), (strmatch('c2_a_obs',M_.endo_names,'exact'))))*sqrt(oo_.var((strmatch('c2_b_obs',M_.endo_names,'exact')), (strmatch('c2_b_obs',M_.endo_names,'exact'))))) oo_.var((strmatch('n2_a_obs',M_.endo_names,'exact')), (strmatch('n2_b_obs',M_.endo_names,'exact')))/(sqrt(oo_.var((strmatch('n2_a_obs',M_.endo_names,'exact')), (strmatch('n2_a_obs',M_.endo_names,'exact'))))*sqrt(oo_.var((strmatch('n2_b_obs',M_.endo_names,'exact')), (strmatch('n2_b_obs',M_.endo_names,'exact')))))]', 'BC', 'B20');
 xlswrite('Tables', [oo_.var((strmatch('dgdp2_a_t',M_.endo_names,'exact')), (strmatch('PD_a_obs',M_.endo_names,'exact')))/(sqrt(oo_.var((strmatch('dgdp2_a_t',M_.endo_names,'exact')), (strmatch('dgdp2_a_t',M_.endo_names,'exact'))))*sqrt(oo_.var((strmatch('PD_a_obs',M_.endo_names,'exact')), (strmatch('PD_a_obs',M_.endo_names,'exact'))))) oo_.var((strmatch('dgdp2_b_t',M_.endo_names,'exact')), (strmatch('PD_b_obs',M_.endo_names,'exact')))/(sqrt(oo_.var((strmatch('dgdp2_b_t',M_.endo_names,'exact')), (strmatch('dgdp2_b_t',M_.endo_names,'exact'))))*sqrt(oo_.var((strmatch('PD_b_obs',M_.endo_names,'exact')), (strmatch('PD_b_obs',M_.endo_names,'exact')))))]', 'BC', 'B25');

 xlswrite('Tables', [oo_.var((strmatch('dgdp2_a_t',M_.endo_names,'exact')), (strmatch('c2_a_obs',M_.endo_names,'exact')))/(sqrt(oo_.var((strmatch('dgdp2_a_t',M_.endo_names,'exact')), (strmatch('dgdp2_a_t',M_.endo_names,'exact'))))*sqrt(oo_.var((strmatch('c2_a_obs',M_.endo_names,'exact')), (strmatch('c2_a_obs',M_.endo_names,'exact'))))) oo_.var((strmatch('dgdp2_b_t',M_.endo_names,'exact')), (strmatch('c2_b_obs',M_.endo_names,'exact')))/(sqrt(oo_.var((strmatch('dgdp2_b_t',M_.endo_names,'exact')), (strmatch('dgdp2_b_t',M_.endo_names,'exact'))))*sqrt(oo_.var((strmatch('c2_b_obs',M_.endo_names,'exact')), (strmatch('c2_b_obs',M_.endo_names,'exact'))))) oo_.var((strmatch('n2_a_obs',M_.endo_names,'exact')), (strmatch('n2_b_obs',M_.endo_names,'exact')))/(sqrt(oo_.var((strmatch('n2_a_obs',M_.endo_names,'exact')), (strmatch('n2_a_obs',M_.endo_names,'exact'))))*sqrt(oo_.var((strmatch('n2_b_obs',M_.endo_names,'exact')), (strmatch('n2_b_obs',M_.endo_names,'exact')))))]', 'BC', 'B30');

 
 
dynare Buba_Fiskal_Erweiterung_FU_Eq;
 xlswrite('Tables', [sqrt(oo_.var((strmatch('dgdp2_a_t',M_.endo_names,'exact')), (strmatch('dgdp2_a_t',M_.endo_names,'exact')))) sqrt(oo_.var((strmatch('c2_a_obs',M_.endo_names,'exact')), (strmatch('c2_a_obs',M_.endo_names,'exact')))) sqrt(oo_.var((strmatch('n2_a_obs',M_.endo_names,'exact')), (strmatch('n2_a_obs',M_.endo_names,'exact')))) sqrt(oo_.var((strmatch('dgdp2_b_t',M_.endo_names,'exact')), (strmatch('dgdp2_b_t',M_.endo_names,'exact')))) sqrt(oo_.var((strmatch('c2_b_obs',M_.endo_names,'exact')), (strmatch('c2_b_obs',M_.endo_names,'exact')))) sqrt(oo_.var((strmatch('n2_b_obs',M_.endo_names,'exact')), (strmatch('n2_b_obs',M_.endo_names,'exact'))))]', 'BC', 'C4');
 xlswrite('Tables', [oo_.autocorr{1,1}((strmatch('dgdp2_a_t',M_.endo_names,'exact')), (strmatch('dgdp2_a_t',M_.endo_names,'exact'))) oo_.autocorr{1,1}((strmatch('c2_a_obs',M_.endo_names,'exact')), (strmatch('c2_a_obs',M_.endo_names,'exact'))) oo_.autocorr{1,1}((strmatch('n2_a_obs',M_.endo_names,'exact')), (strmatch('n2_a_obs',M_.endo_names,'exact'))) oo_.autocorr{1,1}((strmatch('dgdp2_b_t',M_.endo_names,'exact')), (strmatch('dgdp2_b_t',M_.endo_names,'exact'))) oo_.autocorr{1,1}((strmatch('c2_b_obs',M_.endo_names,'exact')), (strmatch('c2_b_obs',M_.endo_names,'exact'))) oo_.autocorr{1,1}((strmatch('n2_b_obs',M_.endo_names,'exact')), (strmatch('n2_b_obs',M_.endo_names,'exact')))]', 'BC', 'C12');
 xlswrite('Tables', [oo_.var((strmatch('dgdp2_a_t',M_.endo_names,'exact')), (strmatch('dgdp2_b_t',M_.endo_names,'exact')))/(sqrt(oo_.var((strmatch('dgdp2_a_t',M_.endo_names,'exact')), (strmatch('dgdp2_a_t',M_.endo_names,'exact'))))*sqrt(oo_.var((strmatch('dgdp2_b_t',M_.endo_names,'exact')), (strmatch('dgdp2_b_t',M_.endo_names,'exact'))))) oo_.var((strmatch('c2_a_obs',M_.endo_names,'exact')), (strmatch('c2_b_obs',M_.endo_names,'exact')))/(sqrt(oo_.var((strmatch('c2_a_obs',M_.endo_names,'exact')), (strmatch('c2_a_obs',M_.endo_names,'exact'))))*sqrt(oo_.var((strmatch('c2_b_obs',M_.endo_names,'exact')), (strmatch('c2_b_obs',M_.endo_names,'exact'))))) oo_.var((strmatch('n2_a_obs',M_.endo_names,'exact')), (strmatch('n2_b_obs',M_.endo_names,'exact')))/(sqrt(oo_.var((strmatch('n2_a_obs',M_.endo_names,'exact')), (strmatch('n2_a_obs',M_.endo_names,'exact'))))*sqrt(oo_.var((strmatch('n2_b_obs',M_.endo_names,'exact')), (strmatch('n2_b_obs',M_.endo_names,'exact')))))]', 'BC', 'C20');
 xlswrite('Tables', [100*newss((strmatch('dgdp_a_t',M_.endo_names,'exact'))) 100*newss((strmatch('c_a_obs',M_.endo_names,'exact'))) 100*newss((strmatch('in_a_obs',M_.endo_names,'exact'))) 100*newss((strmatch('ur_a_obs',M_.endo_names,'exact'))) 100*newss((strmatch('wr_a_obs',M_.endo_names,'exact'))) 100*newss((strmatch('cG_a_obs',M_.endo_names,'exact'))) 100*newss((strmatch('inG_a_obs',M_.endo_names,'exact'))) 100*newss((strmatch('nG_a_obs',M_.endo_names,'exact'))) 100*newss((strmatch('wrG_a_obs',M_.endo_names,'exact'))) 100*newss((strmatch('TR_a_obs',M_.endo_names,'exact'))) 100*newss((strmatch('tauw_a_obs',M_.endo_names,'exact'))) 100*newss((strmatch('tausc_a_obs',M_.endo_names,'exact'))) 100*newss((strmatch('tauc_a_obs',M_.endo_names,'exact'))) 100*newss((strmatch('tauk_a_obs',M_.endo_names,'exact'))) 100*newss((strmatch('T_a_obs',M_.endo_names,'exact'))) 100*newss((strmatch('PD_a_obs',M_.endo_names,'exact')))]', 'SS', 'B3');
 xlswrite('Tables', [100*newss((strmatch('dgdp_b_t',M_.endo_names,'exact'))) 100*newss((strmatch('c_b_obs',M_.endo_names,'exact'))) 100*newss((strmatch('in_b_obs',M_.endo_names,'exact'))) 100*newss((strmatch('ur_b_obs',M_.endo_names,'exact'))) 100*newss((strmatch('wr_b_obs',M_.endo_names,'exact'))) 100*newss((strmatch('cG_b_obs',M_.endo_names,'exact'))) 100*newss((strmatch('inG_b_obs',M_.endo_names,'exact'))) 100*newss((strmatch('nG_b_obs',M_.endo_names,'exact'))) 100*newss((strmatch('wrG_b_obs',M_.endo_names,'exact'))) 100*newss((strmatch('TR_b_obs',M_.endo_names,'exact'))) 100*newss((strmatch('tauw_b_obs',M_.endo_names,'exact'))) 100*newss((strmatch('tausc_b_obs',M_.endo_names,'exact'))) 100*newss((strmatch('tauc_b_obs',M_.endo_names,'exact'))) 100*newss((strmatch('tauk_b_obs',M_.endo_names,'exact'))) 100*newss((strmatch('T_b_obs',M_.endo_names,'exact'))) 100*newss((strmatch('PD_b_obs',M_.endo_names,'exact')))]', 'SS', 'B21');
 xlswrite('Tables', [oo_.var((strmatch('dgdp2_a_t',M_.endo_names,'exact')), (strmatch('PD_a_obs',M_.endo_names,'exact')))/(sqrt(oo_.var((strmatch('dgdp2_a_t',M_.endo_names,'exact')), (strmatch('dgdp2_a_t',M_.endo_names,'exact'))))*sqrt(oo_.var((strmatch('PD_a_obs',M_.endo_names,'exact')), (strmatch('PD_a_obs',M_.endo_names,'exact'))))) oo_.var((strmatch('dgdp2_b_t',M_.endo_names,'exact')), (strmatch('PD_b_obs',M_.endo_names,'exact')))/(sqrt(oo_.var((strmatch('dgdp2_b_t',M_.endo_names,'exact')), (strmatch('dgdp2_b_t',M_.endo_names,'exact'))))*sqrt(oo_.var((strmatch('PD_b_obs',M_.endo_names,'exact')), (strmatch('PD_b_obs',M_.endo_names,'exact')))))]', 'BC', 'C25');

  xlswrite('Tables', [oo_.var((strmatch('dgdp2_a_t',M_.endo_names,'exact')), (strmatch('c2_a_obs',M_.endo_names,'exact')))/(sqrt(oo_.var((strmatch('dgdp2_a_t',M_.endo_names,'exact')), (strmatch('dgdp2_a_t',M_.endo_names,'exact'))))*sqrt(oo_.var((strmatch('c2_a_obs',M_.endo_names,'exact')), (strmatch('c2_a_obs',M_.endo_names,'exact'))))) oo_.var((strmatch('dgdp2_b_t',M_.endo_names,'exact')), (strmatch('c2_b_obs',M_.endo_names,'exact')))/(sqrt(oo_.var((strmatch('dgdp2_b_t',M_.endo_names,'exact')), (strmatch('dgdp2_b_t',M_.endo_names,'exact'))))*sqrt(oo_.var((strmatch('c2_b_obs',M_.endo_names,'exact')), (strmatch('c2_b_obs',M_.endo_names,'exact'))))) oo_.var((strmatch('n2_a_obs',M_.endo_names,'exact')), (strmatch('n2_b_obs',M_.endo_names,'exact')))/(sqrt(oo_.var((strmatch('n2_a_obs',M_.endo_names,'exact')), (strmatch('n2_a_obs',M_.endo_names,'exact'))))*sqrt(oo_.var((strmatch('n2_b_obs',M_.endo_names,'exact')), (strmatch('n2_b_obs',M_.endo_names,'exact')))))]', 'BC', 'C30');

 
 
dynare Buba_Fiskal_Erweiterung_FU_TH;
 xlswrite('Tables', [sqrt(oo_.var((strmatch('dgdp2_a_t',M_.endo_names,'exact')), (strmatch('dgdp2_a_t',M_.endo_names,'exact')))) sqrt(oo_.var((strmatch('c2_a_obs',M_.endo_names,'exact')), (strmatch('c2_a_obs',M_.endo_names,'exact')))) sqrt(oo_.var((strmatch('n2_a_obs',M_.endo_names,'exact')), (strmatch('n2_a_obs',M_.endo_names,'exact')))) sqrt(oo_.var((strmatch('dgdp2_b_t',M_.endo_names,'exact')), (strmatch('dgdp2_b_t',M_.endo_names,'exact')))) sqrt(oo_.var((strmatch('c2_b_obs',M_.endo_names,'exact')), (strmatch('c2_b_obs',M_.endo_names,'exact')))) sqrt(oo_.var((strmatch('n2_b_obs',M_.endo_names,'exact')), (strmatch('n2_b_obs',M_.endo_names,'exact'))))]', 'BC', 'D4');
 xlswrite('Tables', [oo_.autocorr{1,1}((strmatch('dgdp2_a_t',M_.endo_names,'exact')), (strmatch('dgdp2_a_t',M_.endo_names,'exact'))) oo_.autocorr{1,1}((strmatch('c2_a_obs',M_.endo_names,'exact')), (strmatch('c2_a_obs',M_.endo_names,'exact'))) oo_.autocorr{1,1}((strmatch('n2_a_obs',M_.endo_names,'exact')), (strmatch('n2_a_obs',M_.endo_names,'exact'))) oo_.autocorr{1,1}((strmatch('dgdp2_b_t',M_.endo_names,'exact')), (strmatch('dgdp2_b_t',M_.endo_names,'exact'))) oo_.autocorr{1,1}((strmatch('c2_b_obs',M_.endo_names,'exact')), (strmatch('c2_b_obs',M_.endo_names,'exact'))) oo_.autocorr{1,1}((strmatch('n2_b_obs',M_.endo_names,'exact')), (strmatch('n2_b_obs',M_.endo_names,'exact')))]', 'BC', 'D12');
 xlswrite('Tables', [oo_.var((strmatch('dgdp2_a_t',M_.endo_names,'exact')), (strmatch('dgdp2_b_t',M_.endo_names,'exact')))/(sqrt(oo_.var((strmatch('dgdp2_a_t',M_.endo_names,'exact')), (strmatch('dgdp2_a_t',M_.endo_names,'exact'))))*sqrt(oo_.var((strmatch('dgdp2_b_t',M_.endo_names,'exact')), (strmatch('dgdp2_b_t',M_.endo_names,'exact'))))) oo_.var((strmatch('c2_a_obs',M_.endo_names,'exact')), (strmatch('c2_b_obs',M_.endo_names,'exact')))/(sqrt(oo_.var((strmatch('c2_a_obs',M_.endo_names,'exact')), (strmatch('c2_a_obs',M_.endo_names,'exact'))))*sqrt(oo_.var((strmatch('c2_b_obs',M_.endo_names,'exact')), (strmatch('c2_b_obs',M_.endo_names,'exact'))))) oo_.var((strmatch('n2_a_obs',M_.endo_names,'exact')), (strmatch('n2_b_obs',M_.endo_names,'exact')))/(sqrt(oo_.var((strmatch('n2_a_obs',M_.endo_names,'exact')), (strmatch('n2_a_obs',M_.endo_names,'exact'))))*sqrt(oo_.var((strmatch('n2_b_obs',M_.endo_names,'exact')), (strmatch('n2_b_obs',M_.endo_names,'exact')))))]', 'BC', 'D20');
 xlswrite('Tables', [100*newss((strmatch('dgdp_a_t',M_.endo_names,'exact'))) 100*newss((strmatch('c_a_obs',M_.endo_names,'exact'))) 100*newss((strmatch('in_a_obs',M_.endo_names,'exact'))) 100*newss((strmatch('ur_a_obs',M_.endo_names,'exact'))) 100*newss((strmatch('wr_a_obs',M_.endo_names,'exact'))) 100*newss((strmatch('cG_a_obs',M_.endo_names,'exact'))) 100*newss((strmatch('inG_a_obs',M_.endo_names,'exact'))) 100*newss((strmatch('nG_a_obs',M_.endo_names,'exact'))) 100*newss((strmatch('wrG_a_obs',M_.endo_names,'exact'))) 100*newss((strmatch('TR_a_obs',M_.endo_names,'exact'))) 100*newss((strmatch('tauw_a_obs',M_.endo_names,'exact'))) 100*newss((strmatch('tausc_a_obs',M_.endo_names,'exact'))) 100*newss((strmatch('tauc_a_obs',M_.endo_names,'exact'))) 100*newss((strmatch('tauk_a_obs',M_.endo_names,'exact'))) 100*newss((strmatch('T_a_obs',M_.endo_names,'exact'))) 100*newss((strmatch('PD_a_obs',M_.endo_names,'exact')))]', 'SS', 'C3');
 xlswrite('Tables', [100*newss((strmatch('dgdp_b_t',M_.endo_names,'exact'))) 100*newss((strmatch('c_b_obs',M_.endo_names,'exact'))) 100*newss((strmatch('in_b_obs',M_.endo_names,'exact'))) 100*newss((strmatch('ur_b_obs',M_.endo_names,'exact'))) 100*newss((strmatch('wr_b_obs',M_.endo_names,'exact'))) 100*newss((strmatch('cG_b_obs',M_.endo_names,'exact'))) 100*newss((strmatch('inG_b_obs',M_.endo_names,'exact'))) 100*newss((strmatch('nG_b_obs',M_.endo_names,'exact'))) 100*newss((strmatch('wrG_b_obs',M_.endo_names,'exact'))) 100*newss((strmatch('TR_b_obs',M_.endo_names,'exact'))) 100*newss((strmatch('tauw_b_obs',M_.endo_names,'exact'))) 100*newss((strmatch('tausc_b_obs',M_.endo_names,'exact'))) 100*newss((strmatch('tauc_b_obs',M_.endo_names,'exact'))) 100*newss((strmatch('tauk_b_obs',M_.endo_names,'exact'))) 100*newss((strmatch('T_b_obs',M_.endo_names,'exact'))) 100*newss((strmatch('PD_b_obs',M_.endo_names,'exact')))]', 'SS', 'C21');
 xlswrite('Tables', [oo_.var((strmatch('dgdp2_a_t',M_.endo_names,'exact')), (strmatch('PD_a_obs',M_.endo_names,'exact')))/(sqrt(oo_.var((strmatch('dgdp2_a_t',M_.endo_names,'exact')), (strmatch('dgdp2_a_t',M_.endo_names,'exact'))))*sqrt(oo_.var((strmatch('PD_a_obs',M_.endo_names,'exact')), (strmatch('PD_a_obs',M_.endo_names,'exact'))))) oo_.var((strmatch('dgdp2_b_t',M_.endo_names,'exact')), (strmatch('PD_b_obs',M_.endo_names,'exact')))/(sqrt(oo_.var((strmatch('dgdp2_b_t',M_.endo_names,'exact')), (strmatch('dgdp2_b_t',M_.endo_names,'exact'))))*sqrt(oo_.var((strmatch('PD_b_obs',M_.endo_names,'exact')), (strmatch('PD_b_obs',M_.endo_names,'exact')))))]', 'BC', 'D25');

  xlswrite('Tables', [oo_.var((strmatch('dgdp2_a_t',M_.endo_names,'exact')), (strmatch('c2_a_obs',M_.endo_names,'exact')))/(sqrt(oo_.var((strmatch('dgdp2_a_t',M_.endo_names,'exact')), (strmatch('dgdp2_a_t',M_.endo_names,'exact'))))*sqrt(oo_.var((strmatch('c2_a_obs',M_.endo_names,'exact')), (strmatch('c2_a_obs',M_.endo_names,'exact'))))) oo_.var((strmatch('dgdp2_b_t',M_.endo_names,'exact')), (strmatch('c2_b_obs',M_.endo_names,'exact')))/(sqrt(oo_.var((strmatch('dgdp2_b_t',M_.endo_names,'exact')), (strmatch('dgdp2_b_t',M_.endo_names,'exact'))))*sqrt(oo_.var((strmatch('c2_b_obs',M_.endo_names,'exact')), (strmatch('c2_b_obs',M_.endo_names,'exact'))))) oo_.var((strmatch('n2_a_obs',M_.endo_names,'exact')), (strmatch('n2_b_obs',M_.endo_names,'exact')))/(sqrt(oo_.var((strmatch('n2_a_obs',M_.endo_names,'exact')), (strmatch('n2_a_obs',M_.endo_names,'exact'))))*sqrt(oo_.var((strmatch('n2_b_obs',M_.endo_names,'exact')), (strmatch('n2_b_obs',M_.endo_names,'exact')))))]', 'BC', 'D30');

 
 
 
dynare Buba_Fiskal_Erweiterung_FU_CA;
 xlswrite('Tables', [sqrt(oo_.var((strmatch('dgdp2_a_t',M_.endo_names,'exact')), (strmatch('dgdp2_a_t',M_.endo_names,'exact')))) sqrt(oo_.var((strmatch('c2_a_obs',M_.endo_names,'exact')), (strmatch('c2_a_obs',M_.endo_names,'exact')))) sqrt(oo_.var((strmatch('n2_a_obs',M_.endo_names,'exact')), (strmatch('n2_a_obs',M_.endo_names,'exact')))) sqrt(oo_.var((strmatch('dgdp2_b_t',M_.endo_names,'exact')), (strmatch('dgdp2_b_t',M_.endo_names,'exact')))) sqrt(oo_.var((strmatch('c2_b_obs',M_.endo_names,'exact')), (strmatch('c2_b_obs',M_.endo_names,'exact')))) sqrt(oo_.var((strmatch('n2_b_obs',M_.endo_names,'exact')), (strmatch('n2_b_obs',M_.endo_names,'exact'))))]', 'BC', 'E4');
 xlswrite('Tables', [oo_.autocorr{1,1}((strmatch('dgdp2_a_t',M_.endo_names,'exact')), (strmatch('dgdp2_a_t',M_.endo_names,'exact'))) oo_.autocorr{1,1}((strmatch('c2_a_obs',M_.endo_names,'exact')), (strmatch('c2_a_obs',M_.endo_names,'exact'))) oo_.autocorr{1,1}((strmatch('n2_a_obs',M_.endo_names,'exact')), (strmatch('n2_a_obs',M_.endo_names,'exact'))) oo_.autocorr{1,1}((strmatch('dgdp2_b_t',M_.endo_names,'exact')), (strmatch('dgdp2_b_t',M_.endo_names,'exact'))) oo_.autocorr{1,1}((strmatch('c2_b_obs',M_.endo_names,'exact')), (strmatch('c2_b_obs',M_.endo_names,'exact'))) oo_.autocorr{1,1}((strmatch('n2_b_obs',M_.endo_names,'exact')), (strmatch('n2_b_obs',M_.endo_names,'exact')))]', 'BC', 'E12');
 xlswrite('Tables', [oo_.var((strmatch('dgdp2_a_t',M_.endo_names,'exact')), (strmatch('dgdp2_b_t',M_.endo_names,'exact')))/(sqrt(oo_.var((strmatch('dgdp2_a_t',M_.endo_names,'exact')), (strmatch('dgdp2_a_t',M_.endo_names,'exact'))))*sqrt(oo_.var((strmatch('dgdp2_b_t',M_.endo_names,'exact')), (strmatch('dgdp2_b_t',M_.endo_names,'exact'))))) oo_.var((strmatch('c2_a_obs',M_.endo_names,'exact')), (strmatch('c2_b_obs',M_.endo_names,'exact')))/(sqrt(oo_.var((strmatch('c2_a_obs',M_.endo_names,'exact')), (strmatch('c2_a_obs',M_.endo_names,'exact'))))*sqrt(oo_.var((strmatch('c2_b_obs',M_.endo_names,'exact')), (strmatch('c2_b_obs',M_.endo_names,'exact'))))) oo_.var((strmatch('n2_a_obs',M_.endo_names,'exact')), (strmatch('n2_b_obs',M_.endo_names,'exact')))/(sqrt(oo_.var((strmatch('n2_a_obs',M_.endo_names,'exact')), (strmatch('n2_a_obs',M_.endo_names,'exact'))))*sqrt(oo_.var((strmatch('n2_b_obs',M_.endo_names,'exact')), (strmatch('n2_b_obs',M_.endo_names,'exact')))))]', 'BC', 'E20');
 xlswrite('Tables', [100*newss((strmatch('dgdp_a_t',M_.endo_names,'exact'))) 100*newss((strmatch('c_a_obs',M_.endo_names,'exact'))) 100*newss((strmatch('in_a_obs',M_.endo_names,'exact'))) 100*newss((strmatch('ur_a_obs',M_.endo_names,'exact'))) 100*newss((strmatch('wr_a_obs',M_.endo_names,'exact'))) 100*newss((strmatch('cG_a_obs',M_.endo_names,'exact'))) 100*newss((strmatch('inG_a_obs',M_.endo_names,'exact'))) 100*newss((strmatch('nG_a_obs',M_.endo_names,'exact'))) 100*newss((strmatch('wrG_a_obs',M_.endo_names,'exact'))) 100*newss((strmatch('TR_a_obs',M_.endo_names,'exact'))) 100*newss((strmatch('tauw_a_obs',M_.endo_names,'exact'))) 100*newss((strmatch('tausc_a_obs',M_.endo_names,'exact'))) 100*newss((strmatch('tauc_a_obs',M_.endo_names,'exact'))) 100*newss((strmatch('tauk_a_obs',M_.endo_names,'exact'))) 100*newss((strmatch('T_a_obs',M_.endo_names,'exact'))) 100*newss((strmatch('PD_a_obs',M_.endo_names,'exact')))]', 'SS', 'D3');
 xlswrite('Tables', [100*newss((strmatch('dgdp_b_t',M_.endo_names,'exact'))) 100*newss((strmatch('c_b_obs',M_.endo_names,'exact'))) 100*newss((strmatch('in_b_obs',M_.endo_names,'exact'))) 100*newss((strmatch('ur_b_obs',M_.endo_names,'exact'))) 100*newss((strmatch('wr_b_obs',M_.endo_names,'exact'))) 100*newss((strmatch('cG_b_obs',M_.endo_names,'exact'))) 100*newss((strmatch('inG_b_obs',M_.endo_names,'exact'))) 100*newss((strmatch('nG_b_obs',M_.endo_names,'exact'))) 100*newss((strmatch('wrG_b_obs',M_.endo_names,'exact'))) 100*newss((strmatch('TR_b_obs',M_.endo_names,'exact'))) 100*newss((strmatch('tauw_b_obs',M_.endo_names,'exact'))) 100*newss((strmatch('tausc_b_obs',M_.endo_names,'exact'))) 100*newss((strmatch('tauc_b_obs',M_.endo_names,'exact'))) 100*newss((strmatch('tauk_b_obs',M_.endo_names,'exact'))) 100*newss((strmatch('T_b_obs',M_.endo_names,'exact'))) 100*newss((strmatch('PD_b_obs',M_.endo_names,'exact')))]', 'SS', 'D21');
 xlswrite('Tables', [oo_.var((strmatch('dgdp2_a_t',M_.endo_names,'exact')), (strmatch('PD_a_obs',M_.endo_names,'exact')))/(sqrt(oo_.var((strmatch('dgdp2_a_t',M_.endo_names,'exact')), (strmatch('dgdp2_a_t',M_.endo_names,'exact'))))*sqrt(oo_.var((strmatch('PD_a_obs',M_.endo_names,'exact')), (strmatch('PD_a_obs',M_.endo_names,'exact'))))) oo_.var((strmatch('dgdp2_b_t',M_.endo_names,'exact')), (strmatch('PD_b_obs',M_.endo_names,'exact')))/(sqrt(oo_.var((strmatch('dgdp2_b_t',M_.endo_names,'exact')), (strmatch('dgdp2_b_t',M_.endo_names,'exact'))))*sqrt(oo_.var((strmatch('PD_b_obs',M_.endo_names,'exact')), (strmatch('PD_b_obs',M_.endo_names,'exact')))))]', 'BC', 'E25');

  xlswrite('Tables', [oo_.var((strmatch('dgdp2_a_t',M_.endo_names,'exact')), (strmatch('c2_a_obs',M_.endo_names,'exact')))/(sqrt(oo_.var((strmatch('dgdp2_a_t',M_.endo_names,'exact')), (strmatch('dgdp2_a_t',M_.endo_names,'exact'))))*sqrt(oo_.var((strmatch('c2_a_obs',M_.endo_names,'exact')), (strmatch('c2_a_obs',M_.endo_names,'exact'))))) oo_.var((strmatch('dgdp2_b_t',M_.endo_names,'exact')), (strmatch('c2_b_obs',M_.endo_names,'exact')))/(sqrt(oo_.var((strmatch('dgdp2_b_t',M_.endo_names,'exact')), (strmatch('dgdp2_b_t',M_.endo_names,'exact'))))*sqrt(oo_.var((strmatch('c2_b_obs',M_.endo_names,'exact')), (strmatch('c2_b_obs',M_.endo_names,'exact'))))) oo_.var((strmatch('n2_a_obs',M_.endo_names,'exact')), (strmatch('n2_b_obs',M_.endo_names,'exact')))/(sqrt(oo_.var((strmatch('n2_a_obs',M_.endo_names,'exact')), (strmatch('n2_a_obs',M_.endo_names,'exact'))))*sqrt(oo_.var((strmatch('n2_b_obs',M_.endo_names,'exact')), (strmatch('n2_b_obs',M_.endo_names,'exact')))))]', 'BC', 'E30');

 

%% Second Step is to plot IRFs (so far Tech_shock at home, abroad and IR shock)
Figures;


%% Third Step is to do counterfactuals, what would have been, if...
% Need the smoothed shocks and feed them back into the other scenarios to
% obtain the artifical series for output, inflation etc over the last decade.
Counterfactual; 


%% Fourth Step: Calculate and plot the transitional dynamics from SQ to Eq

dynare Buba_Fiskal_Erweiterung_FU_Eq_Trans;
 xlswrite('Tables', [newss(strmatch('CE_a_t',M_.endo_names,'exact')) newss(strmatch('CE_b_t',M_.endo_names,'exact')) newss(strmatch('CE_t',M_.endo_names,'exact'))], 'Welf', 'B11');
 xlswrite('Tables', [newss(strmatch('CE_o_a_t',M_.endo_names,'exact')) newss(strmatch('CE_r_a_t',M_.endo_names,'exact')) newss(strmatch('CE_a_t',M_.endo_names,'exact')) newss(strmatch('CE_o_b_t',M_.endo_names,'exact')) newss(strmatch('CE_r_b_t',M_.endo_names,'exact')) newss(strmatch('CE_b_t',M_.endo_names,'exact'))], 'Welf_Dis', 'B11');
lagrule = 1;
pl_periods = 20;
Prep_Trans_Fig;

dynare Buba_Fiskal_Erweiterung_FU_TH_Trans;
 xlswrite('Tables', [newss(strmatch('CE_a_t',M_.endo_names,'exact')) newss(strmatch('CE_b_t',M_.endo_names,'exact')) newss(strmatch('CE_t',M_.endo_names,'exact'))], 'Welf', 'B12');
 xlswrite('Tables', [newss(strmatch('CE_o_a_t',M_.endo_names,'exact')) newss(strmatch('CE_r_a_t',M_.endo_names,'exact')) newss(strmatch('CE_a_t',M_.endo_names,'exact')) newss(strmatch('CE_o_b_t',M_.endo_names,'exact')) newss(strmatch('CE_r_b_t',M_.endo_names,'exact')) newss(strmatch('CE_b_t',M_.endo_names,'exact'))], 'Welf_Dis', 'B12');
lagrule = 1;
pl_periods = 20;
Prep_Trans_Fig2;

dynare Buba_Fiskal_Erweiterung_FU_CA_Trans;
 xlswrite('Tables', [newss(strmatch('CE_a_t',M_.endo_names,'exact')) newss(strmatch('CE_b_t',M_.endo_names,'exact')) newss(strmatch('CE_t',M_.endo_names,'exact'))], 'Welf', 'B13');
 xlswrite('Tables', [newss(strmatch('CE_o_a_t',M_.endo_names,'exact')) newss(strmatch('CE_r_a_t',M_.endo_names,'exact')) newss(strmatch('CE_a_t',M_.endo_names,'exact')) newss(strmatch('CE_o_b_t',M_.endo_names,'exact')) newss(strmatch('CE_r_b_t',M_.endo_names,'exact')) newss(strmatch('CE_b_t',M_.endo_names,'exact'))], 'Welf_Dis', 'B13');
lagrule = 1;
pl_periods = 20;
Figures2;

  
%% Fifth Step is to do a Welfare analysis (now running second order approximations)

dynare Buba_Fiskal_Erweiterung_FU_base_welf;
 xlswrite('Tables', [oo_.mean(10) oo_.mean(13) oo_.mean(14)], 'Welf', 'E5');
 xlswrite('Tables', [oo_.mean(8) oo_.mean(9) oo_.mean(10) oo_.mean(11) oo_.mean(12) oo_.mean(13)], 'Welf_Dis', 'B5');

dynare Buba_Fiskal_Erweiterung_FU_Eq_welf;
 xlswrite('Tables', [oo_.mean(10) oo_.mean(13) oo_.mean(14)], 'Welf', 'E6');
 xlswrite('Tables', [oo_.mean(8) oo_.mean(9) oo_.mean(10) oo_.mean(11) oo_.mean(12) oo_.mean(13)], 'Welf_Dis', 'B6');

dynare Buba_Fiskal_Erweiterung_FU_TH_welf;
 xlswrite('Tables', [oo_.mean(10) oo_.mean(13) oo_.mean(14)], 'Welf', 'E7');
 xlswrite('Tables', [oo_.mean(8) oo_.mean(9) oo_.mean(10) oo_.mean(11) oo_.mean(12) oo_.mean(13)], 'Welf_Dis', 'B7');

dynare Buba_Fiskal_Erweiterung_FU_CA_welf;
 xlswrite('Tables', [oo_.mean(10) oo_.mean(13) oo_.mean(14)], 'Welf', 'E8');
 xlswrite('Tables', [oo_.mean(8) oo_.mean(9) oo_.mean(10) oo_.mean(11) oo_.mean(12) oo_.mean(13)], 'Welf_Dis', 'B8');

