Skip to content
All library documents

Engle–Granger Cointegration Testing and Error-Correction Modeling

Article Quant Q&A · Author: Turtles Are Cute

Summary

The note summarizes the Engle–Granger two-step procedure for assessing whether two time series are cointegrated. First test each series for its integration order, using an augmented Dickey–Fuller test to check that each is nonstationary in levels but integrated of order one. Regress one series on the other, then test the regression residuals for stationarity; stationary residuals support a conclusion of cointegration. Lag choices in the tests may be selected with criteria such as AIC or BIC.

For cointegrated series, the note sketches an error-correction model that uses lagged disequilibrium residuals alongside lagged changes in the series. It points readers to educational examples and references, including a pairs-trading example involving gold-related instruments. The discussion is introductory rather than a complete implementation: it does not supply code, spell out test critical values or finite-sample adjustments, or examine practical pitfalls in inference and trading.

Key ideas

  • Engle–Granger testing begins by checking that both series are integrated of order one.
  • Regress one series on the other and test whether the residuals are stationary.
  • Stationary residuals provide evidence that the series are cointegrated.
  • An error-correction model can include lagged residuals and lagged changes in the series.
  • Information criteria such as AIC or BIC can help select test lags, but implementation and inference details are omitted.

Tags

Full text
# Dou you have an example of implementing Engle-Granger 2-step cointegration?


# Dou you have an example of implementing Engle-Granger 2-step cointegration?












Does anyone know where to find an example of implementing Engle-Granger 2-step cointegration?

Python's ideal, but any language will do.

I've skimmed and read many articles, but understand little about the abstract terms.

Seeing an implementation would not only solve my practical problem, but help me understand what the papers are talking about.

I've been trying for weeks, but have found no code examples.

edit: Looks like Matt Clegg has a robust R module for egcm here. I'm working on a Python port, and will post it when I'm ready. Anyone who would like my working copy, ask.

## Answer by Quantopik (score 1)

https://quant.stackexchange.com/a/16801

In the E.P. Chan's Book, the author provided an example in which he tests a pair trading strategy on GLD (gold spot price) and GDX (gold industry stock index).

All code examples are written in Matlab down in the book, but all of them are explained pretty well; each practical example is equipped with a full theoretical explanation.

The example you need for is at p. 57.

## Answer by NBF (score 1)

https://quant.stackexchange.com/a/16929

One of the simplest and most intuitive books covering cointegration is Applied Econometric Time Series by Enders.

It would cover both Engle-Granger and Johansen (although not in so much detail).

Another tried and true way of learning it is to go to the Eviews Help Manual. It has grown over the years and now is over 1000 pages. I used it when it was maybe 300 and learned alll the basics of pretty much all the econometrics I use today in that manual. It has a very recipe-book style, of course using eviews. Examples will involve the author testing for unit root in individual series, combining to test for cointegration and testing the numbers of cointegratin vectors. I'm not 100% sure they cover Engle-Granger (or instead just go for the easier to use one-step Johansen method) but it is a great book nonetheless.

Engle Granger boils down to:

- Test each series to check I(1)--brownian motion, or I(0)- white noise using Augmented Dickey Fuller (ADF) test. Must be I(1).

- Do regression. Check residuals, run ADF test. They must be I(0) - stationary/white noise....i.e., they gotta cross zero lots of times. If you pass both, you have cointegration.

To fit the Error correction framework, you take you cointegrated residuals $\epsilon(t)$ and lag them and do a regression, i.e.,

$$\Delta x(t) = a \cdot \epsilon(t-1) + b \cdot \Delta x(t-1) + c \cdot \Delta y(t-1) + .... + \text{resid}$$

and do the same for the other series.

Since ADF has arbitrary lags, sometimes people automate this using a AIC or BIC in steps 1 and 2.

## Answer by Felix (score 1)

https://quant.stackexchange.com/a/16932

Another book is Bernhard Pfaff's Analysis of Integrated and Cointegrated Time Series with R (amazon.com). He emphasizes the Johansen method and error correction models, but also gives an empirical example of the Engle-Granger procedure, Code 4.2.

Shown in full with attribution under the source's licence. Licence: CC BY-SA 4.0 (Stack Exchange)

This summary was written by Stratmill's research agent from the original; it is not a copy of the source.