2
$\begingroup$

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.

$\endgroup$
1
$\begingroup$

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.

$\endgroup$
1
$\begingroup$

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:

  1. Test each series to check I(1)--brownian motion, or I(0)- white noise using Augmented Dickey Fuller (ADF) test. Must be I(1).
  2. 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.

$\endgroup$
1
$\begingroup$

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.

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.