gctest

Block-wise Granger causality and block exogeneity tests

The gctest function conducts a block-wise Granger causality test by accepting sets of time series data representing the "cause" and "effect" multivariate response variables in the test. gctest supports the inclusion of optional endogenous conditioning variables in the model for the test.

To conduct the leave-one-out, exclude-all, and block-wise Granger causality tests on the response variables of a fully specified VAR model (represented by a varm model object), see gctest.

Syntax

h = gctest(Y1,Y2)
h = gctest(Y1,Y2,Y3)
h = gctest(___,Name,Value)
[h,pvalue,stat,cvalue] = gctest(___)

Description

example

h = gctest(Y1,Y2) returns the test decision h from conducting a block-wise Granger causality test for assessing whether a set of time series variables Y1 Granger-causes a distinct set of the time series variables Y2. The gctest function conducts tests in the vector autoregression (VAR) framework and treats Y1 and Y2 as response (endogenous) variables during testing.

example

h = gctest(Y1,Y2,Y3) conducts a 1-step Granger causality test for Y1 and Y2, conditioned on a distinct set of time series variables Y3. The variable Y3 is endogenous in the underlying VAR model, but gctest does not consider it a "cause" or an "effect" in the test.

example

h = gctest(___,Name,Value) specifies options using one or more name-value pair arguments in addition to the input argument combinations in previous syntaxes. For example, 'Test',"f",'NumLags',2 specifies conducting an F test that compares the residual sum of squares between restricted and unrestricted VAR(2) models for all response variables.

example

[h,pvalue,stat,cvalue] = gctest(___) additionally returns the p-value pvalue, test statistic stat, and critical value cvalue for the test.

Examples

collapse all

Conduct a Granger causality test to assess whether the M1 money supply has an impact on the predictive distribution of the consumer price index (CPI).

Load the US macroeconomic data set Data_USEconModel.mat.

load Data_USEconModel

The data set includes the MATLAB® timetable DataTable, which contains 14 variables measured from Q1 1947 through Q1 2009. M1SL is the table variable containing the M1 money supply, and CPIAUCSL is the table variable containing the CPI. For more details, enter Description at the command line.

Visually assess whether the series are stationary by plotting them in the same figure.

figure;
yyaxis left
plot(DataTable.Time,DataTable.CPIAUCSL)
ylabel("CPI");
yyaxis right
plot(DataTable.Time,DataTable.M1SL);
ylabel("Money Supply");

Both series are nonstationary.

Stabilize the series by converting them to rates.

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

Assume that a VAR(1) model is an appropriate multivariate model for the rates. Conduct a default Granger causality test to assess whether the M1 money supply rate Granger-causes the inflation rate.

h = gctest(m1slrate,inflation)
h = logical
   1

The test decision h is 1, which indicates the rejection of the null hypothesis that the M1 money supply rate does not Granger-cause inflation.

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 α for the test is 0.05. Because this example conducts two tests, decrease α by half for each test to achieve a family-wise level of significance of 0.05.

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

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)
hM1gcIR = logical
   0

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.

Assess whether the US gross domestic product (GDP) Granger-causes CPI conditioned on the M1 money supply.

Load the US macroeconomic data set Data_USEconModel.mat.

load Data_USEconModel

The variables GDP and GDPDEF of DataTable are the US GDP and its deflator with respect to year 2000 dollars, respectively. Both series are nonstationary.

Convert the M1 money supply and CPI to rates. Convert the US GDP to the real GDP rate.

m1slrate = price2ret(DataTable.M1SL);
inflation = price2ret(DataTable.CPIAUCSL);
rgdprate = price2ret(DataTable.GDP./DataTable.GDPDEF);

Assume that a VAR(1) model is an appropriate multivariate model for the rates. Conduct a Granger causality test to assess whether the real GDP rate has an impact on the predictive distribution of the inflation rate, conditioned on the M1 money supply. The inclusion of a conditional variable forces gctest to conduct a 1-step Granger causality test.

h = gctest(rgdprate,inflation,m1slrate)
h = logical
   0

The test decision h is 0, which indicates failure to reject the null hypothesis that the real GDP rate is not a 1-step Granger-cause of inflation when you account for the M1 money supply rate.

gctest includes the M1 money supply rate as a response variable in the underlying VAR(1) model, but it does not include the M1 money supply in the computation of the test statistics.

Conduct the test again, but without conditioning on the M1 money supply rate.

h = gctest(rgdprate,inflation)
h = logical
   0

The test result is the same as before, suggesting that the real GDP rate does not Granger-cause inflation at all periods in a forecast horizon and regardless of whether you account for the M1 money supply rate in the underlying VAR(1) model.

By default, gctest assumes an underlying VAR(1) model for all specified response variables. However, a VAR(1) model might be an inappropriate representation of the data. For example, the model might not capture all the serial correlation present in the variables.

To specify a more complex underlying VAR model, you can increase the number of lags by specifying the 'NumLags' name-value pair argument of gctest.

Consider the Granger causality tests conducted in Conduct 1-Step Granger Causality Test Conditioned on Variable. Load the US macroeconomic data set Data_USEconModel.mat. Convert the M1 money supply and CPI to rates. Convert the US GDP to the real GDP rate.

load Data_USEconModel
m1slrate = price2ret(DataTable.M1SL);
inflation = price2ret(DataTable.CPIAUCSL);
rgdprate = price2ret(DataTable.GDP./DataTable.GDPDEF);

Preprocess the data by removing all missing observations (indicated by NaN).

idx = sum(isnan([m1slrate inflation rgdprate]),2) < 1;
m1slrate = m1slrate(idx);
inflation = inflation(idx);
rgdprate = rgdprate(idx);
T = numel(m1slrate); % Total sample size

Fit VAR models, with lags ranging from 1 to 4, to the real GDP and inflation rate series. Initialize each fit by specifying the first four observations. Store the Akaike information criteria (AIC) of the fits.

numseries = 2;
numlags = (1:4)';
nummdls = numel(numlags);

% Partition time base.
maxp = max(numlags); % Maximum number of required presample responses
idxpre = 1:maxp;
idxest = (maxp + 1):T;

% Preallocation
EstMdl(nummdls) = varm(numseries,0);
aic = zeros(nummdls,1);

% Fit VAR models to data.
Y0 = [rgdprate(idxpre) inflation(idxpre)]; % Presample
Y = [rgdprate(idxest) inflation(idxest)];  % Estimation sample
for j = 1:numel(numlags)
    Mdl = varm(numseries,numlags(j));
    Mdl.SeriesNames = ["rGDP" "Inflation"];
    EstMdl(j) = estimate(Mdl,Y,'Y0',Y0);
    results = summarize(EstMdl(j));
    aic(j) = results.AIC;
end

p = numlags(aic == min(aic))
p = 3

A VAR(3) model yields the best fit.

Assess whether the real GDP rate Granger-causes inflation. gctest removes p observations from the beginning of the input data to initialize the underlying VAR(p) model for estimation. Prepend only the required p = 3 presample observations to the estimation sample. Specify the concatenated series as input data. Return the p-value of the test.

rgdprate3 = [Y0((end - p + 1):end,1); Y(:,1)];
inflation3 = [Y0((end - p + 1):end,2); Y(:,2)];
[h,pvalue] = gctest(rgdprate3,inflation3,"NumLags",p)
h = logical
   1

pvalue = 7.7741e-04

The p-value is approximately 0.0008, indicating the existence of strong evidence to reject the null hypothesis of noncausality, that is, that the three real GDP rate lags in the inflation rate equation are jointly zero. Given the VAR(3) model, there is enough evidence to suggest that the real GDP rate Granger-causes at least one future value of the inflation rate.

Alternatively, you can conduct the same test by passing the estimated VAR(3) model (represented by the varm model object in EstMdl(3)), to the object function gctest. Specify a block-wise test and the "cause" and "effect" series names.

h = gctest(EstMdl(3),'Type',"block-wise",...
    'Cause',"rGDP",'Effect',"Inflation")
                         H0                          Decision      Distribution    Statistic      PValue      CriticalValue
    ____________________________________________    ___________    ____________    _________    __________    _____________

    "Exclude lagged rGDP in Inflation equations"    "Reject H0"     "Chi2(3)"       16.799      0.00077741       7.8147    
h = logical
   1

If you are testing integrated series for Granger causality, then the Wald test statistic does not follow a χ2 or F distribution, and test results can be unreliable. However, you can implement the Granger causality test in [5] by specifying the maximum integration order among all the variables in the system using the 'Integration' name-value pair argument.

Consider the Granger causality tests conducted in Conduct 1-Step Granger Causality Test Conditioned on Variable. Load the US macroeconomic data set Data_USEconModel.mat and take the log of real GDP and CPI.

load Data_USEconModel
cpi = log(DataTable.CPIAUCSL);
rgdp = log(DataTable.GDP./DataTable.GDPDEF);

Assess whether the real GDP Granger-causes CPI. Assume the series are I(1), or order-1 integrated. Also, specify an underlying VAR(3) model and the F test. Return the test statistic and p-value.

[h,pvalue,stat] = gctest(rgdp,cpi,'NumLags',3,...
    'Integration',1,'Test',"f")
h = logical
   1

pvalue = 0.0031
stat = 4.7557

The p-value = 0.0031, indicating the existence of strong evidence to reject the null hypothesis of noncausality, that is, that the three real GDP lags in the CPI equation are jointly zero. Given the VAR(3) model, there is enough evidence to suggest that real GDP Granger-causes at least one future value of the CPI.

In this case, the test augments the VAR(3) model with an additional lag. In other words, the model is a VAR(4) model. However, gctest tests only whether the first three lags are 0.

Time series are block exogenous if they do not Granger-cause any other variables in a multivariate system. Test whether the effective federal funds rate is block exogenous with respect to the real GDP, personal consumption expenditures, and inflation rates.

Load the US macroeconomic data set Data_USEconModel.mat. Convert the price series to returns.

load Data_USEconModel
inflation = price2ret(DataTable.CPIAUCSL);
rgdprate = price2ret(DataTable.GDP./DataTable.GDPDEF);
pcerate = price2ret(DataTable.PCEC);

Test whether the federal funds rate is nonstationary by conducting an augmented Dickey-Fuller test. Specify that the alternative model has a drift term and an F test.

h = adftest(DataTable.FEDFUNDS,'Model',"ard")
h = logical
   0

The test decision h = 0 indicates that the null hypothesis that the series has a unit root should not be rejected.

To stabilize the federal funds rate series, apply the first difference to it.

dfedfunds = diff(DataTable.FEDFUNDS);

Assume a 4-D VAR(3) model for the four series. Assess whether the federal funds rate is block exogenous with respect to the real GDP, personal consumption expenditures, and inflation rates. Conduct an F-based Wald test, and return the p-value, test statistic, and critical value.

cause = dfedfunds;
effects = [inflation rgdprate pcerate];
[hgc,pvalue,stat,cvalue] = gctest(cause,effects,'NumLags',2,...
    'Test',"f")
hgc = logical
   1

pvalue = 4.1619e-10
stat = 10.4383
cvalue = 2.1426

The test decision hgc = 1 indicates that the null hypothesis that the federal funds rate is block exogenous should be rejected. This result suggests that the federal funds rate Granger-causes at least one of the other variables in the system.

To determine which variables the federal funds rate Granger-causes, you can run a leave-one-out test. For more details, see gctest.

Input Arguments

collapse all

Data for the response variables representing the Granger-causes in the test, specified as a numobs1-by-1 numeric vector or a numobs1-by-numseries1 numeric matrix. numobs1 is the number of observations and numseries1 is the number of time series variables.

Row t contains the observation in time t, the last row contains the latest observation. Y1 must have enough rows to initialize and estimate the underlying VAR model. gctest uses the first NumLags observations to initialize the model for estimation.

Columns correspond to distinct time series variables.

Data Types: double | single

Data for response variables affected by the Granger-causes in the test, specified as a numobs2-by-1 numeric vector or a numobs2-by-numseries2 numeric matrix. numobs2 is the number of observations in the data and numseries2 is the number of time series variables.

Row t contains the observation in time t, the last row contains the latest observation. Y2 must have enough rows to initialize and estimate the underlying VAR model. gctest uses the first NumLags observations to initialize the model for estimation.

Columns correspond to distinct time series variables.

Data Types: double | single

Data for conditioning response variables, specified as a numobs3-by-1 numeric vector or a numobs3-by-numseries3 numeric matrix. numobs3 is the number of observations in the data and numseries3 is the number of time series variables.

Row t contains the observation in time t, the last row contains the latest observation. Y3 must have enough rows to initialize and estimate the underlying VAR model. gctest uses the first NumLags observations to initialize the model for estimation.

Columns correspond to distinct time series variables.

If you specify Y3, then Y1, Y2, and Y3 represent the response variables in the underlying VAR model. gctest assesses whether Y1 is a 1-step Granger-cause of Y2.

Data Types: double | single

Name-Value Pair Arguments

Specify optional comma-separated pairs of Name,Value arguments. Name is the argument name and Value is the corresponding value. Name must appear inside quotes. You can specify several name and value pair arguments in any order as Name1,Value1,...,NameN,ValueN.

Example: 'Alpha',0.10,'NumLags',2 specifies a 0.10 significance level for the test and uses an underlying VAR(2) model for all response variables.

Number of lagged responses to include in the underlying VAR model for all response variables, specified as the comma-separated pair consisting of 'NumLags' and a nonnegative integer. The resulting underlying model is a VAR(NumLags) model.

Example: 'NumLags',2

Data Types: double | single

Maximum order of integration among all response variables, specified as the comma-separated pair consisting of 'Integration' and a nonnegative integer.

To address integration, gctest augments the VAR(NumLags) model by adding additional lagged responses beyond NumLags to all equations during estimation. For more details, see [5] and [3].

Example: 'Integration',1

Data Types: double | single

Flag indicating the inclusion of model intercepts (constants) in the underlying VAR model, specified as the comma-separated pair consisting of 'Constant' and a value in this table.

ValueDescription
trueAll equations in the underlying VAR model have an intercept. gctest estimates the intercepts with all other estimable parameters.
falseAll underlying VAR model equations do not have an intercept. gctest sets all intercepts to 0.

Example: 'Constant',false

Data Types: logical

Flag indicating the inclusion of linear time trends in the underlying VAR model, specified as the comma-separated pair consisting of 'Trend' and a value in this table.

ValueDescription
trueAll equations in the underlying VAR model have a linear time trend. gctest estimates the linear time trend coefficients with all other estimable parameters.
falseAll underlying VAR model equations do not have a linear time trend.

Example: 'Trend',false

Data Types: logical

Predictor data for the regression component in the underlying VAR model, specified as the comma-separated pair consisting of 'X' and a numeric matrix containing numpreds columns. numpreds is the number of predictor variables.

Row t contains the observation in time t, and the last row contains the latest observation. gctest does not use the regression component in the presample period. X must have at least as many observations as the number of observations used by gctest after the presample period. Specifically, X must have at least numobsMdl.P observations, where numobs = min([numobs1 numobs2 numobs3]). If you supply more rows than necessary, gctest uses the latest observations only.

Columns correspond to individual predictor variables. gctest treats predictors as exogenous. All predictor variables are present in the regression component of each response equation.

By default, gctest excludes a regression component from all equations.

Data Types: double | single

Significance level for the test, specified as the comma-separated pair consisting of 'Alpha' and a numeric scalar in (0,1).

Example: 'Alpha',0.1

Data Types: double | single

Test statistic distribution under the null hypothesis, specified as the comma-separated pair consisting of 'Test' and a value in this table.

ValueDescription
"chi-square"gctest derives outputs from conducting a χ2 test.
"f"gctest derives outputs from conducting an F test.

For test statistic forms, see [4].

Example: 'Test',"f"

Data Types: char | string

Output Arguments

collapse all

Block-wise Granger causality test decision, returned as a logical scalar.

  • h = 1 indicates rejection of H0.

    • If you specify the conditioning response data Y3, then sufficient evidence exists to suggest that the response variables represented in Y1 are 1-step Granger-causes of the response variables represented in Y2, conditioned on the response variables represented in Y3.

    • Otherwise, sufficient evidence exists to suggest that the variables in Y1 are h-step Granger-causes of the variables in Y2 for some h ≥ 0. In other words, Y1 is block endogenous with respect to Y2.

  • h = 0 indicates failure to reject H0.

    • If you specify Y3, then the variables in Y1 are not 1-step Granger-causes of the variables in Y2, conditioned on Y3.

    • Otherwise, Y1 does not Granger-cause Y2. In other words, there is not enough evidence to reject block exogeneity of Y1 with respect to Y2.

p-value, returned as a numeric scalar.

Test statistic, returned as a numeric scalar.

Critical value for the significance level Alpha, returned as a numeric scalar.

More About

collapse all

Granger Causality Test

The Granger causality test is a statistical hypothesis test that assesses whether past and present values of a set of m1 = numseries1 time series variables y1,t, called the "cause" variables, affect the predictive distribution of a distinct set of m2 = numseries2 time series variables y2,t, called the "effect" variables. The impact is a reduction in forecast mean squared error (MSE) of y2,t. If past values of y1,t affect y2,t + h, then y1,t is an h-step Granger-cause of y2,t. In other words, y1,t Granger-causes y2,t if y1,t is an h-step Granger-cause of y2,t for all h ≥ 1.

Consider a stationary VAR(p) model for [y1,t y2,t]:

[y1,ty2,t]=c+δt+βxt+[Φ11,1Φ12,1Φ21,1Φ22,1][y1,t1y2,t1]+...+[Φ11,pΦ12,pΦ21,pΦ22,p][y1,tpy2,tp]+[ε1,tε2,t].

Assume the following conditions:

  • Future values cannot inform past values.

  • y1,t uniquely informs y2,t (no other variable has the information to inform y2,t).

If Φ21,1 = … = Φ21,p = 0m1,m2, then y1,t is not the block-wise Granger cause of y2,t + h, for all h ≥ 1 and where 0m2,m1 is an m2-by-m1 matrix of zeros. Also, y1,t is block exogenous with respect to y2,t. Consequently, the block-wise Granger causality test hypotheses are:

H0:Φ21,1=...=Φ21,p=0m2,m1H1:j{1,...,p}Φ21,j0m2,m1.

H1 implies that at least one h ≥ 1 exists such that y1,t is an h-step Granger-cause of y2,t.

gctest conducts χ2-based or F-based Wald tests (see 'Test'). For test statistic forms, see [4].

Distinct conditioning endogenous variables y3,t can be included in the system (see Y3). In this case, the VAR(p) model is:

[y1,ty2,ty3,t]=c+δt+βxt+[Φ11,1Φ12,1Φ13,1Φ21,1Φ22,1Φ23,1Φ31,1Φ32,1Φ33,1][y1,t1y2,t1y3,t1]+...+[Φ11,pΦ12,pΦ13,pΦ21,pΦ22,pΦ23,pΦ31,pΦ32,pΦ33,p][y1,tpy2,tpy3,tp]+[ε1,tε2,tε3,t].

gctest does not test the parameters associated with the conditioning variables. The test assesses only whether y1,t is an 1-step Granger-cause of y2,t.

Vector Autoregression Model

A vector autoregression (VAR) model is a stationary multivariate time series model consisting of a system of m equations of m distinct response variables as linear functions of lagged responses and other terms.

A VAR(p) model in difference-equation notation and in reduced form is

yt=c+Φ1yt1+Φ2yt2+...+Φpytp+βxt+δt+εt.

  • yt is a numseries-by-1 vector of values corresponding to numseries response variables at time t, where t = 1,...,T. The structural coefficient is the identity matrix.

  • c is a numseries-by-1 vector of constants.

  • Φj is a numseries-by-numseries matrix of autoregressive coefficients, where j = 1,...,p and Φp is not a matrix containing only zeros.

  • xt is a numpreds-by-1 vector of values corresponding to numpreds exogenous predictor variables.

  • β is a numseries-by-numpreds matrix of regression coefficients.

  • δ is a numseries-by-1 vector of linear time-trend values.

  • εt is a numseries-by-1 vector of random Gaussian innovations, each with a mean of 0 and collectively a numseries-by-numseries covariance matrix Σ. For ts, εt and εs are independent.

Condensed and in lag operator notation, the system is

Φ(L)yt=c+βxt+δt+εt,

where Φ(L)=IΦ1LΦ2L2...ΦpLp, Φ(L)yt is the multivariate autoregressive polynomial, and I is the numseries-by-numseries identity matrix.

For example, a VAR(1) model containing two response series and three exogenous predictor variables has this form:

y1,t=c1+ϕ11y1,t1+ϕ12y2,t1+β11x1,t+β12x2,t+β13x3,t+δ1t+ε1,ty2,t=c2+ϕ21y1,t1+ϕ22y2,t1+β21x1,t+β22x2,t+β23x3,t+δ2t+ε2,t.

References

[1] Granger, C. W. J. "Investigating Causal Relations by Econometric Models and Cross-Spectral Methods." Econometrica. Vol. 37, 1969, pp. 424–459.

[2] Hamilton, J. D. Time Series Analysis. Princeton, NJ: Princeton University Press, 1994.

[3] Dolado, J. J., and H. Lütkepohl. "Making Wald Tests Work for Cointegrated VAR Systems." Econometric Reviews. Vol. 15, 1996, pp. 369–386.

[4] Lütkepohl, H. New Introduction to Multiple Time Series Analysis. New York, NY: Springer-Verlag, 2007.

[5] Toda, H. Y., and T. Yamamoto. "Statistical Inferences in Vector Autoregressions with Possibly Integrated Processes." Journal of Econometrics. Vol. 66, 1995, pp. 225–250.

See Also

Objects

Functions

Introduced in R2019a