Reputation: 35
I'd like an example/method to incorporate regressors into forecast.hts. Below seems correct, but alas is not producing a forecast.
require(hts)
data(htseg2)
ri <- runif(14)
rix <- runif(16)
htseg2y <- hts(window(allts(htseg2),start = c(1992), end=c(2005))[,8:17],htseg2$g)
htseg2x <- hts((window(allts(htseg2),start = c(1992), end=c(2005))*ri)[,8:17],htseg2$g)
htseg2nx <- hts((window(allts(htseg2),start = c(1992), end=c(2007))*rix)[,8:17],htseg2$g)
forecast.hts(htseg2y , h = 2, fmethod = c("arima"), positive = F, stepwise=F,ic=c("bic"),level=4,trace=TRUE
,xreg = allts(htseg2x)
,newxreg = allts(htseg2nx))
Upvotes: 1
Views: 762
Reputation: 31800
Your hierarchical time series hts.mts
includes nine series. Your exogenous variable hts.mtsx$y
contains eight series. You also use the same exogenous series for the historical data as for the future data.
Upvotes: 1