You may want to read this article first: What is order of integration?

Cointegration tests analyze non-stationary time series— processes that have variances and means that vary over time. In other words, the method allows you to estimate the long-run parameters or equilibrium in systems with unit root variables (Rao, 2007).

Two sets of variables are cointegrated if a linear combination of those variables has a lower order of integration. For example, cointegration exists if a set of I(1) variables can be modeled with linear combinations that are I(0). The order of integration here—I(1)— tells you that a single set of differences can transform the non-stationary variables to stationarity. Although looking at a graph can sometimes tell you if you have an I(1) process, you may need to run a test such as the KPSS test or the Augmented Dickey-Fuller test to figure it out.

## Background

In order to analyze time series with classical methods like ordinary least squares, an assumption is made: The variances and means of the series are constants that are independent of time (i.e. the processes are stationary). Non-stationary time series (or unit root variables) don’t meet this assumption, so the results from any hypothesis test will be biased or misleading. These series have to be analyzed with different methods. One of these methods is called **cointegration**.

More formally, cointegration is where two I(1) time series x_{t} and y_{t} can be described by the stationary process

u_{t} = y_{t} − αx_{t}.

## Tests for Cointegration

Tests for cointegration identify stable, long-run relationships between sets of variables. However, Rao (2007) notes that if the test fails to find such a relationship, it isn’t proof that one doesn’t exists— it only *suggests *that one doesn’t exist.

Three of the most popular tests are:

- Engle–Granger
- Phillips–Ouliaris
- Johansen test

## Engle–Granger

The Engle-Granger method first constructs residuals (errors) based on the static regression.The residuals are tested for the presence of unit roots using ADF or a similar test. If the time series is cointegrated, then the residuals will be practically stationary. A major issue with the Engle-Granger method is that choice of the dependent variable may lead to different conclusions (Armstrong, 2001), an issue corrected by more recent tests such as Phillips-Ouliaris and Johansen’s.

H_{0}: No cointegration exists

H_{1}: Cointegration exists

This test is usually performed by software such as MATLAB or STAT (using the egranger command).

In R, download the “adf.R” code found here on the University of Illinois website. An outline of the steps is found here (scroll down to Cointegration: Engle-Granger Test); you’ll need this table of critical values for the Engle-Granger test.

## Phillips–Ouliaris

The Philips-Ouliaris (1990) is a residual-based unit root test. It is an improvement over the Engle-Ganger test; Prior to 1987, tests for cointegration worked on the assumption that regression errors are independent with common variance—which is rarely true in real life (Chaovalitwongse et. al, 2010).

H_{0}: No cointegration exists

H_{1}: Cointegration exists

The Philips-Ouliaris test takes supplementary variability into account (stemming from the fact that residuals are *estimates *instead of the actual parameter values). The tests is also invariant to normalization of the cointegration relationship (i.e. which variable is counted as the dependent variable).

## Johansen test

Johansen’s test is another improvement over the Engle-Granger test. It avoids the issue of choosing a dependent variable as well as issues created when errors are carried from one step to the next. As such, the test can detect multiple cointegrating vectors.

## References

Armstrong, J. Principles of Forecasting: A Handbook for Researchers and Practitioners. Springer Science & Business Media

Chaovalitwongse, W. et. al (2010). Computational Neuroscience. Springer Science & Business Media.

Engle, R. F., and C. W. J. Granger. 1987. Co-integration and error correction: Representation, estimation, and testing. Econometrica 55: 251–276.

Granger, C.; Newbold, P. (1974). *Spurious Regressions in Econometrics.* Journal of Econometrics. 2 (2): 111–120. doi:10.1016/0304-4076(74)90034-7

P. C. B. Phillips and S. Ouliaris (1990): Asymptotic Properties of Residual Based Tests for Cointegration. Econometrica 58, 165–193.

Rao, B. (2007). Cointegration: for the Applied Economist, Springer.

If you prefer an online interactive environment to learn R and statistics, this *free R Tutorial by Datacamp* is a great way to get started. If you're are somewhat comfortable with R and are interested in going deeper into Statistics, try *this Statistics with R track*.

*Facebook page*and I'll do my best to help!