# gctest

Granger causality and block exogeneity tests for vector autoregression (VAR) models

## Syntax

``h = gctest(Mdl)``
``h = gctest(Mdl,Name,Value)``
``[h,Summary] = gctest(___)``

## Description

The `gctest` object function can conduct leave-one-out, exclude-all, and block-wise Granger causality tests for the response variables of a fully specified vector autoregression (VAR) model (represented by a `varm` model object).

To conduct a block-wise Granger causality test from specified sets of time series data representing "cause" and "effect" multivariate response variables, or to address possibly integrated series for the test, see the `gctest` function.

example

````h = gctest(Mdl)` returns the test decision `h` from conducting leave-one-out Granger causality tests on all response variables that compose the VAR(p) model `Mdl`.```

example

````h = gctest(Mdl,Name,Value)` uses additional options specified by one or more name-value pair arguments. For example, `'Type',"block-wise",'Cause',1:2,'Effect',3:5` specifies conducting a block-wise test to assess whether the response variables `Mdl.SeriesNames(1:2)` Granger-cause the response variables `Mdl.SeriesNames(3:5)` conditioned on all other variables in the model.```

example

````[h,Summary] = gctest(___)` additionally returns a table that summarizes all test results, using any of the input argument combinations in the previous syntaxes. Results include test decisions and p-values.```

## Examples

collapse all

Conduct a leave-one-out Granger causality test to assess whether each variable in a 3-D VAR model Granger-causes another variable, given the third variable. The variables in the VAR model are the M1 money supply, consumer price index (CPI), and US gross domestic product (GDP).

Load the US macroeconomic data set `Data_USEconModel.mat`.

`load Data_USEconModel`

The data set includes the MATLAB® timetable `DataTimeTable`, which contains 14 variables measured from Q1 1947 through Q1 2009.

• `M1SL` is the table variable containing the M1 money supply.

• `CPIAUCSL` is the table variable containing the CPI.

• `GDP` is the table variable containing the US GDP.

For more details, enter `Description` at the command line.

Visually assess whether the series are stationary.

```plot(DataTimeTable.Time,DataTimeTable.CPIAUCSL) ylabel("Money Supply");```

```plot(DataTimeTable.Time,DataTimeTable.M1SL) ylabel("CPI");```

```plot(DataTimeTable.Time,DataTimeTable.GDP) ylabel("GDP")```

All series are nonstationary.

Stabilize the series.

• Convert the M1 money supply prices to returns.

• Convert the CPI to the inflation rate.

• Convert the GDP to the real GDP rate with respect to year 2000 dollars.

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

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

```tbl = table(m1slrate,inflation,rgdprate); tbl = rmmissing(tbl); T = size(tbl,1); % Total sample size```

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

```numseries = 3; 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 = tbl{idxpre,:}; % Presample Y = tbl{idxest,:}; % Estimation sample for j = 1:numel(numlags) Mdl = varm(numseries,numlags(j)); Mdl.SeriesNames = tbl.Properties.VariableNames; EstMdl(j) = estimate(Mdl,Y,'Y0',Y0); results = summarize(EstMdl(j)); aic(j) = results.AIC; end [~,bestidx] = min(aic); p = numlags(bestidx)```
```p = 3 ```
`BestMdl = EstMdl(bestidx);`

A VAR(3) model yields the best fit.

For each variable and equation in the system, conduct a leave-one-out Granger causality test to assess whether a variable in the fitted VAR(3) model is the 1-step Granger-cause of another variable, given the third variable.

`h = gctest(BestMdl)`
``` H0 Decision Distribution Statistic PValue CriticalValue _______________________________________________ __________________ ____________ _________ _________ _____________ "Exclude lagged inflation in m1slrate equation" "Cannot reject H0" "Chi2(3)" 7.0674 0.069782 7.8147 "Exclude lagged rgdprate in m1slrate equation" "Cannot reject H0" "Chi2(3)" 2.5585 0.4648 7.8147 "Exclude lagged m1slrate in inflation equation" "Cannot reject H0" "Chi2(3)" 2.7025 0.4398 7.8147 "Exclude lagged rgdprate in inflation equation" "Reject H0" "Chi2(3)" 14.338 0.0024796 7.8147 "Exclude lagged m1slrate in rgdprate equation" "Cannot reject H0" "Chi2(3)" 7.0352 0.070785 7.8147 "Exclude lagged inflation in rgdprate equation" "Reject H0" "Chi2(3)" 12.006 0.0073619 7.8147 ```
```h = 6x1 logical array 0 0 0 1 0 1 ```

`gctest` conducts six tests, so `h` is a 6-by-1 logical vector of test decisions corresponding to the rows of the test summary table. The results indicate the following decisions, at a 5% level of significance:

• Do not reject the claim that the inflation rate is not the 1-step Granger-cause of the M1 money supply rate, given the real GDP rate (`h(1)` = `0`).

• Do not reject the claim that the real GDP rate is not the 1-step Granger-cause of the M1 money supply rate, given the inflation rate (`h(2)` = `0`).

• Do not reject the claim that the M1 money supply rate is not the 1-step Granger-cause of the inflation rate, given the real GDP rate (`h(3)` = `0`).

• Reject the claim that the real GDP rate is not the 1-step Granger-cause of the inflation rate, given the M1 money supply rate (`h(4)` = 1).

• Do not reject the claim that the M1 money supply rate is not the 1-step Granger-cause of the real GDP rate, given the inflation rate (`h(5)` = `0`).

• Reject the claim that the inflation rate is not the 1-step Granger-cause of the real GDP rate, given the M1 money supply rate (`h(6)` = 1).

Because the inflation and real GDP rates are 1-step Granger-causes of each other, they constitute a feedback loop.

Consider the 3-D VAR(3) model and leave-one-out Granger causality test in Conduct Leave-One-Out Granger Causality Test.

Load the US macroeconomic data set `Data_USEconModel.mat`. Preprocess the data. Fit a VAR(3) model to the preprocessed data.

```load Data_USEconModel m1slrate = price2ret(DataTimeTable.M1SL); inflation = price2ret(DataTimeTable.CPIAUCSL); rgdprate = price2ret(DataTimeTable.GDP./DataTimeTable.GDPDEF); tbl = table(m1slrate,inflation,rgdprate); tbl = rmmissing(tbl); Mdl = varm(3,3); Mdl.SeriesNames = tbl.Properties.VariableNames; EstMdl = estimate(Mdl,tbl{5:end,:},'Y0',tbl{2:4,:});```

Conduct an exclude-all Granger causality test on the variables of the fitted model.

`h = gctest(EstMdl,'Type',"exclude-all");`
``` H0 Decision Distribution Statistic PValue CriticalValue ________________________________________________________ __________________ ____________ _________ _________ _____________ "Exclude all but lagged m1slrate in m1slrate equation" "Cannot reject H0" "Chi2(6)" 9.477 0.14847 12.592 "Exclude all but lagged inflation in inflation equation" "Reject H0" "Chi2(6)" 19.475 0.0034327 12.592 "Exclude all but lagged rgdprate in rgdprate equation" "Reject H0" "Chi2(6)" 19.16 0.0039014 12.592 ```

`gctest` conducts `numtests` = 3 tests. The results indicate the following decisions, each at a 5% level of significance:

• Do not reject the claim that the inflation and real GDP rates do not Granger-cause the M1 money supply rate.

• Reject the claim that the M1 money supply and real GDP rates do not Granger-cause the inflation rate.

• Reject the claim that the M1 money supply and inflation rates do not Granger-cause the real GDP rate.

The false discovery rate increases with the number of simultaneous hypothesis tests you conduct. To combat the increase, decrease the level of significance per test by using the `'Alpha'` name-value pair argument. Consider the 3-D VAR(3) model and leave-one-out Granger causality test in Conduct Leave-One-Out Granger Causality Test.

Load the US macroeconomic data set `Data_USEconModel.mat`. Preprocess the data. Fit a VAR(3) model to the preprocessed data.

```load Data_USEconModel m1slrate = price2ret(DataTimeTable.M1SL); inflation = price2ret(DataTimeTable.CPIAUCSL); rgdprate = price2ret(DataTimeTable.GDP./DataTimeTable.GDPDEF); tbl = table(m1slrate,inflation,rgdprate); tbl = rmmissing(tbl); Mdl = varm(3,3); Mdl.SeriesNames = tbl.Properties.VariableNames; EstMdl = estimate(Mdl,tbl{5:end,:},'Y0',tbl{2:4,:});```

A leave-one-out Granger causality test on the variables in the model results in `numtests` = 6 simultaneous tests. Conduct the tests, but specify a family-wise significance level of 0.05 by specifying a level of significance of `alpha` = `0.05/numtests` for each test.

```numtests = 6; alpha = 0.05/numtests```
```alpha = 0.0083 ```
`gctest(EstMdl,'Alpha',alpha);`
``` H0 Decision Distribution Statistic PValue CriticalValue _______________________________________________ __________________ ____________ _________ _________ _____________ "Exclude lagged inflation in m1slrate equation" "Cannot reject H0" "Chi2(3)" 7.0674 0.069782 11.739 "Exclude lagged rgdprate in m1slrate equation" "Cannot reject H0" "Chi2(3)" 2.5585 0.4648 11.739 "Exclude lagged m1slrate in inflation equation" "Cannot reject H0" "Chi2(3)" 2.7025 0.4398 11.739 "Exclude lagged rgdprate in inflation equation" "Reject H0" "Chi2(3)" 14.338 0.0024796 11.739 "Exclude lagged m1slrate in rgdprate equation" "Cannot reject H0" "Chi2(3)" 7.0352 0.070785 11.739 "Exclude lagged inflation in rgdprate equation" "Reject H0" "Chi2(3)" 12.006 0.0073619 11.739 ```

The test decisions of these more conservative tests are the same as the tests decisions in Conduct Leave-One-Out Granger Causality Test. However, the conclusions of the conservative tests hold simultaneously at a 5% level of significance.

Consider the 3-D VAR(3) model and leave-one-out Granger causality test in Conduct Leave-One-Out Granger Causality Test.

Load the US macroeconomic data set `Data_USEconModel.mat`. Preprocess the data. Fit a VAR(3) model to the preprocessed data.

```load Data_USEconModel m1slrate = price2ret(DataTimeTable.M1SL); inflation = price2ret(DataTimeTable.CPIAUCSL); rgdprate = price2ret(DataTimeTable.GDP./DataTimeTable.GDPDEF); tbl = table(m1slrate,inflation,rgdprate); tbl = rmmissing(tbl); Mdl = varm(3,3); Mdl.SeriesNames = tbl.Properties.VariableNames; EstMdl = estimate(Mdl,tbl{5:end,:},'Y0',tbl{2:4,:});```

Conduct a leave-one-out Granger causality test on the variables of the fitted model. Return the test result summary table and suppress the test results display.

`[~,Summary] = gctest(EstMdl,'Display',false)`
```Summary=6×6 table H0 Decision Distribution Statistic PValue CriticalValue _______________________________________________ __________________ ____________ _________ _________ _____________ "Exclude lagged inflation in m1slrate equation" "Cannot reject H0" "Chi2(3)" 7.0674 0.069782 7.8147 "Exclude lagged rgdprate in m1slrate equation" "Cannot reject H0" "Chi2(3)" 2.5585 0.4648 7.8147 "Exclude lagged m1slrate in inflation equation" "Cannot reject H0" "Chi2(3)" 2.7025 0.4398 7.8147 "Exclude lagged rgdprate in inflation equation" "Reject H0" "Chi2(3)" 14.338 0.0024796 7.8147 "Exclude lagged m1slrate in rgdprate equation" "Cannot reject H0" "Chi2(3)" 7.0352 0.070785 7.8147 "Exclude lagged inflation in rgdprate equation" "Reject H0" "Chi2(3)" 12.006 0.0073619 7.8147 ```

`Summary` is a MATLAB table containing `numtests` = 6 rows. The rows contain the results of each test. The columns are table variables containing characteristics of the tests.

Extract the $\mathit{p}$-values of the tests.

`pvalues = Summary.PValue`
```pvalues = 6×1 0.0698 0.4648 0.4398 0.0025 0.0708 0.0074 ```

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(DataTimeTable.CPIAUCSL); rgdprate = price2ret(DataTimeTable.GDP./DataTimeTable.GDPDEF); pcerate = price2ret(DataTimeTable.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 $\mathit{F}$ test.

`StatTbl = adftest(DataTimeTable,DataVariable="FEDFUNDS",Model="ard")`
```StatTbl=1×8 table h pValue stat cValue Lags Alpha Model Test _____ ________ _______ _______ ____ _____ _______ ______ Test 1 false 0.071419 -2.7257 -2.8751 0 0.05 {'ARD'} {'T1'} ```

The test decision `h` = `0` indicates that the null hypothesis that the series has a unit root should not be rejected, at 0.05 significance level.

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

`dfedfunds = diff(DataTimeTable.FEDFUNDS);`

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

```tbl = table(inflation,pcerate,rgdprate,dfedfunds); tbl = rmmissing(tbl); T = size(tbl,1); % Total sample size```

Assume a 4-D VAR(3) model for the four series. Initialize the model by using the first three observations, and fit the model to the rest of the data. Assign names to the series in the model.

```Mdl = varm(4,3); Mdl.SeriesNames = tbl.Properties.VariableNames; EstMdl = estimate(Mdl,tbl{4:end,:},Y0=tbl{1:3,:});```

Assess whether the federal funds rate is block exogenous with respect to the real GDP, personal consumption expenditures, and inflation rates. Conduct an $\mathit{F}$-based Wald test, and return the test decision and summary table. Suppress the test results display.

```cause = "dfedfunds"; effects = ["inflation" "pcerate" "rgdprate"]; [h,Summary] = gctest(EstMdl,Type="blockwise", ... Cause=cause,Effect=effects,Test="f",Display=false);```

`gctest` conducts one test. `h` = `1` indicates, at a 5% level of significance, rejection of the null hypothesis that the federal funds rate is block exogenous with respect to the other variables in the VAR model. This result suggests that the federal funds rate Granger-causes at least one of the other variables in the system.

Alternatively, you can conduct the same blockwise Granger causality test by passing the data to the `gctest` function.

```causedata = tbl.dfedfunds; EffectsData = tbl{:,effects}; [hgc,pvalue,stat,cvalue] = gctest(causedata,EffectsData,... NumLags=3,Test="f")```
```hgc = logical 1 ```
```pvalue = 9.0805e-09 ```
```stat = 6.9869 ```
```cvalue = 1.9265 ```

To determine which variables are Granger-caused by the federal funds rate, conduct a leave-one-out test and specify the "cause" and "effects."

`gctest(EstMdl,Cause=cause,Effect=effects);`
``` H0 Decision Distribution Statistic PValue CriticalValue ________________________________________________ ___________ ____________ _________ __________ _____________ "Exclude lagged dfedfunds in inflation equation" "Reject H0" "Chi2(3)" 26.157 8.8433e-06 7.8147 "Exclude lagged dfedfunds in pcerate equation" "Reject H0" "Chi2(3)" 10.151 0.017325 7.8147 "Exclude lagged dfedfunds in rgdprate equation" "Reject H0" "Chi2(3)" 10.651 0.013772 7.8147 ```

The test results suggest the following decisions, each at a 5% level of significance:

• Reject the claim that the federal funds rate is not a 1-step Granger-cause of the inflation rate, given all other variables in the VAR model.

• Reject the claim that the federal funds rate is not a 1-step Granger-cause of the personal consumption expenditures rate, given all other variables in the VAR model.

• Reject the claim that the federal funds rate is not a 1-step Granger-cause of the real GDP rate, given all other variables in the VAR model.

## Input Arguments

collapse all

VAR model, specified as a `varm` model object created by `varm` or `estimate`. `Mdl` must be fully specified.

### Name-Value Arguments

Specify optional pairs of arguments as `Name1=Value1,...,NameN=ValueN`, where `Name` is the argument name and `Value` is the corresponding value. Name-value arguments must appear after other arguments, but the order of the pairs does not matter.

Before R2021a, use commas to separate each name and value, and enclose `Name` in quotes.

Example: `'Type',"block-wise",'Cause',1:2,'Effect',3:5` specifies conducting a block-wise test to assess whether the response variables `Mdl.SeriesNames(1:2)` Granger-cause the response variables `Mdl.SeriesNames(3:5)` conditioned on all other variables in the model.

Granger causality test to conduct, specified as the comma-separated pair consisting of `'Type'` and a value in this table. Suppose that the VAR model `Mdl` is m-D (m = `Mdl.NumSeries`).

ValueDescription
`"leave-one-out"`

Leave-one-out test

For j = 1,…,m, k = 1,…,m, and jk, `gctest` tests the null hypothesis that variable j does not Granger-cause variable k, conditioned on all other variables in the model. This setting conducts `numtests` = m(m – 1) tests.

`"exclude-all"`

Exclude-all test

For j = 1,…,m, `gctest` tests the null hypothesis that all other response variables do not jointly Granger-cause response variable j. This setting conducts `numtests` = m tests.

`"block-wise"`

Block-wise test

`gctest` tests the null hypothesis that the response variables specified by `Causes` do not jointly Granger-cause the response variables specified by `Effects`. This setting conducts `numtests` = 1 test. If you do not specify `Causes` and `Effects`, then `gctest` tests the null hypothesis that all lag coefficients, including self lags, are zero.

Example: `'Type',"exclude-all"`

Data Types: `char` | `string`

Significance level for each conducted test (see `Type`), 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`

VAR model response variables representing Granger-causes in the 1-step block-wise test, specified as the comma-separated pair consisting of `'Cause'` and a numeric vector of variable indices or a vector of variable names.

For either input type, values correspond to the response series names in the `SeriesNames` property of the input VAR model object `Mdl`, which you access by using dot notation: `Mdl.SeriesNames`.

Example: `'Cause',["rGDP" "m1sl"]`

Example: `'Cause',1:2`

Data Types: `single` | `double` | `char` | `string`

VAR model response variables affected by Granger-causes in the 1-step block-wise test, specified as the comma-separated pair consisting of `'Effect'` and a numeric vector of variable indices or a vector of variable names.

For either input type, values correspond to the response series names in the `SeriesNames` property of the input VAR model object `Mdl`, which you access by using dot notation: `Mdl.SeriesNames`.

Example: `'Cause',"inflation"`

Example: `'Cause',3`

Data Types: `single` | `double` | `char` | `string`

Flag to display a test summary table at the command line, specified as the comma-separated pair consisting of `'Display'` and a value in this table.

ValueDescription
`true`Display a test summary table, as returned in `Summary`, at the command line.
`false`Do not display a test summary table.

Example: `'Display',false`

Data Types: `logical`

## Output Arguments

collapse all

Granger causality test decisions, returned as a logical scalar or `numtests`-by-1 logical vector. For `j` = 1,…,`numtests`:

• `h(j)` = `1` indicates that test `j` rejects the null hypothesis H0 that the "cause" variables are not 1-step Granger-causes of the "effect" variables. Sufficient evidence exists to support Granger causality and endogeneity of the "cause" variables.

• `h(j)` = `0` indicates failure to reject H0.

The number of tests conducted depends on the specified test type (see `Type`). For more details on the conducted tests, display or return the test summary table (see `Display` and `Summary`, respectively).

Summary of the test results, returned as a table.

Each row of `Summary` corresponds to one of the `numtests` conducted tests. The columns describe the characteristics of the tests.

Column NameDescriptionData Type
`H0`Granger causality or block exogeneity test null hypothesis descriptionString scalar
`Decision`Test decisions corresponding to `h`String scalar
`Distribution`Test statistic distribution under the null hypothesisString scalar
`Statistic`Value of test statisticNumeric scalar
`PValue`Test p-valueNumeric scalar
`CriticalValue`Critical value for the significance level `Alpha`Numeric scalar

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 time series variables, called the "cause" variables, affect the predictive distribution of a distinct set of m2 time series variables, called the "effect" variables. The impact is a reduction in forecast mean squared error (MSE) of the "effect" variables. If past values of the "cause" variables affect the "effect" variables h-steps into the forecast horizon, the "cause" variables are h-step Granger-causes of the "effect" variables. If the "cause" variables are h-step Granger-causes of the "effect" variables for all h ≥ 1, the "cause" variables Granger-cause the "effect" variables.

`gctest` provides block-wise, leave-one-out, and exclude-all variations of the Granger causality tests (see `'Type'`) and χ2-based or F-based Wald tests (see `'Test'`). For test statistic forms, see [4].

For all test types, assume the following conditions:

• Future values cannot inform past values.

• The "cause" variables uniquely inform the "effect" variables. No other variables have the information to inform the "effect" variables.

Block-Wise Test

Let y1,t denote the m1 "cause" variables and y2,t denote the m2 "effect" variables. Consider a stationary VAR(p) model for [y1,t y2,t]:

`$\left[\begin{array}{c}{y}_{1,t}\\ {y}_{2,t}\end{array}\right]=c+\delta t+\beta {x}_{t}+\left[\begin{array}{cc}{\Phi }_{11,1}& {\Phi }_{12,1}\\ {\Phi }_{21,1}& {\Phi }_{22,1}\end{array}\right]\left[\begin{array}{c}{y}_{1,t-1}\\ {y}_{2,t-1}\end{array}\right]+...+\left[\begin{array}{cc}{\Phi }_{11,p}& {\Phi }_{12,p}\\ {\Phi }_{21,p}& {\Phi }_{22,p}\end{array}\right]\left[\begin{array}{c}{y}_{1,t-p}\\ {y}_{2,t-p}\end{array}\right]+\left[\begin{array}{c}{\epsilon }_{1,t}\\ {\epsilon }_{2,t}\end{array}\right].$`

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:

`$\begin{array}{l}{H}_{0}:{\Phi }_{21,1}=...={\Phi }_{21,p}={0}_{{m}_{2},{m}_{1}}\\ {H}_{1}:\exists j\in \left\{1,...,p\right\}\ni {\Phi }_{21,j}\ne {0}_{{m}_{2},{m}_{1}}.\end{array}$`

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

Distinct endogenous variables in the VAR model that are not "causes" or "effects" in the block-wise test are conditioning variables. If conditioning variables exist in the model, h = 1. In other words, `gctest` tests the null hypothesis of 1-step noncausality.

Leave-One-Out Test

For each response variable and equation in the VAR model, `gctest` removes lags of a variable from an equation, except self lags, and tests the null hypothesis of 1-step noncausality. Specifically, consider the m-D VAR(p) model

`$\left[\begin{array}{c}{y}_{j,t}\\ \begin{array}{l}{y}_{k,t}\\ {y}_{s,t}\end{array}\end{array}\right]=c+\delta t+\beta {x}_{t}+\left[\begin{array}{ccc}{\varphi }_{11,1}& {\varphi }_{12,1}& {\varphi }_{13,1}\\ {\varphi }_{21,1}& {\varphi }_{22,1}& {\varphi }_{23,1}\\ {\varphi }_{31,1}& {\varphi }_{32,1}& {\Phi }_{33,1}\end{array}\right]\left[\begin{array}{c}{y}_{1,t-1}\\ \begin{array}{l}{y}_{2,t-1}\\ {y}_{3,t-1}\end{array}\end{array}\right]+...+\left[\begin{array}{ccc}{\varphi }_{11,p}& {\varphi }_{12,p}& {\varphi }_{13,p}\\ {\varphi }_{21,p}& {\varphi }_{22,p}& {\varphi }_{23,p}\\ {\varphi }_{31,p}& {\varphi }_{32,p}& {\Phi }_{33,p}\end{array}\right]\left[\begin{array}{c}{y}_{j,t-p}\\ \begin{array}{l}{y}_{k,t-p}\\ {y}_{s,t-p}\end{array}\end{array}\right]+\left[\begin{array}{c}{\epsilon }_{j,t}\\ \begin{array}{l}{\epsilon }_{k,t}\\ {\epsilon }_{s,t}\end{array}\end{array}\right],$`

where:

• yj,t and yk,t are 1-D series representing the "cause" and "effect" variables, respectively.

• ys,t is an (m – 2)-D series of all other endogenous variables; s = {1,…,m} \ {j,k}.

• For = 1,…,p:

• ϕ11,, ϕ12,, ϕ21,, and ϕ22, are scalar lag coefficients.

• ϕ13,, ϕ31,, ϕ23,, and ϕ32, are (m – 2)-D vectors of lag coefficients.

• Φ33, is an (m – 2)-by-(m – 2) matrix of lag coefficients.

For j = 1,…,m, k = 1,…,m, and jk, `gctest` tests the null hypothesis that yj,t is not a 1-step Granger-cause of yk,t, given ys,t:

`$\begin{array}{l}{H}_{0}:{\varphi }_{21,1}=...={\varphi }_{21,p}=0\\ {H}_{1}:\exists r\in \left\{1,...,p\right\}\ni {\varphi }_{21,r}\ne 0.\end{array}$`

`gctest` conducts m(m – 1) tests.

Exclude-All Test

For each equation in the VAR model, `gctest` removes all lags from the equation, except self lags, and tests for h-step noncausality. Specifically, consider the m-D VAR(p) model

`$\left[\begin{array}{c}{y}_{k,t}\\ {y}_{-k,t}\end{array}\right]=c+\delta t+\beta {x}_{t}+\left[\begin{array}{cc}{\varphi }_{kk,1}& {\varphi }_{k-k,1}\\ {\varphi }_{-kk,1}& {\Phi }_{-k-k,1}\end{array}\right]\left[\begin{array}{c}{y}_{k,t-1}\\ {y}_{-k,t-1}\end{array}\right]+...+\left[\begin{array}{cc}{\varphi }_{kk,p}& {\varphi }_{k-k,p}\\ {\varphi }_{-kk,p}& {\Phi }_{-k-k,p}\end{array}\right]\left[\begin{array}{c}{y}_{k,t-p}\\ {y}_{-k,t-p}\end{array}\right]+\left[\begin{array}{c}{\epsilon }_{k,t}\\ {\epsilon }_{-k,t}\end{array}\right],$`

where:

• y-k,t is an (m – 1)-D series of all endogenous variables in the VAR model (except yk,t) representing the "cause" variables.

• yk,t is the 1-D series representing the "effect" variable.

• For = 1,…,p:

• ϕkk, is a scalar lag coefficient.

• ϕk-k, and ϕ-kk, are (m – 1)-D vectors of lag coefficients.

• Φ-k-k, is an (m – 1)-by-(m – 1) matrix of lag coefficients.

For k = 1,…,m, `gctest` tests the null hypothesis that the variables in y-k,t are not h-step Granger-causes of yk,t:

`$\begin{array}{l}{H}_{0}:{\varphi }_{21,1}=...={\varphi }_{21,p}=0\\ {H}_{1}:\exists r\in \left\{1,...,p\right\}\ni {\varphi }_{21,r}\ne 0.\end{array}$`

`gctest` conducts m tests.

### 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

`${y}_{t}=c+{\Phi }_{1}{y}_{t-1}+{\Phi }_{2}{y}_{t-2}+...+{\Phi }_{p}{y}_{t-p}+\beta {x}_{t}+\delta t+{\epsilon }_{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

`$\Phi \left(L\right){y}_{t}=c+\beta {x}_{t}+\delta t+{\epsilon }_{t},$`

where $\Phi \left(L\right)=I-{\Phi }_{1}L-{\Phi }_{2}{L}^{2}-...-{\Phi }_{p}{L}^{p}$, Φ(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:

`$\begin{array}{l}{y}_{1,t}={c}_{1}+{\varphi }_{11}{y}_{1,t-1}+{\varphi }_{12}{y}_{2,t-1}+{\beta }_{11}{x}_{1,t}+{\beta }_{12}{x}_{2,t}+{\beta }_{13}{x}_{3,t}+{\delta }_{1}t+{\epsilon }_{1,t}\\ {y}_{2,t}={c}_{2}+{\varphi }_{21}{y}_{1,t-1}+{\varphi }_{22}{y}_{2,t-1}+{\beta }_{21}{x}_{1,t}+{\beta }_{22}{x}_{2,t}+{\beta }_{23}{x}_{3,t}+{\delta }_{2}t+{\epsilon }_{2,t}.\end{array}$`

## Tips

• `gctest` uses the series names in `Mdl` in test result summaries. To make the output more meaningful for your application, specify series names by setting the `SeriesNames` property of the VAR model object `Mdl` by using dot notation before calling `gctest`. For example, the following code assigns names to the variables in the 3-D VAR model object `Mdl`:

`Mdl.SeriesNames = ["rGDP" "m1sl" "inflation"];`

• The exclude-all and leave-one-out Granger causality tests conduct multiple, simultaneous tests. To control the inevitable increase in the false discovery rate, decrease the level of significance `Alpha` when you conduct multiple tests. For example, to achieve a family-wise significance level of 0.05, specify `'Alpha',0.05/numtests`.

## Algorithms

The name-value pair arguments `Cause` and `Effect` apply to the block-wise Granger causality test because they specify which equations have lag coefficients set to 0 for the null hypothesis. Because the leave-one-out and exclude-all Granger causality tests cycle through all combinations of variables in the VAR model, the information provided by `Cause` and `Effect` is not necessary. However, you can specify a leave-one-out or exclude-all Granger causality test and the `Cause` and `Effect` variables to conduct unusual tests such as constraints on self lags. For example, the following code assesses the null hypothesis that the first variable in the VAR model `Mdl` is not the 1-step Granger-cause of itself:

`gctest(Mdl,'Type',"leave-one-out",'Cause',1,'Effect',1);`

## 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, James 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, Helmut. 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.

## Version History

Introduced in R2019a