gctest
Granger causality and block exogeneity tests for vector autoregression (VAR) models
Description
The gctest
object function can conduct leaveoneout,
excludeall, and blockwise Granger causality tests for the
response variables of a fully specified vector autoregression (VAR)
model (represented by a varm
model object).
To conduct a blockwise 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.
returns
the test decision h
= gctest(Mdl
)h
from conducting leaveoneout Granger causality tests on all
response variables that compose the VAR(p) model
Mdl
.
uses additional options specified by one or more namevalue pair arguments. For example,
h
= gctest(Mdl
,Name,Value
)'Type',"blockwise",'Cause',1:2,'Effect',3:5
specifies conducting a
blockwise test to assess whether the response variables
Mdl.SeriesNames(1:2)
Grangercause the response variables
Mdl.SeriesNames(3:5)
conditioned on all other variables in the
model.
Examples
Conduct LeaveOneOut Granger Causality Test
Conduct a leaveoneout Granger causality test to assess whether each variable in a 3D VAR model Grangercauses 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.M1SL)
ylabel("Money Supply");
plot(DataTimeTable.Time,DataTimeTable.CPIAUCSL)
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 leaveoneout Granger causality test to assess whether a variable in the fitted VAR(3) model is the 1step Grangercause 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 6by1 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 1step Grangercause 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 1step Grangercause 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 1step Grangercause of the inflation rate, given the real GDP rate (
h(3)
=0
).Reject the claim that the real GDP rate is not the 1step Grangercause 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 1step Grangercause of the real GDP rate, given the inflation rate (
h(5)
=0
).Reject the claim that the inflation rate is not the 1step Grangercause of the real GDP rate, given the M1 money supply rate (
h(6)
= 1).
Because the inflation and real GDP rates are 1step Grangercauses of each other, they constitute a feedback loop.
Conduct ExcludeAll Granger Causality Test
Consider the 3D VAR(3) model and leaveoneout Granger causality test in Conduct LeaveOneOut 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 excludeall Granger causality test on the variables of the fitted model.
h = gctest(EstMdl,'Type',"excludeall");
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 Grangercause the M1 money supply rate.
Reject the claim that the M1 money supply and real GDP rates do not Grangercause the inflation rate.
Reject the claim that the M1 money supply and inflation rates do not Grangercause the real GDP rate.
Adjust Significance Level for Multiple Tests
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'
namevalue pair argument. Consider the 3D VAR(3) model and leaveoneout Granger causality test in Conduct LeaveOneOut 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 leaveoneout Granger causality test on the variables in the model results in numtests
= 6 simultaneous tests. Conduct the tests, but specify a familywise 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 LeaveOneOut Granger Causality Test. However, the conclusions of the conservative tests hold simultaneously at a 5% level of significance.
Access Test pValues
Consider the 3D VAR(3) model and leaveoneout Granger causality test in Conduct LeaveOneOut 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 leaveoneout 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
Test for Block Exogeneity
Time series are block exogenous if they do not Grangercause 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 DickeyFuller 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 4D 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 Grangercauses 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.0805e09
stat = 6.9869
cvalue = 1.9265
To determine which variables are Grangercaused by the federal funds rate, conduct a leaveoneout 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.8433e06 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 1step Grangercause of the inflation rate, given all other variables in the VAR model.
Reject the claim that the federal funds rate is not a 1step Grangercause 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 1step Grangercause of the real GDP rate, given all other variables in the VAR model.
Input Arguments
NameValue Arguments
Specify optional pairs of arguments as
Name1=Value1,...,NameN=ValueN
, where Name
is
the argument name and Value
is the corresponding value.
Namevalue 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',"blockwise",'Cause',1:2,'Effect',3:5
specifies
conducting a blockwise test to assess whether the response variables
Mdl.SeriesNames(1:2)
Grangercause the response variables
Mdl.SeriesNames(3:5)
conditioned on all other variables in the
model.
Type
— Granger causality test to conduct
"leaveoneout"
(default)  "excludeall"
 "blockwise"
Granger causality test to conduct, specified as the commaseparated pair
consisting of 'Type'
and a value in this table. Suppose that the
VAR model Mdl
is mD (m =
Mdl.NumSeries
).
Value  Description 

"leaveoneout"  Leaveoneout test For j =
1,…,m, k = 1,…,m,
and j ≠ k,

"excludeall"  Excludeall test For j =
1,…,m, 
"blockwise"  Blockwise test

Example: 'Type',"excludeall"
Data Types: char
 string
Alpha
— Significance level
0.05
(default)  numeric scalar in (0,1)
Significance level for each conducted test (see Type
),
specified as the commaseparated pair consisting of 'Alpha'
and a
numeric scalar in (0,1).
Example: 'Alpha',0.1
Data Types: double
 single
Test
— Test statistic distribution under null hypothesis
"chisquare"
(default)  "f"
Test statistic distribution under the null hypothesis, specified as the
commaseparated pair consisting of 'Test'
and a value in this
table.
Value  Description 

"chisquare"  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
Cause
— VAR model response variables representing Grangercauses
numeric vector of variable indices  vector of variable names
VAR model response variables representing Grangercauses in the 1step blockwise
test, specified as the commaseparated 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
Effect
— VAR model response variables affected by Grangercauses
numeric vector of variable indices  vector of variable names
VAR model response variables affected by Grangercauses in the 1step blockwise
test, specified as the commaseparated 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
Display
— Flag to display test summary table
true
(default)  false
Flag to display a test summary table at the command line, specified as the
commaseparated pair consisting of 'Display'
and a value in this
table.
Value  Description 

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
h
— Granger causality test decisions
logical scalar  logical vector
Granger causality test decisions, returned as a logical scalar or
numtests
by1 logical vector. For
=
1,…,j
numtests
:
h(
=j
)1
indicates that test
rejects the null hypothesis H_{0} that the "cause" variables are not 1step Grangercauses of the "effect" variables. Sufficient evidence exists to support Granger causality and endogeneity of the "cause" variables.j
h(
=j
)0
indicates failure to reject H_{0}.
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
— Summary of test results
table
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 Name  Description  Data Type 

H0  Granger causality or block exogeneity test null hypothesis description  String scalar 
Decision  Test decisions corresponding to h  String scalar 
Distribution  Test statistic distribution under the null hypothesis  String scalar 
Statistic  Value of test statistic  Numeric scalar 
PValue  Test pvalue  Numeric scalar 
CriticalValue  Critical value for the significance level
Alpha  Numeric scalar 
More About
Granger Causality Test
The Granger causality test is a statistical hypothesis test that assesses whether past and present values of a set of m_{1} time series variables, called the "cause" variables, affect the predictive distribution of a distinct set of m_{2} 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 hsteps into the forecast horizon, the "cause" variables are hstep Grangercauses of the "effect" variables. If the "cause" variables are hstep Grangercauses of the "effect" variables for all h ≥ 1, the "cause" variables Grangercause the "effect" variables.
gctest
provides blockwise, leaveoneout,
and excludeall variations of the Granger causality tests (see 'Type'
) and
χ^{2}based or Fbased 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.
Let y_{1,t} denote the m_{1} "cause" variables and y_{2,t} denote the m_{2} "effect" variables. Consider a stationary VAR(p) model for [y_{1,t} y_{2,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,t1}\\ {y}_{2,t1}\end{array}\right]+\mathrm{...}+\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,tp}\\ {y}_{2,tp}\end{array}\right]+\left[\begin{array}{c}{\epsilon}_{1,t}\\ {\epsilon}_{2,t}\end{array}\right].$$
If Φ_{21,1} = … = Φ_{21,p} = 0_{m1,m2}, then y_{1,t} is not the blockwise Grangercause of y_{2,t + h}, for all h ≥ 1 and where 0_{m2,m1} is an m_{2}bym_{1} matrix of zeros. Also, y_{1,t} is block exogenous with respect to y_{2,t}. Consequently, the blockwise Granger causality test hypotheses are:
$$\begin{array}{l}{H}_{0}:{\Phi}_{21,1}=\mathrm{...}={\Phi}_{21,p}={0}_{{m}_{2},{m}_{1}}\\ {H}_{1}:\exists j\in \{1,\mathrm{...},p\}\ni {\Phi}_{21,j}\ne {0}_{{m}_{2},{m}_{1}}.\end{array}$$
H_{1} implies that at least one h ≥ 1 exists such that y_{1,t} is the hstep Grangercause of y_{2,t}.
Distinct endogenous variables in the VAR model that are not "causes" or "effects" in
the blockwise test are conditioning variables. If conditioning
variables exist in the model, h = 1. In other words,
gctest
tests the null hypothesis of 1step
noncausality.
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 1step noncausality. Specifically, consider
the mD 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,t1}\\ \begin{array}{l}{y}_{2,t1}\\ {y}_{3,t1}\end{array}\end{array}\right]+\mathrm{...}+\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,tp}\\ \begin{array}{l}{y}_{k,tp}\\ {y}_{s,tp}\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:
y_{j,t} and y_{k,t} are 1D series representing the "cause" and "effect" variables, respectively.
y_{s,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 j ≠ k,
gctest
tests the null hypothesis that
y_{j,t}
is not a 1step Grangercause of
y_{k,t},
given y_{s,t}:
$$\begin{array}{l}{H}_{0}:{\varphi}_{21,1}=\mathrm{...}={\varphi}_{21,p}=0\\ {H}_{1}:\exists r\in \{1,\mathrm{...},p\}\ni {\varphi}_{21,r}\ne 0.\end{array}$$
gctest
conducts
m(m – 1) tests.
For each equation in the VAR model, gctest
removes all lags
from the equation, except self lags, and tests for hstep noncausality.
Specifically, consider the mD 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}_{kk,1}\\ {\varphi}_{kk,1}& {\Phi}_{kk,1}\end{array}\right]\left[\begin{array}{c}{y}_{k,t1}\\ {y}_{k,t1}\end{array}\right]+\mathrm{...}+\left[\begin{array}{cc}{\varphi}_{kk,p}& {\varphi}_{kk,p}\\ {\varphi}_{kk,p}& {\Phi}_{kk,p}\end{array}\right]\left[\begin{array}{c}{y}_{k,tp}\\ {y}_{k,tp}\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 y_{k,t}) representing the "cause" variables.
y_{k,t} is the 1D series representing the "effect" variable.
For ℓ = 1,…,p:
ϕ_{kk,ℓ} is a scalar lag coefficient.
ϕ_{kk,ℓ} and ϕ_{kk,ℓ} are (m – 1)D vectors of lag coefficients.
Φ_{kk,ℓ} 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 hstep Grangercauses of
y_{k,t}:
$$\begin{array}{l}{H}_{0}:{\varphi}_{21,1}=\mathrm{...}={\varphi}_{21,p}=0\\ {H}_{1}:\exists r\in \{1,\mathrm{...},p\}\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 differenceequation notation and in reduced form is
$${y}_{t}=c+{\Phi}_{1}{y}_{t1}+{\Phi}_{2}{y}_{t2}+\mathrm{...}+{\Phi}_{p}{y}_{tp}+\beta {x}_{t}+\delta t+{\epsilon}_{t}.$$
y_{t} is a
numseries
by1 vector of values corresponding tonumseries
response variables at time t, where t = 1,...,T. The structural coefficient is the identity matrix.c is a
numseries
by1 vector of constants.Φ_{j} is a
numseries
bynumseries
matrix of autoregressive coefficients, where j = 1,...,p and Φ_{p} is not a matrix containing only zeros.x_{t} is a
numpreds
by1 vector of values corresponding tonumpreds
exogenous predictor variables.β is a
numseries
bynumpreds
matrix of regression coefficients.δ is a
numseries
by1 vector of linear timetrend values.ε_{t} is a
numseries
by1 vector of random Gaussian innovations, each with a mean of 0 and collectively anumseries
bynumseries
covariance matrix Σ. For t ≠ s, ε_{t} and ε_{s} are independent.
Condensed and in lag operator notation, the system is
$$\Phi (L){y}_{t}=c+\beta {x}_{t}+\delta t+{\epsilon}_{t},$$
where $$\Phi (L)=I{\Phi}_{1}L{\Phi}_{2}{L}^{2}\mathrm{...}{\Phi}_{p}{L}^{p}$$, Φ(L)y_{t} is
the multivariate autoregressive polynomial, and I is the
numseries
bynumseries
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,t1}+{\varphi}_{12}{y}_{2,t1}+{\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,t1}+{\varphi}_{22}{y}_{2,t1}+{\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 inMdl
in test result summaries. To make the output more meaningful for your application, specify series names by setting theSeriesNames
property of the VAR model objectMdl
by using dot notation before callinggctest
. For example, the following code assigns names to the variables in the 3D VAR model objectMdl
:Mdl.SeriesNames = ["rGDP" "m1sl" "inflation"];
The excludeall and leaveoneout 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 familywise significance level of 0.05, specify'Alpha',0.05/numtests
.
Algorithms
The namevalue pair arguments Cause
and Effect
apply to the blockwise Granger causality test because they specify which equations have lag
coefficients set to 0 for the null hypothesis. Because the leaveoneout and excludeall
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 leaveoneout or excludeall 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 1step
Grangercause of
itself:
gctest(Mdl,'Type',"leaveoneout",'Cause',1,'Effect',1);
References
[1] Granger, C. W. J. "Investigating Causal Relations by Econometric Models and CrossSpectral 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: SpringerVerlag, 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 R2019aR2023a: gctest
accepts input data in tables and timetables, and return results in tables and timetables
In addition to accepting input data in numeric arrays,
gctest
accepts input data in tables and timetables. gctest
chooses default series on which to operate, but you can use the following namevalue arguments to select variables.
CauseVariables
selects the Grangercause variables from the input. By default, all variables not specified as Grangereffect variables are Grangercause variables.EffectVariables
selects the Grangereffect variables from the input. By default, the last variable is the Grangereffect variable.ConditionVariables
selects the conditioning variables from the input. The default is none of the variables.
MATLAB 命令
您点击的链接对应于以下 MATLAB 命令：
请在 MATLAB 命令行窗口中直接输入以执行命令。Web 浏览器不支持 MATLAB 命令。
Select a Web Site
Choose a web site to get translated content where available and see local events and offers. Based on your location, we recommend that you select: .
You can also select a web site from the following list:
How to Get Best Site Performance
Select the China site (in Chinese or English) for best site performance. Other MathWorks country sites are not optimized for visits from your location.
Americas
 América Latina (Español)
 Canada (English)
 United States (English)
Europe
 Belgium (English)
 Denmark (English)
 Deutschland (Deutsch)
 España (Español)
 Finland (English)
 France (Français)
 Ireland (English)
 Italia (Italiano)
 Luxembourg (English)
 Netherlands (English)
 Norway (English)
 Österreich (Deutsch)
 Portugal (English)
 Sweden (English)
 Switzerland
 United Kingdom (English)