clear all
close all

addpath c:\dynare\4.3.0\matlab;
addpath D:\Bureau\Doctoral_Courses\Attended\gradmacroII;

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Adolfson NL (2005) in blue
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

dynare Adolfson_2005_nl_replication;
IRF_nl = oo_.irfs;
save('IRF_nl','IRF_nl')

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Adolfson L (2005) (2013) in red
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

dynare EA_SR07_rep;
IRF_l = oo_.irfs;
save('IRF_l','IRF_l')

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% PLOT
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

load IRF_l;
load IRF_nl;
close all

shocks = {'epsilon_zetac' 'epsilon_zetah' 'epsilon_upsilon' ...
    'epsilon_muz' 'epsilon_epsilond' 'epsilon_lambdad' 'epsilon_lambdax' ...
    'epsilon_lambdamc' 'epsilon_lambdami' 'epsilon_epsilongc' 'epsilon_epsilonr' ...
    'epsilon_pibar' 'epsilon_psitildew' 'epsilon_tauk' 'epsilon_tauw' ...
    'epsilon_tauy' 'epsilon_tauc' 'epsilon_xtildew' ...
    'epsilon_piw' 'epsilon_rw' 'epsilon_ztildew' };

shocks_names = {'Consumption preference' 'Leisure preference' 'Investment technology' ...
    'Permanent technology' 'Final Good technology' 'Final Good Mark-up' 'Export Mark-up'  ...
    'Imported Consumption Mark-up' 'Imported Investment Mark-up' 'Government Consumption' 'Monetary Policy Shock' ...
    'Inflation Target' 'Foreign Credit Supply' 'Capital taxes' 'Wage taxes'  ...
    'Pay-role Taxes' 'Consumption taxes'  'Foreign Demand' ...
    'Foreign Inflation' 'Foreign Interest rate' 'Asymmetric technology' };

variables = {'pi_hat' 'w_barhat' 'c_hat' 'i_hat' 'x_hat' 'R_hat' 'pi_chat' 'rk_hat' 'u_hat'}; % care x_hat and u_hat

var_names = {'pi_hat' 'w_barhat' 'c_hat' 'i_hat' 'x_hat' 'R_hat' 'pi_chat' 'rk_hat' 'u_hat'};
       
shocks_plot = [1 2 4 5 6 7 8 9 11 12 13];


nvar = size(var_names,2);
nshocks = size(shocks_plot,2);
nperiods = 20;
nplot=1;

for j=1:nshocks

jj = shocks_plot(j);
figure(nplot)
    for ii=1:nvar
temp_nl = strcat(variables{ii},'_',shocks{jj});
temp_nl = getfield(IRF_nl,temp_nl);

temp = strcat(variables{ii},'_',shocks{jj});
temp = getfield(IRF_l,temp);

subplot(5,4,ii)
plot(temp_nl(1:nperiods),'-','LineWidth',1.5,'color','b');
hold on;
plot(temp(1:nperiods),'--','LineWidth',1.5,'color','r');
hold on;
plot(1:nperiods,zeros(1,nperiods),'LineWidth',1.5,'color','k');
hold on;
title([var_names(ii)],'FontSize',13)

    end
    mtit([shocks_names{jj} ' Shock'],'FontSize',20,'xoff',0,'yoff',0.015)
%     saveas(nplot,['plot_HMO_cal' num2str(nplot)],'png')
    hold off;
    nplot=nplot+1;
end


