R Cointegration

May 26, 2010 by · Leave a Comment
Filed under: Notes 

From package tseries:

from po.test help:

x <- ts(diffinv(matrix(rnorm(2000),1000,2)))
po.test(x)
Phillips-Ouliaris Cointegration Test
data: x
Phillips-Ouliaris demeaned = -13.5288, Truncation lag parameter = 10,
p-value = 0.15
Warning message:
In po.test(x) : p-value greater than printed p-value: Fail to reject null hypothesis that there is no cointegration, i.e., not cointegrated
x <- diffinv(rnorm(1000)) y <- 2.0-3.0*x+rnorm(x,sd=5) z <- ts(cbind(x,y)) # cointegrated po.test(z) Phillips-Ouliaris Cointegration Test data: z Phillips-Ouliaris demeaned = -933.6705, Truncation lag parameter = 10, p-value = 0.01 Warning message: In po.test(z) : p-value smaller than printed p-value Reject null hypothesis that there is no cointegration, i.e., cointegrated

R Stationarity Test

May 26, 2010 by · Leave a Comment
Filed under: Notes 

From kpss.test help

package:tseries

Level Stationary Example
x <- rnorm(1000) # is level stationary
kpss.test(x)
KPSS Test for Level Stationarity
data: x
KPSS Level = 0.0319, Truncation lag parameter = 7, p-value = 0.1 <- fail to reject null hypothesis that x is stationary
Warning message:
In kpss.test(x) : p-value greater than printed p-value

Not Stationary Example
y <- cumsum(x) # has unit root
kpss.test(y)
KPSS Test for Level Stationarity
data: y
KPSS Level = 9.4899, Truncation lag parameter = 7, p-value = 0.01 <- Safe to reject null hypothesis that x is stationary
Warning message:
In kpss.test(y) : p-value smaller than printed p-value

Trend Stationary Example
x <- 0.3*(1:1000)+rnorm(1000) # is trend stationary
kpss.test(x, null = "Trend")
KPSS Test for Trend Stationarity
data: x
KPSS Trend = 0.1068, Truncation lag parameter = 7, p-value = 0.1 <- Fail to reject null hypothesis that x is trend stationary
Warning message:
In kpss.test(x, null = "Trend") : p-value greater than printed p-value