I was using the hts R package for hierarchical forecasting and I want to obtain or extract the forecasted values into a data frame, for example:
library(hts)
data <- window(htseg2, start = 1992, end = 2002)
test <- window(htseg2, start = 2003)
fcasts <- as.data.frame(forecast(data, h = 5, method = "bu"))
plot(fcasts)
which plots the forecasted values in dotted lines, implying that somehow they can be extracted however, the fcasts
object does not store such information.
Thank you
The forecasts are saved efficiently, but if you want all of them, they can be computed using
allts()
and then converted to a data frame as follows.