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...
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?