hts (version 5.1.5)

combinef: Optimally combine forecasts from a hierarchical or grouped time series

Description

Using the method of Hyndman et al. (2011), this function optimally combines the forecasts at all levels of a hierarchical time series. The forecast.gts calls this function when the comb method is selected.

Usage

combinef(fcasts, nodes, groups, weights = NULL, algorithms = c("lu", "cg",
  "chol", "recursive", "slm"), keep = c("gts", "all", "bottom"))

Arguments

fcasts

Matrix of forecasts for all levels of the hierarchical time series. Each row represents one forecast horizon and each column represents one time series from the hierarchy.

nodes

If the object class is hts, a list contains the number of child nodes referring to hts.

groups

If the object class is gts, a gmatrix is required, which is the same as groups in the function gts.

weights

A numeric vector. The default is NULL which means that ordinary least squares is implemented.

algorithms

An algorithm to be used for computing reconciled forecasts. See forecast.gts for details.

keep

Return a gts object or the the reconciled forecasts at the bottom level.

Value

Return the reconciled gts object or forecasts at the bottom level.

References

R. J. Hyndman, R. A. Ahmed, G. Athanasopoulos and H.L. Shang (2011) Optimal combination forecasts for hierarchical time series. Computational Statistics and Data Analysis, 55(9), 2579--2589. http://robjhyndman.com/papers/hierarchical/

Hyndman, R. J., Lee, A., & Wang, E. (2014). Fast computation of reconciled forecasts for hierarchical and grouped time series. Working paper 17/14, Department of Econometrics & Business Statistics, Monash University. http://robjhyndman.com/working-papers/hgts/

See Also

hts, forecast.gts

Examples

Run this code
# NOT RUN {
# hts example
# }
# NOT RUN {
h <- 12
ally <- aggts(htseg1)
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, start = 51)
y.f <- combinef(allf, get_nodes(htseg1), weights = NULL, keep = "gts", algorithms = "lu")
plot(y.f)
# }
# NOT RUN {
# gts example
# }
# NOT RUN {
abc <- ts(5 + matrix(sort(rnorm(200)), ncol = 4, nrow = 50))
g <- rbind(c(1,1,2,2), c(1,2,1,2))
y <- gts(abc, groups = g)
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, start = 51)
y.f <- combinef(allf, groups = get_groups(y), keep ="gts", algorithms = "lu")
plot(y.f)
# }
# NOT RUN {
# }

Run the code above in your browser using DataCamp Workspace