# Understanding of the specification of the Johansen Cointegration test in R

I've just started getting into cointegration testing in R using the "urca" and "tseries" packages last week and am still very confused about the different arguments, despite having read the manuals. This is of concern as my cointegration tests have so far yielded "no cointegration" results, when I know intuitively that my series should co-integrate (e.g. U.S. 10-year yield vs. U.S. 2-year yield, or XLE price vs. Brent 1st Futures)

I posted my results for the cointegration tests in a previous thread: Interpretation of results using Johansen and Engle-Granger 2-step Cointegration tests

Specifically for the Johansen Cointegration test, I read in another thread that

If you are really sure that there is a long term relationship in your data, then check that you are using the correct number of lags and appropriate dummy variables (constant, trend, seasonal dummies, etc) and then rerun the Johansen procedure again.

My questions then are:

(1) Lags: How do you select the optimal lags in the Johansen test? Unlike in the ADF test, I cannot let AIC select the lags for me.

(2) Type: When should you use trace vs. eigen? Some tutorials I've read stated that trace is preferred, but without any explanations on why it is so.

(3) ecdet: what does the argument ecdet refer to in the function ca.jo in package "urca"? The manual states that ecdet = Character, ‘none’ for no intercept in cointegration, ‘const’ for constant term in cointegration and ‘trend’ for trend variable in cointegration., but how do you decide which character fits? With the stationarity tests, I would plot the graphs to try and decipher if it's a random walk/with drift/with trend, but I am not sure if that makes sense for this test.

Here is a graph of U.S. 10-year vs. 2-year yields, if anyone would like to use it to elaborate:

I have tried to find existing answers before posting this to no avail, but if anyone knows of existing threads that are helpful, feel free to link me to them as well.

• As I said here, even if you are sure the series should be cointegrated (or at least co-move closely over the long run, to avoid strict statistical terminology), there seems to have been a structural change around years 05-08 which is why formal cointegration tests will likely reject cointegration. Also, even though the spread does not diverge, the two series do diverge for long periods before coming back together, which is not exactly compatible with cointegration. – Richard Hardy Nov 12 '15 at 18:38

## 1 Answer

1. The lag selection for cointegration test is the same as selecting lags for VAR model, since cointegration is a actually a special feature of VAR model. Use VARselect to choose number of lags.

2. The two statistics test the same thing and are constructed from the same eigenvalues of a certain matrix. For practical purposes there are no differences between these two.

3. Cointegration means that the linear combination of unit root processes is stationary process. It is usually assumed that this stationary process has zero mean. However it is entirely possible that it has a non-zero mean and there is a trend added to the process. In the case of trend and two unit root processes this means that the difference $y_t-\alpha x_t$ has a trend, which means that the two processes are pushed apart over time. Judging from your graph it would be difficult to argue if this is really the case.

• thanks for your response @mpiktas, if you realise I quoted you above (I couldn't leave a comment directly on that thread as I am a very new member here). On (2), do you know why there exists the 2 different types (eigen and trace) then? Also, while I have not encountered this, is there the possibility of getting a result that accepts the null for one and not the other (i.e. conflicting results). Further, on (3), is observing the graph then also the way that you decide on which ecdet to choose (though for this case it's not that helpful)? – ElizaTYX Nov 12 '15 at 9:28
• Also, seeing that you're very proficient in Johansen Test/time-series data analysis, do you mind hopping over to the linked thread above on the interpretations of cointegration test results, where I have my test inputs and outputs and see if I have done anything wrong? Series pairs like the XLE/Brent 1st Futures, the 10year/2year yields on US t-bills should theoretically be cointegrated, but so far my test results have all requested that I not reject the null of r=0 (no cointegration). @mpiktas – ElizaTYX Nov 12 '15 at 9:42
• Concerning the (2). The Johansen in his original paper introduces the two statistics. They are both based on eigen values, one is the maximum, another is sum. Mathematically they are both sound choices. There is a possibility of conflicting results, but I personally use only one variant. – mpiktas Nov 12 '15 at 12:25
• Concerning the (3). It is always instructive to see the graph, sometimes some things are immediately evident. However the precise choice should depend on theoretical considerations, both economic and statistic. – mpiktas Nov 12 '15 at 12:27
• Hi @mpiktas, a few questions on VARselect: (A) I will run VARselect on the dependent variable. but the exo-endo relationship isnt clear in some instances, for example when you look at US 2 year vs 10 year yields, there's no way for sure to tell which is the dependent variable, no? Also, what happens in a scenario where there are more than 1 dependent variable in a data set where we are trying to study cointegration with >2 data series? (B) How do I determine the max.lag and type (by gut feeling I would refer to the graph of the series that is being tested at VARselect). Many thanks in advance! – ElizaTYX Nov 16 '15 at 10:24