0

大家好,我正在尝试使用 hts 包计算分层时间序列的准确度统计信息,但我收到一条错误消息,显示“x - fcasts 中的错误:不合格数组”。

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

谢谢

4

2 回答 2

0

我认为问题的出现是因为fcaststest的列表对象。

尝试这个:

accuracy(fcasts$bts, test$bts)
accuracy(fcasts$bts, test$bts, levels = 1)
于 2021-11-23T09:22:19.943 回答
0

这是hts包中的一个错误,我现在已经在开发版本中修复了(https://github.com/earowang/hts/commit/3f444cf6d6aca23a3a7f2d482df2e33bb078dc55)。

使用 CRAN 版本,通过使用与h测试集长度相同的预测范围 ( ) 来避免该问题。

accuracy()我也修复了由每周数据触发的另一个错误。

于 2021-11-23T22:46:38.290 回答