# Chapter 10 Forecasting hierarchical or grouped time series

Warning: this is a more advanced section and assumes knowledge of some basic matrix algebra. We have however tried to simplify and explain in as much as detail as possible all the notation used starting from basic concepts and building up.

In this chapter we discuss forecasting large collections of time series that follow either a hierarchical or grouped aggregation structure. We clasify these as hierarchical or grouped time series in Sections 10.1 and 10.2 respectively. The challenge is that we require forecasts that are coherent across the aggregation structure. I.e., forecasts that add up in a manner consistent with the aggregation structure the collection of time series follow. Commonly used approaches are based on selecting a single level of aggregation, generating forecasts at that level and then combining these to produce coherent forecasts for the other time series. These approaches are presented in Sections 10.4-10.6. In Section 10.8 we introduce the concept of reconciliation where forecasts of all the times series in the collection are first generated and these are then reconciled so that they become coherent. This appraoch has the advantage that it incorporates information and the correlation structure across all the series in the collection.

### The hts package

Forecasting hierarchical and grouped time series is implemented using the hts package. Forecasts are simply obtained as usual with the forecast function. The R code below shows the possible arguments that this function takes when applied to a hierarchical or grouped time series.

forecast(object, h = ifelse(frequency(object$bts)>1, 2*frequency(object$bts), 10),
fmethod = c("ets", "arima", "rw"),
method = c("comb", "bu", "mo", "tdgsa", "tdgsf", "tdfp"),
weights = c("wls", "ols", "mint", "nseries"), ...)

We explain each of the arguments in the sections that follow in detail. Below is a brief introduction.

object
A hierarchical or grouped time series object to be forecast. We present how to generate a hierarchical time series object in Section 10.1 and a grouped time series object in Section 10.2 using the hts function.
fmethod
The forecasting model used for generating base forecasts. Possible values are "ets", "arima" and rw. These models have been studied in Chapters 7, 8 and 3 respectively. What is meant by base forecasts becomes clear in Section 10.3.
method
The method used for generating coherent forecasts. The possible values this argument can take are explained in Sections 10.4-10.8.
weights
Weight associated with the reconcilication approach presented in Section 10.8.