% Code by Sujeetha
% This file extracts details from '00_' to group large number of shocks
% into some categories of shocks.

% This file loads filename_results.mat and convert data stored in
% 'oo_.shockdecomposition' to individual vectors and the vectors are then
% added to sum-up the total for that category.

% This result.mat file has 13 shocks and 52 periods. shock 14 is the
% initial value and shock 15 is the smoothed variable. Details are
% extracted to decompose GDP and Inflation data. All 13 shocks are grouped
% into demand shock, supply shock, external shock and monetary policy
% shock.

 % This file doesn't attempt to plot the data, because vectors sum_demand,
 % sum_supply,sum_external,monetary can be easily copied to excel sheets to
 % produce graphs.
 
 % Example : (oo_.shock_decomposition(55,6,:). Here 55 is the row that
 % corresponds to observed GDP data, 6 is the 6th shock. So y_demand1 is
 % the vector that has the impact of shock 6 on GDP for number of periods
 
 % to identify corresponding ordering of endogenous variables choose  '
 % M_.endo_names' and for the ordering of shocks choose 'M_.exo_names'



load('finalsep14_results.mat')

% Extracting details for historical decomposition of GDP
y_demand1=squeeze(oo_.shock_decomposition(55,6,:));
y_demand2=squeeze(oo_.shock_decomposition(55,10,:));
y_demand3=squeeze(oo_.shock_decomposition(55,11,:));
y_sum_demand= y_demand1+y_demand2+y_demand3;

y_supply1=squeeze(oo_.shock_decomposition(55,1,:));

y_supply2=squeeze(oo_.shock_decomposition(55,9,:));
y_supply3=squeeze(oo_.shock_decomposition(55,12,:));
y_sum_supply= y_supply1+y_supply2+y_supply3;

y_external1=squeeze(oo_.shock_decomposition(55,2,:));
y_external2=squeeze(oo_.shock_decomposition(55,3,:));
y_external3=squeeze(oo_.shock_decomposition(55,4,:));
y_external4=squeeze(oo_.shock_decomposition(55,7,:));
y_external5=squeeze(oo_.shock_decomposition(55,8,:));
y_external6=squeeze(oo_.shock_decomposition(55,13,:));
y_sum_external= y_external1+y_external2+y_external3+y_external4+y_external5+y_external6;

y_monetary=squeeze(oo_.shock_decomposition(55,5,:));
y_initial=squeeze(oo_.shock_decomposition(55,14,:));

Y_smoothed=squeeze(oo_.shock_decomposition(55,15,:));

% Extracting details for historical decomposition of Inflation

pi_demand1=squeeze(oo_.shock_decomposition(56,6,:));
pi_demand2=squeeze(oo_.shock_decomposition(56,10,:));
pi_demand3=squeeze(oo_.shock_decomposition(56,11,:));
pi_sum_demand= pi_demand1+pi_demand2+pi_demand3;

pi_supply1=squeeze(oo_.shock_decomposition(56,1,:));
pi_supply2=squeeze(oo_.shock_decomposition(56,9,:));
pi_supply3=squeeze(oo_.shock_decomposition(56,12,:));
pi_sum_supply= pi_supply1+pi_supply2+pi_supply3;

pi_external1=squeeze(oo_.shock_decomposition(56,2,:));
pi_external2=squeeze(oo_.shock_decomposition(56,3,:));
pi_external3=squeeze(oo_.shock_decomposition(56,4,:));
pi_external4=squeeze(oo_.shock_decomposition(56,7,:));
pi_external5=squeeze(oo_.shock_decomposition(56,8,:));
pi_external6=squeeze(oo_.shock_decomposition(56,13,:));
pi_sum_external= pi_external1+pi_external2+pi_external3+pi_external4+pi_external5+pi_external6;

pi_monetary=squeeze(oo_.shock_decomposition(56,5,:));
pi_initial=squeeze(oo_.shock_decomposition(56,14,:));

pi_smoothed=squeeze(oo_.shock_decomposition(56,15,:));


