adf.test使用xts返回p> 0.99,但使用coredata(xts)返回p <0.01

tma*_*ino 3 r xts

这是输出:

library(tseries) # for adf.test function

adf.test(data)
Augmented Dickey-Fuller Test

data:  data
Dickey-Fuller = 11.1451, Lag order = 16, p-value = 0.99
alternative hypothesis: stationary

Warning message:
In adf.test(spread.princomp) : p-value greater than printed p-value

adf.test(coredata(data))
Augmented Dickey-Fuller Test

data:  coredata(data)
Dickey-Fuller = -4.031, Lag order = 16, p-value = 0.01
alternative hypothesis: stationary

Warning message:
In adf.test(coredata(spread.princomp)) :
p-value smaller than printed p-value
Run Code Online (Sandbox Code Playgroud)

基础数据是数字向量.人们似乎成功地使用xts应用adf.test,所以我不确定我做错了什么.请告诉我我能提供的其他信息.

Jos*_*ich 7

?adf.testx(第一个参数)应该是数字向量或时间序列.通过"时间序列",它表示一个ts被分类的对象,而不是任何时间序列类对象.您应该ts在调用之前将xts对象转换为对象adf.test.

例如:

library(tseries)
library(xts)
data(sample_matrix)
x <- as.xts(sample_matrix[,1])
adf.test(as.ts(x))
Run Code Online (Sandbox Code Playgroud)

  • @tmakino:是的,那是因为`diff.zoo`和`diff.ts`没有填充领先的`NA`,而`diff.xts`没有. (2认同)