EngleGranger cointegration test
[h,pValue,stat,cValue,reg1,reg2]
= egcitest(Y)
[h,pValue,stat,cValue,reg1,reg2]
= egcitest(Y,Name,Value)
EngleGranger tests assess the null hypothesis of no cointegration
among the time series in Y
. The test regresses Y(:,1)
on Y(:,2:end)
,
then tests the residuals for a unit root.
[
performs the EngleGranger
test on a data matrix h
,pValue
,stat
,cValue
,reg1
,reg2
]
= egcitest(Y
)Y
.
[
performs
the EngleGranger test on a data matrix h
,pValue
,stat
,cValue
,reg1
,reg2
]
= egcitest(Y
,Name,Value
)Y
with
additional options specified by one or more Name,Value
pair
arguments.

numObsbynumDims matrix
representing numObs observations of a numDimsdimensional
time series y(t),
with the last observation the most recent. Y cannot
have more than 12 columns. Observations containing 
Specify optional
commaseparated 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
.

Character vector, such as y_{1} = Xa + Y_{2}b + ε
Default: 

Vector or cell vector of vectors containing coefficients [a;b]
to be held fixed in the cointegrating regression. The length of a is
0, 1, 2 or 3, depending on Default: Completely unspecified cointegrating vector (all NaN values). 

Character vector, such as Values are:
Test statistics are computed by calling Default: 

Scalar or vector of nonnegative integers indicating the number
of lags used in the residual regression. The meaning of the parameter
depends on the value of Default: 

Character vector, such as Values are:
The meaning of the parameter depends on the value of Default: 

Scalar or vector of nominal significance levels for the tests. Values must be between 0.001 and 0.999. Default: 0.05 
Singleelement parameter values are expanded to the length of any vector value (the number of tests). Vector values must have equal length. If any value is a row vector, all outputs are row vectors.

Vector of Boolean decisions for the tests, with length equal
to the number of tests. Values of  

Vector of pvalues of the test statistics, with length equal to the number of tests. pvalues are lefttail probabilities.  

Vector of test statistics, with length equal to the number of
tests. The statistic depends on the  

Vector of critical values for the tests, with length equal to
the number of tests. Values are for lefttail probabilities. Since
residuals are estimated rather than observed, critical values are
different from those used in  

Structure of regression statistics from the cointegrating regression.  

Structure of regression statistics from the residual regression. The number of records in
*Lagging and differencing a time series reduces the sample size. Absent any presample values, if y(t) is defined for t = 1:N, then the lagged series y(t−k) is defined for t = k+1:N. Differencing reduces the time base to k+2:N. With p lagged differences, the common time base is p+2:N and the effective sample size is N−(p+1). 
Load data on term structure of interest rates in Canada:
load Data_Canada Y = Data(:,3:end); names = series(3:end); plot(dates,Y) legend(names,'location','NW') grid on
Test for cointegration (and reproduce row 1 of Table II in [3]):
[h,pValue,stat,cValue,reg] = egcitest(Y,'test',... {'t1','t2'}); h,pValue
h = 1x2 logical array 0 1 pValue = 0.0526 0.0202
Plot the estimated cointegrating relation y_{1}−Y_{2}b−Xa:
a = reg(2).coeff(1);
b = reg(2).coeff(2:3);
plot(dates,Y*[1;b]a)
grid on
A suitable value for lags
must be determined
in order to draw valid inferences from the test. See notes on the lags
parameter
in the documentation for adftest
and pptest
.
Samples with less than ~20 to 40 observations (depending on the dimension of the data) can yield unreliable critical values, and so unreliable inferences. See [3].
If cointegration is inferred, residuals from the reg1
output
can be used as data for the errorcorrection term in a VEC representation
of y(t).
See [1]. Estimation of autoregressive
model components can then be performed with estimate
, treating
the residual series as exogenous.
[1] Engle, R. F. and C. W. J. Granger. “CoIntegration and ErrorCorrection: Representation, Estimation, and Testing.” Econometrica. v. 55, 1987, pp. 251–276.
[2] Hamilton, J. D. Time Series Analysis. Princeton, NJ: Princeton University Press, 1994.
[3] MacKinnon, J. G. “Numerical Distribution Functions for Unit Root and Cointegration Tests.” Journal of Applied Econometrics. v. 11, 1996, pp. 601–618.