在组合预测时,得到的hts时间序列具有A、AA、AB等等级名称。它不保留提供的hts时间序列中的级别名称。
在下面的示例中,底层名称是"A10A“& "A10B",而产生的底层名称是"AA”、"BB“。
是否有办法在组合预测对象中保留原始级别名称?
library(forecast)
library(hts)
abc <- ts(5 + matrix(sort(rnorm(20)), ncol = 2, nrow = 10))
colnames(abc) <- c("A10A", "A10B")
y <- hts(abc, characters = c(3, 1))
h <- 12
ally <- aggts(y)
allf <- matrix(NA, nrow = h, ncol = ncol(ally))
for(i in 1:ncol(ally))
allf[,i] <- forecast(auto.arima(ally[,i]), h = h)$mean
allf <- ts(allf)
y.f <- combinef(allf, get_nodes(y), weights = NULL, keep = "gts", algorithms = "lu")发布于 2018-07-18 22:44:22
在代码的末尾,添加以下行:
colnames(allf) <- colnames(ally)
colnames(y.f$bts) <- colnames(y$bts)
y.f$nodes <- y$nodes
y.f$labels <- y$labelshttps://stackoverflow.com/questions/51412743
复制相似问题