時間序列

為什麼以下數據無法通過我的協整檢驗?

  • October 18, 2011

我有兩家澳大利亞銀行的收盤價數據,它們相互密切跟踪。

http://dl.dropbox.com/u/12337149/stat/CBA.csv

http://dl.dropbox.com/u/12337149/stat/WBC.csv

此網頁的程式碼產生以下輸出

假設對沖比率為 2.26

ADF p 值為 0.47

當我繪製價格時,我得到一個看起來協整的圖表

http://dl.dropbox.com/u/12337149/stat/cointegration.png

我不明白為什麼我的 p 值這麼高。我稍微改編的 R 程式碼如下。

library(zoo)
library(tseries)

gld <- read.csv("C:\\...\\CBA.csv", stringsAsFactors=F)
gdx <- read.csv("C:\\...\\WBC.csv", stringsAsFactors=F)

gld <- zoo(gld[,5], as.Date(gld[,1]))
gdx <- zoo(gdx[,5], as.Date(gdx[,1]))

t.zoo <- merge(gld, gdx, all=FALSE)
t <- as.data.frame(t.zoo)

cat("Date range is", format(start(t.zoo)), "to", format(end(t.zoo)), "\n")

m <- lm(gld ~ gdx + 0, data=t)
beta <- coef(m)[1]

cat("Assumed hedge ratio is", beta, "\n")

sprd <- t$gld - beta*t$gdx
ht <- adf.test(sprd, alternative="stationary", k=0)

cat("ADF p-value is", ht$p.value, "\n")

if (ht$p.value < 0.05) {
   cat("The spread is likely mean-reverting\n")
} else {
   cat("The spread is not mean-reverting.\n")
}

這是我的程式碼:

require(xts)
require(urca)

# Load data
gld <- read.csv("~/Downloads/CBA.csv", stringsAsFactors = FALSE)
gdx <- read.csv("~/Downloads/WBC.csv", stringsAsFactors = FALSE)

# Convert to xts
gld <- xts(gld[, 4], as.POSIXct(gld[, 1], tz = "GMT", format = "%Y-%m-%d", tzone =    "GMT"))
gdx <- xts(gdx[, 4], as.POSIXct(gdx[, 1], tz = "GMT", format = "%Y-%m-%d", tzone = "GMT"))

# Plot original data
par(mfrow = c(2,1))
plot(gld)
plot(gdx)
par(mfrow = c(1,1))

# Linear regression with fixed alpha
regress <- lm(as.numeric(gld) ~ as.numeric(gdx) + 0)
cat("Beta is", coef(regress)[1])

# ADF test. We use drift type because we will an intercept
# in our data. 
adf <- ur.df(residuals(regress), type = "drift")
cat("ADF test statistic is", adf@teststat[1], "critical value is", adf@cval[1], "\n")
cat("Residuals are", ifelse(adf@teststat[1] < adf@cval[1], "stationary", "not stationary"))

# Plot residuals
plot(residuals(regress), type = "l")

看起來你的系列在這個樣本中沒有協整,看看殘差。您可以嘗試做的是: 1. 查看更長的樣本 2. 嘗試使用超過 2 個價格序列建構協整向量。提示:添加布倫特原油。您可以嘗試使用 Johansen 程序來解決這些問題。

引用自:https://quant.stackexchange.com/questions/2183