# forecast.gts

From hts v6.0.1
0th

Percentile

##### Forecast a hierarchical or grouped time series

Methods for forecasting hierarchical or grouped time series.

Keywords
ts
##### Usage
# S3 method for gts
forecast(
object,
h = ifelse(frequency(object$bts) > 1L, 2L * frequency(object$bts), 10L),
method = c("comb", "bu", "mo", "tdgsa", "tdgsf", "tdfp"),
weights = c("wls", "ols", "mint", "nseries"),
fmethod = c("ets", "arima", "rw"),
algorithms = c("lu", "cg", "chol", "recursive", "slm"),
covariance = c("shr", "sam"),
nonnegative = FALSE,
control.nn = list(),
keep.fitted = FALSE,
keep.resid = FALSE,
positive = FALSE,
lambda = NULL,
level,
FUN = NULL,
xreg = NULL,
newxreg = NULL,
parallel = FALSE,
num.cores = 2,
...
)
##### Arguments
object

Hierarchical or grouped time series object of class {gts}

h

Forecast horizon

method

Method for distributing forecasts within the hierarchy. See details

weights

Weights used for "optimal combination" method: weights="ols" uses an unweighted combination (as described in Hyndman et al 2011); weights="wls" uses weights based on forecast variances (as described in Hyndman et al 2016); weights="mint" uses a full covariance estimate to determine the weights (as described in Wickramasuriya et al 2019); weights="nseries" uses weights based on the number of series aggregated at each node.

fmethod

Forecasting method to use for each series.

algorithms

An algorithm to be used for computing the combination forecasts (when method=="comb"). The combination forecasts are based on an ill-conditioned regression model. "lu" indicates LU decomposition is used; "cg" indicates a conjugate gradient method; "chol" corresponds to a Cholesky decomposition; "recursive" indicates the recursive hierarchical algorithm of Hyndman et al (2016); "slm" uses sparse linear regression. Note that algorithms = "recursive" and algorithms = "slm" cannot be used if weights="mint".

covariance

Type of the covariance matrix to be used with weights="mint": either a shrinkage estimator ("shr") with shrinkage towards the diagonal; or a sample covariance matrix ("sam").

nonnegative

Logical. Should the reconciled forecasts be non-negative?

control.nn

A list of control parameters to be passed on to the block principal pivoting algorithm. See 'Details'.

keep.fitted

If TRUE, keep fitted values at the bottom level.

keep.resid

If TRUE, keep residuals at the bottom level.

positive

If TRUE, forecasts are forced to be strictly positive (by setting lambda=0).

lambda

Box-Cox transformation parameter.

level

Level used for "middle-out" method (only used when method = "mo").

FUN

A user-defined function that returns an object which can be passed to the forecast function. It is applied to all series in order to generate base forecasts. When FUN is not NULL, fmethod, positive and lambda are all ignored. Suitable values for FUN are tbats and stlf for example.

xreg

When fmethod = "arima", a vector or matrix of external regressors used for modelling, which must have the same number of rows as the original univariate time series

newxreg

When fmethod = "arima", a vector or matrix of external regressors used for forecasting, which must have the same number of rows as the h forecast horizon

parallel

If TRUE, import parallel package to allow parallel processing.

num.cores

If parallel = TRUE, specify how many cores are going to be used.

...

Other arguments passed to ets, auto.arima or FUN.

##### Details

Base methods implemented include ETS, ARIMA and the naive (random walk) models. Forecasts are distributed in the hierarchy using bottom-up, top-down, middle-out and optimal combination methods.

Three top-down methods are available: the two Gross-Sohl methods and the forecast-proportion approach of Hyndman, Ahmed, and Athanasopoulos (2011). The "middle-out" method "mo" uses bottom-up ("bu") for levels higher than level and top-down forecast proportions ("tdfp") for levels lower than level.

For non-hierarchical grouped data, only bottom-up and combination methods are possible, as any method involving top-down disaggregation requires a hierarchical ordering of groups.

When xreg and newxreg are passed, the same covariates are applied to every series in the hierarchy.

The control.nn argument is a list that can supply any of the following components:

ptype

Permutation method to be used: "fixed" or "random". Defaults to "fixed".

par

The number of full exchange rules that may be tried. Defaults to 10.

gtol

The tolerance of the convergence criteria. Defaults to sqrt(.Machine\$double.eps).

##### Value

A forecasted hierarchical/grouped time series of class gts.

##### Note

In-sample fitted values and resiuals are not returned if method = "comb" and nonnegative = TRUE.

##### References

Athanasopoulos, G., Ahmed, R. A., & Hyndman, R. J. (2009). Hierarchical forecasts for Australian domestic tourism, International Journal of Forecasting, 25, 146-166.

Hyndman, R. J., Ahmed, R. A., Athanasopoulos, G., & Shang, H. L. (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. (2016). Fast computation of reconciled forecasts for hierarchical and grouped time series. Computational Statistics and Data Analysis, 97, 16--32. http://robjhyndman.com/papers/hgts/

Wickramasuriya, S. L., Athanasopoulos, G., & Hyndman, R. J. (2019). Optimal forecast reconciliation for hierarchical and grouped time series through trace minimization. Journal of the American Statistical Association, 114(526), 804--819. http://robjhyndman.com/working-papers/mint/

Wickramasuriya, S. L., Turlach, B. A., & Hyndman, R. J. (to appear). Optimal non-negative forecast reconciliation. Statistics and Computing. https://robjhyndman.com/publications/nnmint/

Gross, C., & Sohl, J. (1990). Dissagregation methods to expedite product line forecasting, Journal of Forecasting, 9, 233--254.

hts, gts, plot.gts, accuracy.gts

• forecast.gts
• forecast.hts
##### Examples
# NOT RUN {
forecast(htseg1, h = 10, method = "bu", fmethod = "arima")

# }
# NOT RUN {
forecast(
htseg2, h = 10, method = "comb", algorithms = "lu",
FUN = function(x) tbats(x, use.parallel = FALSE)
)
# }
# NOT RUN {
# }

Documentation reproduced from package hts, version 6.0.1, License: GPL (>= 2)

### Community examples

Looks like there are no examples yet.