%disp 'you may need to comment line 2 in dyn_table to make it work'
%cd('/Users/Diego/Dropbox/Diego-Marta/MATLAB/Math11')

%% Create m-file
%clc
close all
dynare  dyn_main.mod 
%dynare dyn_alt2.mod %dyn_alt.mod  %noclearall

% Generate table of simulated vs. real data
[ssH, stdH, acrH, corH] = dyn_stats(M_,oo_,oo_sim);

mytable = [ 
  sprintf('UNITED STATES                                  ')
  sprintf('  Steady State Properties       Data     Model ')
  sprintf('    Hours worked               % .3f   % .3f ', 0.34, ssH.n)
  sprintf('    Investment share of GDP    % .3f   % .3f ', 0.26, ssH.i)
  sprintf('    Imports share of GDP       % .3f   % .3f ', 0.13, ssH.im) %13% IN 2018
%  sprintf('    Investment/Capital stock   % .3f   % .3f ', 0.025,ssH.xk)
  sprintf('  Standard Deviations                          ')
  sprintf('    Output                     % .3f   % .3f ', 0.016, stdH.gdp)
  sprintf('    Hours worked               % .3f   % .3f ', 1.266, stdH.n)
  sprintf('    Consumption                % .3f   % .3f ', 0.760, stdH.c)
  sprintf('    Investment                 % .3f   % .3f ', 2.771, stdH.i)
  sprintf('    Imports                    % .3f   % .3f ', 3.150, stdH.im)
  sprintf('    Exports                    % .3f   % .3f ', 2.560, stdH.ex)
  sprintf('    Net exports                % .3f   % .3f ', 0.335, stdH.nx)
  sprintf('    Terms of trade             % .3f   % .3f ', 1.574, stdH.tt)
  sprintf('  Autocorrelations                             ')
  sprintf('    Output                     % .3f   % .3f ', 0.877, acrH.gdp)
  sprintf('    Hours worked               % .3f   % .3f ', 0.927, acrH.n)
  sprintf('    Consumption                % .3f   % .3f ', 0.867, acrH.c)
  sprintf('    Investment                 % .3f   % .3f ', 0.905, acrH.i)
  sprintf('    Imports                    % .3f   % .3f ', 0.849, acrH.im)
  sprintf('    Exports                    % .3f   % .3f ', 0.858, acrH.ex)
  sprintf('    Net exports                % .3f   % .3f ', 0.772, acrH.nx)
  sprintf('    Terms of trade             % .3f   % .3f ', 0.805, acrH.tt)
  sprintf('  Domestic Correlations                        ')
  sprintf('    Output-Hours               %+.3f   %+.3f ',  0.885, corH.yn)
  sprintf('    Output-Consumption         %+.3f   %+.3f ',  0.915, corH.yc)
  sprintf('    Output-Investment          %+.3f   %+.3f ',  0.952, corH.yi)
  sprintf('    Output-Imports             %+.3f   %+.3f ',  0.782, corH.yim)
  sprintf('    Output-Exports             %+.3f   %+.3f ',  0.499, corH.yex)
  sprintf('    Output-Net exports         %+.3f   %+.3f ', -0.475, corH.ynx)
  sprintf('    Output-Terms of trade      %+.3f   %+.3f ', -0.100, corH.ytt)
  sprintf('    Consumption-Hours          %+.3f   %+.3f ',  0.737, corH.cn)
  sprintf('    Consumption-Investment     %+.3f   %+.3f ',  0.856, corH.ci)
  sprintf('    Imports-Exports            %+.3f   %+.3f ',  0.351, corH.exim)
  sprintf('  Cross country correlations                   ')
  sprintf('    Output                     %+.3f   %+.3f ',  0.654,  corH.yy)
  sprintf('    Hours worked               %+.3f   %+.3f ',  0.419,  corH.nn)
  sprintf('    Consumption                %+.3f   %+.3f ',  0.535,  corH.cc)
  sprintf('    Investment                 %+.3f   %+.3f ',  0.579,  corH.ii)
  %sprintf('    Net exports                %+.3f   %+.3f ',  00000, corH.rnx)
  sprintf('    Relative consumption-RER   %+.3f   %+.3f ', -0.050, corH.rcrer)
];

disp(mytable);  

%% Plot credit tightness (comment %% when dyn_alt2.mod)

R = cell2struct(num2cell(oo_.endo_simul),cellstr(M_.endo_names));
plot([R.xiH;R.xiF]');

% %% Figure 1
% irfs1=dyn_plotirfs(2,3,'gdpH','wH','mH',{'qH','qF'},{'pH','pF'},'totH');
% irfs=dyn_plotirfs2(1,2,{'gdpH','qgdpH'},{'totH','qtotH'});
% %% Figure 2
% irfs2=dyn_plotirfs(2,2,{'PH','PF'},{'cH','cF'},'rerH','RCH');
% irfs3=dyn_plotirfs2(2,2,{'PH','qPH'},{'cH','qcH'},{'rerH','qrerH'},{'RCH','qRCH'});


