%% Parameters to load

clear all
close all
clc

%Following GALI 2015
betta   = 0.99;
siggma  = 1;
varphi  = 5;
alppha  = 1/4;
epsilon = 9;
theta   = 3/4;
upsilon = 0.4;
%rho_nu  = 0.5;
rho_a   = 0.9;
rho_y_star  = 0;
phi_pi  = 1.5;
phi_y   = 0.5/4;
eta     = 1;
rho_z   =0.5;

%Composite parameters
Omega    =(1-alppha)/(1-alppha+alppha*epsilon);        %p. 233
lambda   =(1-theta)*(1-betta*theta)/theta*Omega;       %p. 233
omega    = siggma*eta + (1-upsilon)*(siggma*eta-1);    %p. 235
Phi = 1 / (1+upsilon*(omega-1));                       %p. 235
siggma_upsilon = siggma*Phi;                           %p. 235
Gamma_a  = (1+varphi)/(siggma_upsilon*(1-alppha)+varphi+alppha);                                          %p. 238
Gamma_star  = - upsilon*(omega-1)*siggma_upsilon*(1-alppha)/(siggma_upsilon*(1-alppha)+varphi+alppha);    %p. 238
Gamma_z  = - upsilon*omega*Phi*(1-alppha)/(siggma_upsilon*(1-alppha)+varphi+alppha);                      %p. 238   
kappa_upsilon  = lambda*(siggma_upsilon+(varphi+alppha)/(1-alppha));                                      %p. 238 bottom
Phi_star=siggma_upsilon*(upsilon*(omega-1)+Gamma_star);                                                %p. 239
Phi_z=(1-upsilon)*Phi-siggma_upsilon*Gamma_z;                                                          %p. 239 


save paranews betta siggma varphi alppha epsilon theta upsilon rho_a rho_y_star phi_pi phi_y eta rho_z Omega lambda omega Phi siggma_upsilon Gamma_a Gamma_star Gamma_z kappa_upsilon Phi_star Phi_z
%rho_nu

dynare G_SOENK_news1 noclearall nolog


IRF_outputgap=[];
IRF_employment=[];
IRF_domesticinflation=[];
IRF_CPIinflation=[];
IRF_domesticpricelevel=[];
IRF_consumerpricelevel=[];
IRF_TOT=[];
IRF_nominalexrate=[];
IRF_nominalrate=[];
IRF_realrate=[];
IRF_netexport=[];

hold on

subplot(2,3,1);
plot(0:12,oo_.endo_simul(strmatch('i_ann',M_.endo_names,'exact'),M_.maximum_lag+1:M_.maximum_lag+13),'-*');
axis([0 12 -1.5 1.5]);
title('Nominal rate')
set(gca,'Fontsize',12);  %modifier la taille de la police sur les axes
set(gca,'FontWeight','bold');

hold on
subplot(2,3,2);
plot(0:12,oo_.endo_simul(strmatch('r_real_ann',M_.endo_names,'exact'),M_.maximum_lag+1:M_.maximum_lag+13),'-*');
axis([0 12 -2 1.5]);
title('Real interest rate')
set(gca,'Fontsize',12);  %modifier la taille de la police sur les axes
set(gca,'FontWeight','bold');

hold on
subplot(2,3,3)
plot(0:12,oo_.endo_simul(strmatch('y_gap',M_.endo_names,'exact'),M_.maximum_lag+1:M_.maximum_lag+13),'-*');
axis([0 12 -1.5 2]);
title('Output')
set(gca,'Fontsize',12);  %modifier la taille de la police sur les axes
set(gca,'FontWeight','bold');

hold on
subplot(2,3,4);
plot(0:12,oo_.endo_simul(strmatch('s',M_.endo_names,'exact'),M_.maximum_lag+1:M_.maximum_lag+13),'-*');
axis([0 12 -2 1.5]);
title('TOT')
set(gca,'Fontsize',12);  %modifier la taille de la police sur les axes
set(gca,'FontWeight','bold');

hold on
subplot(2,3,5);
plot(0:12,oo_.endo_simul(strmatch('er',M_.endo_names,'exact'),M_.maximum_lag+1:M_.maximum_lag+13),'-*');
axis([0 12 -3 1.5]);
title('Exchange rate')
set(gca,'Fontsize',12);  %modifier la taille de la police sur les axes
set(gca,'FontWeight','bold');

hold on
subplot(2,3,6);
plot(0:12,oo_.endo_simul(strmatch('pi',M_.endo_names,'exact'),M_.maximum_lag+1:M_.maximum_lag+13),'-*');
axis([0 12 -2 1.5]);
title('CPI inflation')
set(gca,'Fontsize',12);  %modifier la taille de la police sur les axes
set(gca,'FontWeight','bold');

hold on
%IRF_outputgap=[oo_.endo_simul('y_gap',M_.endo_names,'exact')];
%IRF_employment=[IRF_employment, 0:12,oo_.endo_simul(strmatch('n',M_.endo_names,'exact'),M_.maximum_lag+1:M_.maximum_lag+13)];
%IRF_domesticinflation=[IRF_domesticinflation, 0:12,oo_.endo_simul(strmatch('pi_h_ann',M_.endo_names,'exact'),M_.maximum_lag+1:M_.maximum_lag+13)];
%IRF_CPIinflation=[IRF_CPIinflation, 0:12,oo_.endo_simul(strmatch('pi_ann',M_.endo_names,'exact'),M_.maximum_lag+1:M_.maximum_lag+13)];
%IRF_domesticpricelevel=[IRF_domesticpricelevel, 0:12,oo_.endo_simul(strmatch('p_h',M_.endo_names,'exact'),M_.maximum_lag+1:M_.maximum_lag+13)];
%IRF_consumerpricelevel=[IRF_consumerpricelevel, 0:12,oo_.endo_simul(strmatch('p',M_.endo_names,'exact'),M_.maximum_lag+1:M_.maximum_lag+13)];
%IRF_TOT=[IRF_TOT, 0:12,oo_.endo_simul(strmatch('s',M_.endo_names,'exact'),M_.maximum_lag+1:M_.maximum_lag+13)];
%IRF_nominalexrate=[IRF_nominalexrate, 0:12,oo_.endo_simul(strmatch('er',M_.endo_names,'exact'),M_.maximum_lag+1:M_.maximum_lag+13)];
%IRF_nominalrate=[IRF_nominalrate, 0:12,oo_.endo_simul(strmatch('i_ann',M_.endo_names,'exact'),M_.maximum_lag+1:M_.maximum_lag+13)];
%IRF_realrate=[IRF_realrate, 0:12,oo_.endo_simul(strmatch('r_real',M_.endo_names,'exact'),M_.maximum_lag+1:M_.maximum_lag+13)];
%IRF_netexport=[IRF_netexport, 0:12,oo_.endo_simul(strmatch('nx',M_.endo_names,'exact'),M_.maximum_lag+1:M_.maximum_lag+13)];

%%  news for 2 periods ahead

save paranews betta siggma varphi alppha epsilon theta upsilon rho_a rho_y_star phi_pi phi_y eta rho_z Omega lambda omega Phi siggma_upsilon Gamma_a Gamma_star Gamma_z kappa_upsilon Phi_star Phi_z
%rho_nu

dynare G_SOENK_news2 noclearall nolog

subplot(2,3,1);
plot(0:12,oo_.endo_simul(strmatch('i_ann',M_.endo_names,'exact'),M_.maximum_lag+1:M_.maximum_lag+13),'-v');
axis([0 12 -1.5 1.5]);

subplot(2,3,2);
plot(0:12,oo_.endo_simul(strmatch('y_gap',M_.endo_names,'exact'),M_.maximum_lag+1:M_.maximum_lag+13),'-v');
axis([0 12 -2 1.5]);

subplot(2,3,3);
plot(0:12,oo_.endo_simul(strmatch('pi_h',M_.endo_names,'exact'),M_.maximum_lag+1:M_.maximum_lag+13),'-v');
axis([0 12 -1.5 2]);

subplot(2,3,4);
plot(0:12,oo_.endo_simul(strmatch('s',M_.endo_names,'exact'),M_.maximum_lag+1:M_.maximum_lag+13),'-v');
axis([0 12 -2 1.5]);

subplot(2,3,5);
plot(0:12,oo_.endo_simul(strmatch('er',M_.endo_names,'exact'),M_.maximum_lag+1:M_.maximum_lag+13),'-v');
axis([0 12 -3 1.5]);

subplot(2,3,6);
plot(0:12,oo_.endo_simul(strmatch('pi',M_.endo_names,'exact'),M_.maximum_lag+1:M_.maximum_lag+13),'-v');
axis([0 12 -2 1.5]);

%IRF_outputgap=[IRF_outputgap,oo_.endo_simul(strmatch('y',M_.endo_names,'exact'))];
%IRF_employment=[IRF_employment, oo_.endo_simul(strmatch('y',M_.endo_names,'exact'))];
%IRF_domesticinflation=[IRF_domesticinflation, oo_.endo_simul(strmatch('pi_h_ann',M_.endo_names,'exact'))];
%IRF_CPIinflation=[IRF_CPIinflation, oo_.endo_simul(strmatch('pi_ann',M_.endo_names,'exact'))];
%IRF_domesticpricelevel=[IRF_domesticpricelevel, oo_.endo_simul(strmatch('p_h',M_.endo_names,'exact'))];
%IRF_consumerpricelevel=[IRF_consumerpricelevel, oo_.endo_simul(strmatch('p',M_.endo_names,'exact'))];
%IRF_TOT=[IRF_TOT, oo_.endo_simul(strmatch('s',M_.endo_names,'exact'))];
%IRF_nominalexrate=[IRF_nominalexrate, oo_.endo_simul(strmatch('er',M_.endo_names,'exact'))];
%IRF_nominalrate=[IRF_nominalrate, oo_.endo_simul(strmatch('i_ann',M_.endo_names,'exact'))];
%IRF_realrate=[IRF_realrate, oo_.endo_simul(strmatch('r_real',M_.endo_names,'exact'))];
%IRF_netexport=[IRF_netexport, oo_.endo_simul(strmatch('nx',M_.endo_names,'exact'))];

%hold on

%%  news for 4 periods ahead

save paranews betta siggma varphi alppha epsilon theta upsilon rho_a rho_y_star phi_pi phi_y eta rho_z Omega lambda omega Phi siggma_upsilon Gamma_a Gamma_star Gamma_z kappa_upsilon Phi_star Phi_z
%rho_nuM

dynare G_SOENK_news3 noclearall nolog

subplot(2,3,1);
plot(0:12,oo_.endo_simul(strmatch('i_ann',M_.endo_names,'exact'),M_.maximum_lag+1:M_.maximum_lag+13),'-o');
axis([0 12 -1.5 1.5]);

subplot(2,3,2);
plot(0:12,oo_.endo_simul(strmatch('y_gap',M_.endo_names,'exact'),M_.maximum_lag+1:M_.maximum_lag+13),'-o');
axis([0 12 -2 1.5]);

subplot(2,3,3);
plot(0:12,oo_.endo_simul(strmatch('pi_h',M_.endo_names,'exact'),M_.maximum_lag+1:M_.maximum_lag+13),'-o');
axis([0 12 -1.5 2]);

subplot(2,3,4);
plot(0:12,oo_.endo_simul(strmatch('s',M_.endo_names,'exact'),M_.maximum_lag+1:M_.maximum_lag+13),'-o');
axis([0 12 -2 1.5]);

subplot(2,3,5);
plot(0:12,oo_.endo_simul(strmatch('er',M_.endo_names,'exact'),M_.maximum_lag+1:M_.maximum_lag+13),'-o');
axis([0 12 -3 1.5]);

subplot(2,3,6);
plot(0:12,oo_.endo_simul(strmatch('pi',M_.endo_names,'exact'),M_.maximum_lag+1:M_.maximum_lag+13),'-o');
axis([0 12 -2 1.5]);

