# ADF test in R yielding perfect cointegration. How is this possible?

I am using the famous conintegrated pairs tutorial to just different stocks for cointegration. The adf.test yeilds perfect cointegration, which I feel must be incorrect. Here is why:

When I run adf.test() on a cumsum of a random series, the plot looks like this: And it yields the following adf.test output:

Augmented Dickey-Fuller Test data: sp Dickey-Fuller = -2.8333, Lag order = 4, p-value = 0.2314 alternative hypothesis: stationary

Here is a spread I constructed, notice how it looks similar to the random walk: Which yields the following adf.test() output:

Augmented Dickey-Fuller Test data: sprd3 Dickey-Fuller = 3.719, Lag order = 7, p-value = 0.99 alternative hypothesis: stationary Warning message: In adf.test(sprd3) : p-value greater than printed p-value

Any ideas what could be going on here? Why is the p-value extremely different between the two cases? I have a hard time believing that the spread I constructed in the graph is has a p-value of .99...

Thanks.

UPDATE I have looked into this problem some more and have revealed a little more that may help us get to the bottom of the .99 p-value.

Here is another spread I created: The spread looks a little more stable than the previous one I posted. I ran the adf.test() on this spread two different ways. The first was adf.test(sprd1). This came up with a p-value of .99, similar to what I have been experiencing.

However, when I use as.numeric() on the spread, the result is quite different. Executing adf.test(as.numeric(sprd1)) gives me a p-value of .07

Interesting. A little more info, the sprd1 data is an xts object with minute-by-minute data and no missing values.

xts version: 0.8-8 zoo version: 1.7-9 R version: 2.14

Maybe older packages are causing the problem?

• Which cases did you use for the ADF-tests? Did you check several lag orders and check the residuals for serial correlation? Oct 19, 2013 at 16:36
• Sorry Do I understand correctly... you get a massive p-value for the test so you cannot reject $H_0$ which is non-stationarity... why do you think it is stationary ? Oct 21, 2013 at 12:45
• @statquant Yes, you are correct. I meant to ask why is the p-value so different between the two. They are both non-stationary, but the p-value using the spread data is VERY high. I would expect the p-values to be somewhat similar between the two.
– Stu
Oct 21, 2013 at 19:05
• Stu, Why are you running an adf on the cumsum of a random series as a comparison? Almost any cumulative sum will have a unit root. Dec 5, 2013 at 16:36

• The answer to your question is still the same. Remove all the observations where the first difference is zero and the p-value will drop: adf.test(sprd3[diff(sprd3)!=0]). Oct 21, 2013 at 19:13