adf.test用xts返回p> 0.99,但用coredata(xts)返回p <0.01(adf.test returning p > 0.99 with xts, but returning p < 0.01 with coredata(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基础数据是一个数字向量。 人们似乎成功地将adf.test与xts结合使用,所以我不确定我做错了什么。 请让我知道我可以提供什么其他信息。
Here is the output:
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-valueThe underlying data is a numeric vector. People seem to be successful at applying adf.test with xts, so I'm not sure what I'm doing wrong. Please let me know what other information I can provide.
最满意答案
?adf.test说x (第一个参数)应该是数字向量或时间序列。 对于“时间序列”,它表示一个ts分类对象,而不是任何时间序列类对象。 在调用adf.test之前,您应该将您的xts对象转换为ts对象。
例如:
library(tseries) library(xts) data(sample_matrix) x <- as.xts(sample_matrix[,1]) adf.test(as.ts(x))?adf.test says that x (the first argument) should be a numeric vector or time series. By "time series", it means a ts classed object, not any time-series class object. You should convert your xts object to a ts object before calling adf.test.
For example:
library(tseries) library(xts) data(sample_matrix) x <- as.xts(sample_matrix[,1]) adf.test(as.ts(x))更多推荐
发布评论