Purpose
To check whether CAN bank and YES bank form a pair

> library(TSA)
> library(lmtest)
> library(fUnitRoots)
> y1 <- (x[, 2])
> x1 <- (x[, 3])

Granger Test

> (grangertest(y1 ~ x1, order = 1))[2, 4]
[1] 0.0624092
> (grangertest(x1 ~ y1, order = 1))[2, 4]
[1] 0.3317135

Unit Root Test

> fit <- lm(y1 ~ x1)
> if (summary(fit)$coefficients[1, 4] < 0.05) {
+     error <- residuals(fit)
+ } else {
+     fit <- lm(y1 ~ x1 + 0)
+     error <- residuals(fit)
+ }
> n <- length(error)
> res <- unitrootTest(error, lag = 1, type = "c")
> attr(res, "test")$p.value[1]
         t
0.03138289

Chris Brooks test

> dy1 <- diff(y1)
> dx1 <- diff(x1)
> error.lag <- error[-n]
> fit <- lm(dy1 ~ error.lag + dx1)
> fit.summary <- summary(fit)
> fit.summary$coefficients[2, 4]
[1] 0.001984493

PFAFF test

> z <- data.frame(embed(cbind(dy1, dx1), 2))
> colnames(z) <- c("dy1", "dx1", "dy1.1", "dx1.1")
> error.lag <- error[-c(1, n)]
> fit <- lm(dy1 ~ error.lag + dy1.1 + dx1.1, data = z)
> fit.summary <- summary(fit)
> fit.summary$coefficients[2, 4]
[1] 0.0407627
> title <- "CANARA - YES "
> res <- armasubsets(error, nar = 14, nma = 14)
Reordering variables and trying again:
> plot(res, main = title)
> eacf(error)
AR/MA
  0 1 2 3 4 5 6 7 8 9 10 11 12 13
0 x x x x x x x x x x x  x  x  x
1 o o o o x x o o o o o  o  x  o
2 x o o o o o o o o o o  o  o  o
3 x x o o o x o o o o o  o  o  o
4 x x x o o o o o o o o  o  o  o
5 x x x o o o o o o o o  o  o  o
6 x x x o o o o o o o o  o  o  o
7 x x x x o o o o o o o  o  o  o

YES-CAN-006.jpg

It is not an AR process and hence risky to model it as an OU process

> plot(error, type = "l")
> abline(h = 0)

YES-CAN-007.jpg

If I forcefit an OU process

> oufit <- lm(error[2:276] ~ error[1:275])
> b <- coefficients(oufit)[2]
> a <- coefficients(oufit)[1]
> kappa <- -log(b) * 252
> pair.half.life <- log(2) * 252/kappa
> pair.half.life
error[1:275]
    8.265652

So, at min it is going to take 17 days to revert