%% Test Series for Feedback
% Time series undergo feedback when they Granger-cause each other.   Assess whether the US inflation and M1 money supply rates undergo feedback.
% Load the US macroeconomic data set Data_USEconModel.mat. Convert the price series to returns.

load Data_USEconModel
inflation = price2ret(DataTable.CPIAUCSL);
m1slrate = price2ret(DataTable.M1SL);

%
% Conduct a Granger causality test to assess whether the inflation rate Granger-causes the M1 money supply rate. Assume that an underlying VAR(1) model is appropriate for the two series. The default level of significance \alpha for the test is 0.05.  Because this example conducts two tests, decrease \alpha \; by half for each test to achieve a family-wise level of significance of 0.05.

hIRgcM1 = gctest(inflation,m1slrate,"Alpha",0.025)

% The test decision hIRgcM1 = 1 indicates rejection of the null hypothesis of noncausality. There is enough evidence to suggest that the inflation rate Granger-causes the M1 money supply rate at 0.025 level of significance.
% Conduct another Granger causality test to assess whether the M1 money supply rate Granger-causes the inflation rate.

hM1gcIR = gctest(m1slrate,inflation,"Alpha",0.025)

% The test decision hM1gcIR = 0 indicates that the null hypothesis of noncausality should not be rejected. There is not enough evidence to suggest that the M1 money supply rate Granger-causes the inflation rate at 0.025 level of significance.
% Because not enough evidence exists to suggest that the inflation rate Granger-causes the M1 money supply rate, the two series do not undergo feedback.
% Copyright 2018 The MathWorks, Inc.