[R-SIG-Finance] Interpreting cointegration - ur.df() and ad.test()

Paul Teetor paulteetor at yahoo.com
Wed Mar 30 06:35:56 CEST 2011


algotr8der:

The adf.test function essentially detrends your data before performing the ADF 
test. (That's what the help page means when it says, "The general regression 
equation which incorporates a constant and a linear trend is used.")  The data 
plot may appear to be trending upward, but the function removes that trend 
first. If you plot the detrended data, you'll see the data that the function is 
testing. It should be going "sideways" compared to your original, trendy data.

The ur.df function performs a similar detrending when you specify type="trend". 
(OK, more precisely: it detrends in conjunction with performing the ADF test.)

HTH,

Paul


 
Paul Teetor, Elgin, IL  USA
http://quanttrader.info/public



----- Original Message ----
From: algotr8der <algotr8der at gmail.com>
To: r-sig-finance at stat.math.ethz.ch
Sent: Tue, March 29, 2011 6:39:48 PM
Subject: [R-SIG-Finance] Interpreting cointegration - ur.df() and ad.test()

Hello folks,

I have read several posts on here regarding cointegration and the various
tests that check for this. 

Here is what I have done - where securityA and securityB are time series
price data.

series <- merge(securityA, securityB,  all=FALSE)
series <- as.data.frame(series)
m <- lm(securityA ~ securityB+ 0, data=series)
beta1 <- coef(m)[1]
sprd = series$securityA - beta1*series$securityB

> adf.test(sprd, alternative="stationary",k=1) 

Augmented Dickey-Fuller Test

data:  sprd 
Dickey-Fuller = -3.9226, Lag order = 1, p-value = 0.01281
alternative hypothesis: stationary 

> summary(ur.df(sprd, type="trend", lag=1))

############################################### 
# Augmented Dickey-Fuller Test Unit Root Test # 
############################################### 

Test regression trend 


Call:
lm(formula = z.diff ~ z.lag.1 + 1 + tt + z.diff.lag)

Residuals:
     Min       1Q   Median       3Q      Max 
-0.91172 -0.02737 -0.00097  0.02553  0.98989 

Coefficients:
              Estimate Std. Error t value Pr(>|t|)    
(Intercept) -2.434e-02  6.790e-03  -3.584 0.000340 ***
z.lag.1     -5.309e-03  1.353e-03  -3.923 8.85e-05 ***
tt           8.143e-06  2.134e-06   3.816 0.000137 ***
z.diff.lag  -5.345e-02  1.226e-02  -4.360 1.32e-05 ***
---
Signif. codes:  0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1 

Residual standard error: 0.05266 on 6624 degrees of freedom
Multiple R-squared: 0.005505,    Adjusted R-squared: 0.005055 
F-statistic: 12.22 on 3 and 6624 DF,  p-value: 5.676e-08 


Value of test-statistic is: -3.9226 6.7405 7.7586 

Critical values for test statistics: 
      1pct  5pct 10pct
tau3 -3.96 -3.41 -3.12
phi2  6.09  4.68  4.03
phi3  8.27  6.25  5.34


Both results indicate that the time series 'sprd' is cointegrated and thus
mean reverting. However looking at the plot one can clearly see that the
series is trending and is not mean reverting. Any thoughts would be greatly
appreciated.

>plot(sprd, type="l")

http://r.789695.n4.nabble.com/file/n3416574/Screen_shot_2011-03-29_at_7.37.39_PM.png
 


--
View this message in context: 
http://r.789695.n4.nabble.com/Interpreting-cointegration-ur-df-and-ad-test-tp3416574p3416574.html

Sent from the Rmetrics mailing list archive at Nabble.com.

_______________________________________________
R-SIG-Finance at r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-sig-finance
-- Subscriber-posting only. If you want to post, subscribe first.
-- Also note that this is not the r-help list where general R questions should 
go.



More information about the R-SIG-Finance mailing list