Performs Engle-Granger(or EG) tests for the null hypothesis that two or more time series, each of which is I(1), are not cointegrated.

1 | ```
coint.test(y, X, d = 0, nlag = NULL, output = TRUE)
``` |

`y` |
the response |

`X` |
the exogenous input variable of a numeric vector or a matrix. |

`d` |
difference operator for both |

`nlag` |
the lag order to calculate the test statistics. The default is |

`output` |
a logical value indicating to print the results in R console.
The default is |

To implement the original EG tests, one first has to fit the linear regression

*y[t] = μ + B*X[t] + e[t],*

where *B* is the coefficient vector and *e[t]* is an error term.
With the fitted model, the residuals are obtained, i.e., *z[t] = y[t] - hat{y}[t]*
and a Augmented Dickey-Fuller test is utilized to examine whether the sequence of
residuals *z[t]* is white noise. The null hypothesis of non-cointegration
is equivalent to the null hypothesis that *z[t]* is white noise. See `adf.test`

for more details of Augmented Dickey-Fuller test, as well as the default `nlag`

.

A matrix for test results with three columns (`lag`

, `EG`

, `p.value`

)
and three rows (`type1`

, `type2`

, `type3`

).
Each row is the test results (including lag parameter,
test statistic and p.value) for each type of linear regression models of residuals
*z[t]*. See `adf.test`

for more details of three types of linear models.

Debin Qiu

MacKinnon, J. G. (1991). Critical values for cointegration tests, Ch. 13 in Long-run Economic Relationships: Readings in Cointegration, eds. R. F. Engle and C. W. J. Granger, Oxford, Oxford University Press.

1 2 3 4 5 6 7 8 | ```
X <- matrix(rnorm(200),100,2)
y <- 0.3*X[,1] + 1.2*X[,2] + rnorm(100)
# test for original y and X
coint.test(y,X)
# test for response = diff(y,differences = 1) and
# input = apply(X, diff, differences = 1)
coint.test(y,X,d = 1)
``` |

Questions? Problems? Suggestions? Tweet to @rdrrHQ or email at ian@mutexlabs.com.

Please suggest features or report bugs with the GitHub issue tracker.

All documentation is copyright its authors; we didn't write any of that.

Embedding an R snippet on your website

Add the following code to your website.

For more information on customizing the embed code, read Embedding Snippets.