簡體   English   中英

分層預測(hts軟件包)R不均勻分組和自定義預測

[英]hierarchical forecast (hts package) R uneven groups and custom forecast

我正在閱讀hts軟件包的自述文件。 我對嘗試定制預測部分感興趣,該部分需要使用指定的預測功能遍歷每個系列。 提供的示例顯示了偶數組。 我想知道如何運行數量不固定的自定義預測,然后將它們重新組合為gts對象。

bts <- ts(5 + matrix(sort(rnorm(500)), ncol=5, nrow=100))
y <- hts(bts, nodes=list(2, c(3, 2)))

allts_y <- aggts(y)
allf <- matrix(allts_y, nrow=100, ncol=ncol(allts_y))

for(i in 1:ncol(allts_y))
  allf[,i] <- forecast(auto.arima(allts_y[,i]), h=10)$mean
allf <- ts(allf, start=1)

# below code is where I run into a hang-up
g <- matrix(c(rep(2, 5), rep(3, 5), rep(1:5, 2)), nrow = 2, byrow = T)
y.f <- combinef(allf, groups = g)

您的組結構ghts()nodes參數指定的層次結構不匹配。 將最后一行替換為

y.f <- combinef(allf, nodes=y$nodes)

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM