【问题标题】:hts non-conformable arrays forecasthts 不合格阵列预测
【发布时间】:2022-01-01 14:08:07
【问题描述】:

大家好,我正在尝试使用 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

谢谢

【问题讨论】:

    标签: r time-series forecasting hts


    【解决方案1】:

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

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

    accuracy() 中还有一个由每周数据触发的错误,我也已修复。

    【讨论】:

      【解决方案2】:

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

      试试这个:

      accuracy(fcasts$bts, test$bts)
      accuracy(fcasts$bts, test$bts, levels = 1)
      

      【讨论】:

      • 谢谢我基本上重新运行了这个包含修复的命令 devtools::install_github("earowang/hts")
      猜你喜欢
      • 2016-07-12
      • 2021-10-26
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2014-10-26
      • 1970-01-01
      • 2015-03-05
      相关资源
      最近更新 更多