Passing a different forecasting method to a hierarchical time series forecast in R?

I have a hierarchical time series, a series of the lower level of which all shows periodic demand. It seems beneficial to use the Hyndman HTS package for the optimal combination within the hierarchy. It also seems advisable to use the Kourentzes MAPA package for multiple forecasting of intermittent demand. In essence, I want to do something like:

forecast(my_hts, method='comb', fmethod='MAPA')

However, it is not clear to me whether it is possible / to combine the two, since forecast.gts()it only acceptsfmethod=c("ets", "arima", "rw").

Is there a smart way to pass different forecasting methods on forecast.gts()without having to break the code?

An example to clarify what I mean:

library(hts)
library(MAPA)
set.seed(1)

#note intermittent demand of bottom level time series
x <- ts(rpois(365, lambda=0.05), frequency=365, start=2014)
y <- ts(rpois(365, lambda=0.07), frequency=365, start=2014)

#it easy to make a MAPA forecast for the top-level time series
#but this isn't an optimal hierarchical forecast
mapasimple(x+y)

#it also easy to make this a HTS and make an optimal hierarchical forecast
#but now I cannot use MAPA
z <- hts(data.frame(x,y)))
z_arima <- forecast(z, fmethod="arima")
z_rw <- forecast(z, fmethod="rw")
z_ets <- forecast(z, fmethod="ets")

#z_MAPA <- ?
+4
3

, hts ( RTFM), , combinef() hts, forecast.gts(). , , , .

fh <- 8

library(hts)
library(MAPA)
set.seed(1)

x <- ts(rpois(365, lambda=0.05), frequency=365, start=2014)
y <- ts(rpois(365, lambda=0.07), frequency=365, start=2014)

my_hts <- hts(data.frame(x,y))

ally <- aggts(my_hts)

allf <- matrix(NA, nrow = fh, ncol = ncol(ally))

for(i in 1:ncol(ally)){
    allf[,i] <- mapafor(ally[,i], 
                        mapaest(ally[,i], outplot=0), 
                        fh = fh, 
                        outplot=0)$outfor
}

allf <- ts(allf)

y.f <- combinef(allf, my_hts$nodes, weights=NULL, keep="bottom")

#here what the non-reconciled, bottom-level MAPA forecasts look like
print(allf[1,1:2])

 Series 1   Series 2
1 0.1343304 0.06032574

#here what the reconciled MAPA bottom-level forecasts look like
#notice that they're different
print(y.f[1,])

[1] 0.06030926 0.07402938
+5

" forecast.gts() ?" - . forecast.gts() family glm() .

, MAPA, . , , hts. hts; - .

, . "" GLS, , . , pcls() mgcv , (.. ) .

+2

MAPA combf. , . iMAPA tsintermittent, . MAPA, Croston, SBA , .

. , ISF E. Spiliotis et al. .

+1
source

All Articles