adf.test用xts返回p> 0.99,但用coredata(xts)返回p 0.99 with xts, but returning p

编程入门 行业动态 更新时间:2024-10-28 01:21:05
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-value

The 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))

更多推荐

本文发布于:2023-07-26 03:56:00,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1270757.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:xts   test   adf   returning   coredata

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!