大家好,我试着用hts软件包计算分层时间序列的准确性统计,但是我得到一个错误,上面写着“x-fcast中的错误:不符合的数组”。
library(hts)
abc <- matrix(sample(1:100, 32*140, replace=TRUE), ncol=32)
colnames(abc) <- c(
paste0("A0",1:5),
paste0("B0",1:9),"B10",
paste0("C0",1:8),
paste0("D0",1:5),
paste0("E0",1:4)
)
abc <- ts(abc, start=2019, frequency=365.25/7)
x <- hts(abc, characters = c(1,2))
data <- window(x, start = 2019.000, end = 2021.166)
test <- window(x, start = 2021.185)
fcasts <- forecast(data, h = 20, method = "bu")
accuracy(fcasts, test)
accuracy(fcasts test, levels = 1)然后,错误消息是:
> data <- window(x, start = 2019.000, end = 2021.166)
> test <- window(x, start = 2021.185)
> fcasts <- forecast(data, h = 20, method = "bu")
There were 32 warnings (use warnings() to see them)
> accuracy(fcasts, test)
Error in x - fcasts : non-conformable arrays
> accuracy(fcasts, test, levels = 1)
Error in x - fcasts : non-conformable arrays谢谢
发布于 2021-11-23 22:46:38
这是hts包中的一个bug,我现在已经在dev版本(https://github.com/earowang/hts/commit/3f444cf6d6aca23a3a7f2d482df2e33bb078dc55)中修复了这个错误。
使用CRAN版本,通过使用与测试集长度相同的预测水平(h),可以避免这个问题。
accuracy()中还有一个错误是由我也修复过的每周数据触发的。
发布于 2021-11-23 09:22:19
我认为问题的出现是因为、fcast、和测试的list对象。
试试这个:
accuracy(fcasts$bts, test$bts)
accuracy(fcasts$bts, test$bts, levels = 1)https://stackoverflow.com/questions/70074839
复制相似问题