Skip to main content

10  Forecasting hierarchical or grouped time series

Warning: this is a more advanced chapter and assumes a knowledge of some basic matrix algebra.

Time series can often be naturally disaggregated by various attributes of interest. For example, the total number of bicycles sold by a cycling manufacturer can be disaggregated by product type such as road bikes, mountain bikes, children’s bikes and hybrids. Each of these can be disaggregated into finer categories. For example hybrid bikes can be divided into city, commuting, comfort, and trekking bikes; and so on. These categories are nested within the larger group categories, and so the collection of time series follow a hierarchical aggregation structure. Therefore we refer to these as “hierarchical time series”, the topic of Section 10.1.

Hierarchical time series often arise due to geographic divisions. For example, the total bicycle sales can be disaggregated by country, then within each country by state, within each state by region, and so on down to the outlet level.

Our bicycle manufacturer may disaggregate sales by both product type and by geographic location. Then we have a more complicated aggregation structure where the product hierarchy and the geographic hierarchy can both be used together. We usually refer to these as “grouped time series”, and discuss them in Section 10.2.

It is common to produce disaggregated forecasts based on disaggregated time series, and we usually require the forecasts to add up in the same way as the data. For example, forecasts of regional sales should add up to give forecasts of state sales, which should in turn add up to give a forecast for the national sales.

In this chapter we discuss forecasting large collections of time series that must add up in some way. The challenge is that we require forecasts that are coherent across the aggregation structure. That is, we require forecasts to add up in a manner that is consistent with the aggregation structure of the collection of time series. In Sections 10.3–10.7 we discuss several methods for producing coherent forecasts for both hierarchical and grouped time series.

10.1 Hierarchical time series

Figure 10.1 shows a K = 2-level hierarchical structure. At the top of the hierarchy (which we call level 0) is the “Total”, the most aggregate level of the data. The tth observation of the Total series is denoted by y_t for t = 1,\dots,T. The Total is disaggregated into two series at level 1, which in turn are divided into three and two series respectively at the bottom-level of the hierarchy. Below the top level, we use y_{\text{j},t} to denote the tth observation of the series corresponding to node j. For example, y_{A,t} denotes the tth observation of the series corresponding to node A at level 1, y_{AB,t} denotes the tth observation of the series corresponding to node AB at level 2, and so on.

Figure 10.1: A two level hierarchical tree diagram.

In this small example, the total number of series in the hierarchy is n = 1 + 2 + 5 = 8, while the number of series at the bottom-level is m = 5. Note that n > m in all hierarchies.

For any time t, the observations at the bottom-level of the hierarchy will sum to the observations of the series above. For example, y_{t} = y_{\text{AA},t} + y_{\text{AB},t} + y_{\text{AC},t} + y_{\text{BA},t} + y_{\text{BB},t} \tag{10.1} and y_{\text{A},t} = y_{\text{AA},t} + y_{\text{AB},t} + y_{\text{AC},t}\quad \text{and} \quad y_{\text{B},t} = y_{\text{BA},t} + y_{\text{BB},t}. \tag{10.2} Substituting Equation 10.2 into Equation 10.1, we also get y_{t} = y_{\text{A},t} + y_{\text{B},t}. These equations can be thought of as aggregation constraints or summing equalities, and can be more efficiently represented using matrix notation. We construct an n \times m matrix \bm{S} (referred to as the “summing matrix”) which dictates the way in which the bottom-level series are aggregated.

For the hierarchical structure in Figure 10.1, we can write \begin{bmatrix} y_{t} \\ y_{\text{A},t} \\ y_{\text{B},t} \\ y_{\text{AA},t} \\ y_{\text{AB},t} \\ y_{\text{AC},t} \\ y_{\text{BA},t} \\ y_{\text{BB},t} \end{bmatrix} = \begin{bmatrix} 1 & 1 & 1 & 1 & 1 \\ 1 & 1 & 1 & 0 & 0 \\ 0 & 0 & 0 & 1 & 1 \\ 1 & 0 & 0 & 0 & 0 \\ 0 & 1 & 0 & 0 & 0 \\ 0 & 0 & 1 & 0 & 0 \\ 0 & 0 & 0 & 1 & 0 \\ 0 & 0 & 0 & 0 & 1 \end{bmatrix} \begin{bmatrix} y_{\text{AA},t} \\ y_{\text{AB},t} \\ y_{\text{AC},t} \\ y_{\text{BA},t} \\ y_{\text{BB},t} \end{bmatrix} or in more compact notation \bm{y}_t = \bm{S}\bm{b}_{t}, \tag{10.3} where \bm{y}_t is an n-dimensional vector of all the observations in the hierarchy at time t, \bm{S} is the summing matrix, and \bm{b}_{t} is an m-dimensional vector of all the observations in the bottom-level of the hierarchy at time t. Note that the first row in the summing matrix \bm{S} represents Equation 10.1 above, the second and third rows represent Equation 10.2. The rows below these comprise an m-dimensional identity matrix \bm{I}_m so that each bottom-level observation on the right hand side of the equation is equal to itself on the left hand side.

Example: Australian tourism hierarchy

Australia is divided into eight geographic areas (some called states and others called territories) with each one having its own government and some economic and administrative autonomy. Each of these can be further subdivided into smaller areas of interest, referred to as zones. Business planners and tourism authorities are interested in forecasts for the whole of Australia, for the states and the territories, and also for the zones. In this example we concentrate on quarterly domestic tourism demand, measured as the number of visitor nights Australians spend away from home. To simplify our analysis, we combine the two territories and Tasmania into an “Other” state. So we have six states: New South Wales (NSW), Queensland (QLD), South Australia (SAU), Victoria (VIC), Western Australia (WAU) and Other (OTH). For each of these we consider visitor nights within the following zones.

State Zones
NSW Metro (NSWMetro), North Coast (NSWNthCo), South Coast (NSWSthCo), South Inner (NSWSthIn), North Inner (NSWNthIn)
QLD Metro (QLDMetro), Central (QLDCntrl), North Coast (QLDNthCo)
SAU Metro (SAUMetro), Coastal (SAUCoast), Inner (SAUInner)
VIC Metro (VICMetro), West Coast (VICWstCo), East Coast (VICEstCo), Inner (VICInner)
WAU Metro (WAUMetro), Coastal (WAUCoast), Inner (WAUInner)
OTH Metro (OTHMetro), Non-Metro (OTHNoMet)

We consider five zones for NSW, four zones for VIC, and three zones each for QLD, SAU and WAU. Note that Metro zones contain the capital cities and surrounding areas. For further details on these geographic areas, please refer to Appendix C in Wickramasuriya et al. (2019).

To create a hierarchical time series, we use the hts() function as shown in the code below. The function requires two inputs: the bottom-level time series and information about the hierarchical structure. visnights is a time series matrix containing the bottom-level series. There are several ways to input the structure of the hierarchy. In this case we are using the characters argument. The first three characters of each column name of visnights capture the categories at the first level of the hierarchy (States). The following five characters capture the bottom-level categories (Zones).

library(hts)
tourism.hts <- hts(visnights, characters = c(3, 5))
tourism.hts |>
  aggts(levels = 0:1) |>
  autoplot(facet = TRUE) +
  xlab("Year") +
  ylab("millions") +
  ggtitle("Visitor nights")
Figure 10.2: Australian domestic visitor nights over the period 1998 Q1 to 2016 Q4 disaggregated by State.

The top plot in Figure 10.2 shows the total number of visitor nights for the whole of Australia, while the plots below show the data disaggregated by state. These reveal diverse and rich dynamics at the aggregate national level, and the first level of disaggregation for each state. The aggts() function extracts time series from an hts object for any level of aggregation.

The plots in Figure 10.3 show the bottom-level time series, namely the visitor nights for each zone. These help us visualise the diverse individual dynamics within each zone, and assist in identifying unique and important time series. Notice, for example, the coastal WAU zone which shows significant growth over the last few years.

library(tidyverse)
cols <- sample(scales::hue_pal(
  h = c(15, 375),
  c = 100,
  l = 65,
  h.start = 0,
  direction = 1
)(NCOL(visnights)))
as_tibble(visnights) |>
  gather(Zone) |>
  mutate(
    Date = rep(time(visnights), NCOL(visnights)),
    State = str_sub(Zone, 1, 3)
  ) |>
  ggplot(aes(x = Date, y = value, group = Zone, colour = Zone)) +
  geom_line() +
  facet_grid(State ~ ., scales = "free_y") +
  xlab("Year") +
  ylab("millions") +
  ggtitle("Visitor nights by Zone") +
  scale_colour_manual(values = cols)
Figure 10.3: Australian domestic visitor nights over the period 1998 Q1 to 2016 Q4 disaggregated by Zones.

To produce this figure, we are using various functions from the tidyverse collection of packages. The details are beyond the scope of this book, but there are many good online resources available to learn how to use these packages.

10.2 Grouped time series

Grouped time series involve more general aggregation structures than hierarchical time series. With grouped time series, the structure does not naturally disaggregate in a unique hierarchical manner, and often the disaggregating factors are both nested and crossed. For example, we could further disaggregate all geographic levels of the Australian tourism data by purpose of travel (such as holidays, business, etc.). So we could consider visitors nights split by purpose of travel for the whole of Australia, and for each state, and for each zone. Then we describe the structure as involving the purpose of travel “crossed” with the geographic hierarchy.

Figure 10.4 shows a K = 2-level grouped structure. At the top of the grouped structure is the Total, the most aggregate level of the data, again represented by y_t. The Total can be disaggregated by attributes (A, B) forming series y_{\text{A},t} and y_{\text{B},t}, or by attributes (X, Y) forming series y_{\text{X},t} and y_{\text{Y},t}. At the bottom level, the data are disaggregated by both attributes.

Figure 10.4: Alternative representations of a two level grouped structure.

This example shows that there are alternative aggregation paths for grouped structures. For any time t, as with the hierarchical structure, y_{t} = y_{\text{AX},t} + y_{\text{AY},t} + y_{\text{BX},t} + y_{\text{BY},t}. However, for the first level of the grouped structure, y_{\text{A},t} = y_{\text{AX},t} + y_{\text{AY},t}\quad \quad y_{\text{B},t} = y_{\text{BX},t} + y_{\text{BY},t} \tag{10.4} but also y_{\text{X},t} = y_{\text{AX},t} + y_{\text{BX},t}\quad \quad y_{\text{Y},t} = y_{\text{AY},t} + y_{\text{BY},t}. \tag{10.5}

These equalities can again be represented by the n \times m summing matrix \bm{S}. The total number of series is n = 9 with m = 4 series at the bottom-level. For the grouped structure in Figure 10.4 we write \begin{bmatrix} y_{t} \\ y_{\text{A},t} \\ y_{\text{B},t} \\ y_{\text{X},t} \\ y_{\text{Y},t} \\ y_{\text{AX},t} \\ y_{\text{AY},t} \\ y_{\text{BX},t} \\ y_{\text{BY},t} \end{bmatrix} = \begin{bmatrix} 1 & 1 & 1 & 1 \\ 1 & 1 & 0 & 0 \\ 0 & 0 & 1 & 1 \\ 1 & 0 & 1 & 0 \\ 0 & 1 & 0 & 1 \\ 1 & 0 & 0 & 0 \\ 0 & 1 & 0 & 0 \\ 0 & 0 & 1 & 0 \\ 0 & 0 & 0 & 1 \end{bmatrix} \begin{bmatrix} y_{\text{AX},t} \\ y_{\text{AY},t} \\ y_{\text{BX},t} \\ y_{\text{BY},t} \end{bmatrix}, or \bm{y}_t = \bm{S}\bm{b}_{t}, where the second and third rows of \bm{S} represent Equation 10.4 and the fourth and fifth rows represent Equation 10.5.

Grouped time series can sometimes be thought of as hierarchical time series that do not impose a unique hierarchical structure, in the sense that the order by which the series can be grouped is not unique.

Example: Australian prison population

The top row of Figure 10.5 shows the total number of prisoners in Australia over the period 2005 Q1 to 2016 Q4. This represents the top-level series in the grouping structure. The rest of the panels show the prison population disaggregated by (i) state1 (ii) legal status, whether prisoners have already been sentenced or are in remand waiting for a sentence, and (iii) gender. In this example, the three factors are crossed, but none are nested within the others.

Figure 10.5: Total Australian quarterly adult prison population, disaggregated by state, by legal status and by gender.

To create a grouped time series, we use the gts() function. Similar to the hts() function, inputs to the gts() function are the bottom-level time series and information about the grouping structure. prison is a time series matrix containing the bottom-level time series. The information about the grouping structure can be passed in using the characters input. (An alternative is to be more explicit about the labelling of the series and use the groups input.)

prison.gts <- gts(
  prison / 1e3,
  characters = c(3, 1, 9),
  gnames = c(
    "State",
    "Gender",
    "Legal",
    "State*Gender",
    "State*Legal",
    "Gender*Legal"
  )
)

One way to plot the main groups is as follows.

prison.gts |> aggts(level = 0:3) |> autoplot()

But with a little more work, we can construct Figure 10.5 using the following code.

p1 <- prison.gts |>
  aggts(level = 0) |>
  autoplot() +
  ggtitle("Australian prison population") +
  xlab("Year") +
  ylab("Total number of prisoners ('000)")
groups <- aggts(prison.gts, level = 1:3)
cols <- sample(scales::hue_pal(
  h = c(15, 375),
  c = 100,
  l = 65,
  h.start = 0,
  direction = 1
)(NCOL(groups)))
p2 <- as_tibble(groups) |>
  gather(Series) |>
  mutate(
    Date = rep(time(groups), NCOL(groups)),
    Group = str_extract(Series, "([A-Za-z ]*)")
  ) |>
  ggplot(aes(x = Date, y = value, group = Series, colour = Series)) +
  geom_line() +
  xlab("Year") +
  ylab("Number of prisoners ('000)") +
  scale_colour_manual(values = cols) +
  facet_grid(. ~ Group, scales = "free_y") +
  scale_x_continuous(breaks = seq(2006, 2016, by = 2)) +
  theme(axis.text.x = element_text(angle = 90, hjust = 1))
gridExtra::grid.arrange(p1, p2, ncol = 1)

Plots of other group combinations can be obtained similarly. Figure 10.6 shows the Australian prison population disaggregated by all possible combinations of two attributes at a time. The top plot shows the prison population disaggregated by state and legal status, the middle panel shows the disaggregation by state and gender and the bottom panel shows the disaggregation by legal status and gender.

Figure 10.6: Australian adult prison population disaggregated by pairs of attributes.

Figure 10.7 shows the Australian adult prison population disaggregated by all three attributes: state, legal status and gender. These form the bottom-level series of the grouped structure.

Figure 10.7: Bottom-level time series for the Australian adult prison population, grouped by state, legal status and gender.

10.3 The bottom-up approach

A simple method for generating coherent forecasts is the bottom-up approach. This approach involves first generating forecasts for each series at the bottom-level, and then summing these to produce forecasts for all the series in the structure.

For example, for the hierarchy of Figure 10.1, we first generate h-step-ahead forecasts for each of the bottom-level series: \hat{y}_{\text{AA},h},~~\hat{y}_{\text{AB},h},~~\hat{y}_{\text{AC},h}, ~~ \hat{y}_{\text{BA},h}~~\text{and}~~\hat{y}_{\text{BB},h}. (We have simplified the previously used notation of \hat{y}_{T+h|T} for brevity.) Summing these, we get h-step-ahead coherent forecasts for the rest of the series: \begin{align*} \tilde{y}_{h} & = \hat{y}_{\text{AA},h} + \hat{y}_{\text{AB},h} + \hat{y}_{\text{AC},h} + \hat{y}_{\text{BA},h} + \hat{y}_{\text{BB},h}, \\ \tilde{y}_{\text{A},h} & = \hat{y}_{\text{AA},h} + \hat{y}_{\text{AB},h} + \hat{y}_{\text{AC},h}, \\ \text{and}\quad \tilde{y}_{\text{B},h} & = \hat{y}_{\text{BA},h} + \hat{y}_{\text{BB},h}. \end{align*} (In this chapter, we will use the “tilde” notation to indicate coherent forecasts.) As in Equation 10.3, we can employ the summing matrix here and write \begin{bmatrix} \tilde{y}_{h} \\ \tilde{y}_{\text{A},h} \\ \tilde{y}_{\text{B},h} \\ \tilde{y}_{\text{AA},h} \\ \tilde{y}_{\text{AB},h} \\ \tilde{y}_{\text{AC},h} \\ \tilde{y}_{\text{BA},h} \\ \tilde{y}_{\text{BB},h} \end{bmatrix} = \begin{bmatrix} 1 & 1 & 1 & 1 & 1 \\ 1 & 1 & 1 & 0 & 0 \\ 0 & 0 & 0 & 1 & 1 \\ 1 & 0 & 0 & 0 & 0 \\ 0 & 1 & 0 & 0 & 0 \\ 0 & 0 & 1 & 0 & 0 \\ 0 & 0 & 0 & 1 & 0 \\ 0 & 0 & 0 & 0 & 1 \end{bmatrix} \begin{bmatrix} \hat{y}_{\text{AA},h} \\ \hat{y}_{\text{AB},h} \\ \hat{y}_{\text{AC},h} \\ \hat{y}_{\text{BA},h} \\ \hat{y}_{\text{BB},h} \end{bmatrix}.

Using more compact notation, the bottom-up approach can be represented as \tilde{\bm{y}}_{h} = \bm{S}\hat{\bm{b}}_{h}, where \tilde{\bm{y}}_h is an n-dimensional vector of coherent h-step-ahead forecasts, and \hat{\bm{b}}_{h} is an m-dimensional vector of h-step-ahead forecasts for each of the bottom-level series.

An advantage of this approach is that we are forecasting at the bottom-level of a structure, and therefore no information is lost due to aggregation. On the other hand, bottom-level data can be quite noisy and more challenging to model and forecast.

The hts package for R

Forecasts can be produced using the forecast() function applied to objects created by hts() or gts(). The hts package has three in-built options to produce forecasts: ETS models, ARIMA models or random walks; these are controlled by the fmethod argument. It also use several methods for producing coherent forecasts, controlled by the method argument.

For example, suppose we wanted bottom-up forecasts using ARIMA models applied to the prison data. Then we would use

forecast(prison.gts, method = "bu", fmethod = "arima")

which will apply the auto.arima() function to every bottom-level series in our collection of time series. Similarly, ETS models would be used if fmethod="ets" was used.

10.4 Top-down approaches

Top-down approaches only work with strictly hierarchical aggregation structures, and not with grouped structures. They involve first generating forecasts for the Total series y_t, and then disaggregating these down the hierarchy.

We let p_1,\dots,p_{m} be a set of disaggregation proportions which dictate how the forecasts of the Total series are to be distributed to obtain forecasts for each series at the bottom-level of the structure. For example, for the hierarchy of Figure 10.1 using proportions p_1,\dots,p_{5} we get, \tilde{y}_{\text{AA},t} = p_1\hat{y}_t,~~~\tilde{y}_{\text{AB},t} = p_2\hat{y}_t, ~~~\tilde{y}_{\text{AC},t} = p_3\hat{y}_t, ~~~\tilde{y}_{\text{BA},t} = p_4\hat{y}_t~~~\text{and}~~~~~~\tilde{y}_{\text{BB},t} = p_5\hat{y}_t. Using matrix notation we can stack the set of proportions in a m-dimensional vector \bm{p} = (p_1,\dots,p_{m})' and write \tilde{\bm{b}}_{t} = \bm{p}\hat{y}_t. Once the bottom-level h-step-ahead forecasts have been generated, these are aggregated to generate coherent forecasts for the rest of the series. In general, for a specified set of proportions, top-down approaches can be represented as \tilde{\bm{y}}_h = \bm{S}\bm{p}\hat{y}_t.

The two most common top-down approaches specify disaggregation proportions based on the historical proportions of the data. These performed well in the study of Gross & Sohl (1990).

Average historical proportions

p_j = \frac{1}{T}\sum_{t=1}^{T}\frac{y_{j,t}}{{y_t}} for j = 1,\dots,m. Each proportion p_j reflects the average of the historical proportions of the bottom-level series y_{j,t} over the period t = 1,\dots,T relative to the total aggregate y_t.

This approach is implemented in the forecast() function by setting method="tdgsa", where tdgsa stands for “top-down Gross-Sohl method A”.

Proportions of the historical averages

p_j = {\sum_{t=1}^{T}\frac{y_{j,t}}{T}}\Big/{\sum_{t=1}^{T}\frac{y_t}{T}} for j = 1,\dots,m. Each proportion p_j captures the average historical value of the bottom-level series y_{j,t} relative to the average value of the total aggregate y_t.

This approach is implemented in the forecast() function by setting method="tdgsf", where tdgsf stands for “top-down Gross-Sohl method F”.

A convenient attribute of such top-down approaches is their simplicity. One only needs to model and generate forecasts for the most aggregated top-level series. In general, these approaches seem to produce quite reliable forecasts for the aggregate levels and they are useful with low count data. On the other hand, one disadvantage is the loss of information due to aggregation. Using such top-down approaches, we are unable to capture and take advantage of individual series characteristics such as time dynamics, special events, etc.

Forecast proportions

Because historical proportions used for disaggregation do not take account of how those proportions may change over time, top-down approaches based on historical proportions tend to produce less accurate forecasts at lower levels of the hierarchy than bottom-up approaches. To address this issue, proportions based on forecasts rather than historical data can be used (Athanasopoulos et al., 2009).

Consider a one level hierarchy. We first generate h-step-ahead forecasts for all of the series. We don’t use these forecasts directly, and they are not coherent (they don’t add up correctly). Let’s call these “base” forecasts. We calculate the proportion of each h-step-ahead base forecast at the bottom level, to the aggregate of all the h-step-ahead base forecasts at this level. We refer to these as the forecast proportions, and we use them to disaggregate the top-level h-step-ahead base forecast in order to generate coherent forecasts for the whole of the hierarchy.

For a K-level hierarchy, this process is repeated for each node, going from the top to the bottom level. Applying this process leads to the following general rule for obtaining the forecast proportions: p_j = \prod^{K-1}_{\ell=0}\frac{\hat{y}_{j,h}^{(\ell)}}{\hat{S}_{j,h}^{(\ell+1)}} where j = 1,2,\dots,m, \hat{y}_{j,h}^{(\ell)} is the h-step-ahead base forecast of the series that corresponds to the node which is \ell levels above j, and \hat{S}_{j,h}^{(\ell)} is the sum of the h-step-ahead base forecasts below the node that is \ell levels above node j and are directly connected to that node. These forecast proportions disaggregate the h-step-ahead base forecast of the Total series to get h-step-ahead coherent forecasts of the bottom-level series.

We will use the hierarchy of Figure 10.1 to explain this notation and to demonstrate how this general rule is reached. Assume we have generated base forecasts for each series in the hierarchy. Recall that for the top-level “Total” series, \tilde{y}_{h} = \hat{y}_{h}, for any top-down approach. Here are some examples using the above notation:

  • \hat{y}_{\text{A},h}^{(1)} = \hat{y}_{\text{B},h}^{(1)} = \hat{y}_{h} = \tilde{y}_{h};
  • \hat{y}_{\text{AA},h}^{(1)} = \hat{y}_{\text{AB},h}^{(1)} = \hat{y}_{\text{AC},h}^{(1)} = \hat{y}_{\text{A},h};
  • \hat{y}_{\text{AA},h}^{(2)} = \hat{y}_{\text{AB},h}^{(2)} = \hat{y}_{\text{AC},h}^{(2)} = \hat{y}_{\text{BA},h}^{(2)} = \hat{y}_{\text{BB},h}^{(2)} = \hat{y}_{h} = \tilde{y}_{h};
  • \hat{S}_{\text{AA},h}^{(1)} = \hat{S}_{\text{AB},h}^{(1)} = \hat{S}_{\text{AC},h}^{(1)} = \hat{y}_{\text{AA},h} + \hat{y}_{\text{AB},h} + \hat{y}_{\text{AC},h};
  • \hat{S}_{\text{AA},h}^{(2)} = \hat{S}_{\text{AB},h}^{(2)} = \hat{S}_{\text{AC},h}^{(2)} = \hat{S}_{\text{A},h}^{(1)} = \hat{S}_{\text{B},h}^{(1)} = \hat{S}_{h} = \hat{y}_{\text{A},h} + \hat{y}_{\text{B},h}.

Moving down the farthest left branch of the hierarchy, coherent forecasts are given by \tilde{y}_{\text{A},h} = \Bigg(\frac{\hat{y}_{\text{A},h}}{\hat{S}_{\text{A},h}^{(1)}}\Bigg) \tilde{y}_{h} = \Bigg(\frac{\hat{y}_{\text{AA},h}^{(1)}}{\hat{S}_{\text{AA},h}^{(2)}}\Bigg) \tilde{y}_{h} and \tilde{y}_{\text{AA},h} = \Bigg(\frac{\hat{y}_{\text{AA},h}}{\hat{S}_{\text{AA},h}^{(1)}}\Bigg) \tilde{y}_{\text{A},h} = \Bigg(\frac{\hat{y}_{\text{AA},h}}{\hat{S}_{\text{AA},h}^{(1)}}\Bigg) \Bigg(\frac{\hat{y}_{\text{AA},h}^{(1)}}{\hat{S}_{\text{AA},h}^{(2)}}\Bigg)\tilde{y}_{h}. Consequently, p_1 = \Bigg(\frac{\hat{y}_{\text{AA},h}}{\hat{S}_{\text{AA},h}^{(1)}}\Bigg) \Bigg(\frac{\hat{y}_{\text{AA},h}^{(1)}}{\hat{S}_{\text{AA},h}^{(2)}}\Bigg). The other proportions can be obtained similarly.

One disadvantage of all top-down approaches, including this one, is that it does not produce unbiased coherent forecasts (Hyndman et al., 2011).

This approach is implemented in the forecast() function by setting method="tdfp", where tdfp stands for “top-down forecast proportions”.

10.5 Middle-out approach

The middle-out approach combines bottom-up and top-down approaches. First, a “middle level” is chosen and forecasts are generated for all the series at this level. For the series above the middle level, coherent forecasts are generated using the bottom-up approach by aggregating the “middle-level” forecasts upwards. For the series below the “middle level”, coherent forecasts are generated using a top-down approach by disaggregating the “middle level” forecasts downwards.

This approach is implemented in the forecast() function by setting method="mo" and by specifying the appropriate middle level via the level argument. For the top-down disaggregation below the middle level, the top-down forecast proportions method is used.

10.6 Mapping matrices

All of the methods considered so far can be expressed using a common notation.

Suppose we forecast all series independently, ignoring the aggregation constraints. We call these the base forecasts and denote them by \hat{\bm{y}}_h where h is the forecast horizon. They are stacked in the same order as the data \bm{y}_t.

Then all forecasting approaches for either hierarchical or grouped structures can be represented as \tilde{\bm{y}}_h = \bm{S}\bm{G}\hat{\bm{y}}_h, \tag{10.6} where \bm{G} is a matrix that maps the base forecasts into the bottom-level, and the summing matrix \bm{S} sums these up using the aggregation structure to produce a set of coherent forecasts \tilde{\bm{y}}_h.

The \bm{G} matrix is defined according to the approach implemented. For example if the bottom-up approach is used to forecast the hierarchy of Figure 10.1, then \bm{G} = \begin{bmatrix} 0 & 0 & 0 & 1 & 0 & 0 & 0 & 0 \\ 0 & 0 & 0 & 0 & 1 & 0 & 0 & 0 \\ 0 & 0 & 0 & 0 & 0 & 1 & 0 & 0 \\ 0 & 0 & 0 & 0 & 0 & 0 & 1 & 0 \\ 0 & 0 & 0 & 0 & 0 & 0 & 0 & 1 \\ \end{bmatrix}. Notice that \bm{G} contains two partitions. The first three columns zero out the base forecasts of the series above the bottom-level, while the m-dimensional identity matrix picks only the base forecasts of the bottom-level. These are then summed by the \bm{S} matrix.

If any of the top-down approaches were used then \bm{G} = \begin{bmatrix} p_1 & 0 & 0 & 0 & 0 & 0 & 0 & 0 \\ p_2 & 0 & 0 & 0 & 0 & 0 & 0 & 0 \\ p_3 & 0 & 0 & 0 & 0 & 0 & 0 & 0 \\ p_4 & 0 & 0 & 0 & 0 & 0 & 0 & 0 \\ p_5 & 0 & 0 & 0 & 0 & 0 & 0 & 0 \\ \end{bmatrix}. The first column includes the set of proportions that distribute the base forecasts of the top-level to the bottom-level. These are then summed up the hierarchy by the \bm{S} matrix. The rest of the columns zero out the base forecasts below the highest level of aggregation.

For a middle out approach, the \bm{G} matrix will be a combination of the above two. Using a set of proportions, the base forecasts of some pre-chosen level will be disaggregated to the bottom-level, all other base forecasts will be zeroed out, and the bottom-level forecasts will then summed up the hierarchy via the summing matrix.

Forecast reconciliation

We can rewrite Equation 10.6 as \tilde{\bm{y}}_h = \bm{P}\hat{\bm{y}}_h, \tag{10.7} where \bm{P} = \bm{S}\bm{G} is a “projection” or a “reconciliation matrix”. That is, it takes the incoherent base forecasts \hat{\bm{y}}_h, and reconciles them to produce coherent forecasts \tilde{\bm{y}}_h.

In the methods discussed so far, no real reconciliation has been done because the methods have been based on forecasts from a single level of the aggregation structure, which have either been aggregated or disaggregated to obtain forecasts at all other levels. However, in general, we could use other \bm{G} matrices, and then \bm{P} will be combining and reconciling all the base forecasts in order to produce coherent forecasts.

In fact, we can find the optimal \bm{G} matrix to give the most accurate reconciled forecasts.

10.7 The optimal reconciliation approach

Optimal forecast reconciliation will occur if we can find the \bm{G} matrix which minimises the forecast error of the set of coherent forecasts. We present here a simplified summary of the approach. More details are provided in Wickramasuriya et al. (2019).

Suppose we generate coherent forecasts using Equation 10.6, repeated here for convenience: \tilde{\bm{y}}_h = \bm{S}\bm{G}\hat{\bm{y}}_h.

First we want to make sure we have unbiased forecasts. If the base forecasts \hat{\bm{y}}_h are unbiased, then the coherent forecasts \tilde{\bm{y}}_h will be unbiased provided \bm{S}\bm{G}\bm{S} = \bm{S} (Hyndman et al., 2011). This provides a constraint on the matrix \bm{G}. Interestingly, no top-down method satisfies this constraint, so all top-down methods are biased.

Next we need to find the error in our forecasts. Wickramasuriya et al. (2019) show that the variance-covariance matrix of the h-step-ahead coherent forecast errors is given by \bm{V}_h = \text{Var}[\bm{y}_{T+h}-\tilde{\bm{y}}_h] = \bm{S}\bm{G}\bm{W}_h\bm{G}'\bm{S}' where \bm{W}_h = \text{Var}[(\bm{y}_{T+h}-\hat{\bm{y}}_h)] is the variance-covariance matrix of the corresponding base forecast errors.

The objective is to find a matrix \bm{G} that minimises the error variances of the coherent forecasts. These error variances are on the diagonal of the matrix \bm{V}_h, and so the sum of all the error variances is given by the trace of the matrix \bm{V}_h. Wickramasuriya et al. (2019) show that the matrix \bm{G} which minimises the trace of \bm{V}_h such that \bm{S}\bm{G}\bm{S} = \bm{S}, is given by \bm{G} = (\bm{S}'\bm{W}_h^{-1}\bm{S})^{-1}\bm{S}'\bm{W}_h^{-1}. Therefore, the optimal reconciled forecasts are given by \tilde{\bm{y}}_h = \bm{S}(\bm{S}'\bm{W}_h^{-1}\bm{S})^{-1}\bm{S}'\bm{W}_h^{-1}\hat{\bm{y}}_h. \tag{10.8} We refer to this as the “MinT” (or Minimum Trace) estimator.

To use this in practice, we need to estimate \bm{W}_h, the forecast error variance of the h-step-ahead base forecasts. This can be difficult, and so we provide four simplifying approximations which have been shown to work well in both simulations and in practice.

  1. Set \bm{W}_h = k_h\bm{I} for all h, where k_{h} > 0.2 This is the most simplifying assumption to make, and means that \bm{G} is independent of the data, providing substantial computational savings. The disadvantage, however, is that this specification does not account for the differences in scale between the levels of the structure, or for relationships between series. This approach is implemented in the forecast() function by setting method = "comb" and weights = "ols".

    The weights here are referred to as OLS (ordinary least squares) because setting \bm{W}_h = k_h\bm{I} in Equation 10.8 gives the least squares estimator we introduced in Section 5.7 with \bm{X} = \bm{S} and \bm{y} = \hat{\bm{y}}.

  2. Set \bm{W}_{h} = k_{h}\text{diag}(\hat{\bm{W}}_{1}) for all h, where k_{h} > 0, \hat{\bm{W}}_{1} = \frac{1}{T}\sum_{t=1}^{T}\bm{e}_{t}\bm{e}_{t}', and \bm{e}_{t} is an n-dimensional vector of residuals of the models that generated the base forecasts stacked in the same order as the data. The approach is implemented by setting method = "comb" and weights = "wls".

    This specification scales the base forecasts using the variance of the residuals and it is therefore referred to as the WLS (weighted least squares) estimator using variance scaling.

  3. Set \bm{W}_{h} = k_{h}\bm{\Lambda} for all h, where k_{h} > 0, \bm{\Lambda} = \text{diag}(\bm{S}\bm{1}), and \bm{1} is a unit vector of dimension m (the number of bottom-level series). This specification assumes that the bottom-level base forecast errors each have variance k_{h} and are uncorrelated between nodes. Hence each element of the diagonal \bm{\Lambda} matrix contains the number of forecast error variances contributing to each node. This estimator only depends on the structure of the aggregations, and not on the actual data. It is therefore referred to as structural scaling. Applying the structural scaling specification is particularly useful in cases where residuals are not available, and so variance scaling cannot be applied; for example, in cases where the base forecasts are generated by judgmental forecasting (Chapter 4). This approach is implemented by setting method="comb" and weights = "nseries".

  4. Set \bm{W}_h = k_h \bm{W}_1 for all h, where k_h > 0. Here we only assume that the error covariance matrices are proportional to each other, and we directly estimate the full one-step covariance matrix \bm{W}_1. The most obvious and simple way would be to use the sample covariance. This is implemented by setting method = "comb", weights = "mint", and covariance = "sam".

    However, for cases where the number of bottom-level series m is large compared to the length of the series T, this is not a good estimator. Instead we use a shrinkage estimator which shrinks the sample covariance to a diagonal matrix. This is implemented by setting method = "comb", weights = "mint", and covariance = "shr".

In summary, unlike any other existing approach, the optimal reconciliation forecasts are generated using all the information available within a hierarchical or a grouped structure. This is important, as particular aggregation levels or groupings may reveal features of the data that are of interest to the user and are important to be modelled. These features may be completely hidden or not easily identifiable at other levels.

For example, consider the Australian tourism data introduced in Section 10.1, where the hierarchical structure followed the geographic division of a country into states and zones. Some coastal areas will be largely summer destinations, while some mountain regions may be winter destinations. These differences will be smoothed at the country level due to aggregation.

Example: Forecasting Australian prison population

We compute the forecasts for the Australian prison population, described in Section 10.2. Using the default arguments for the forecast() function, we compute coherent forecasts by the optimal reconciliation approach with the WLS estimator using variance scaling.

prisonfc <- forecast(prison.gts)

To obtain forecasts for each level of aggregation, we can use the aggts() function. For example, to calculate forecasts for the overall total prison population, and for the one-factor groupings (State, Gender and Legal Status), we use:

fcsts <- aggts(prisonfc, levels = 0:3)

A simple plot is obtained using

groups <- aggts(prison.gts, levels = 0:3)
autoplot(fcsts) + autolayer(groups)

A nicer plot is available using the following code. The results are shown in Figure 10.8. The vertical line marks the start of the forecast period.

prisonfc <- ts(rbind(groups, fcsts), start = start(groups), frequency = 4)
p1 <- autoplot(prisonfc[, "Total"]) +
  ggtitle("Australian prison population") +
  xlab("Year") +
  ylab("Total number of prisoners ('000)") +
  geom_vline(xintercept = 2017)
cols <- sample(scales::hue_pal(
  h = c(15, 375),
  c = 100,
  l = 65,
  h.start = 0,
  direction = 1
)(NCOL(groups)))
p2 <- as_tibble(prisonfc[, -1]) |>
  gather(Series) |>
  mutate(
    Date = rep(time(prisonfc), NCOL(prisonfc) - 1),
    Group = str_extract(Series, "([A-Za-z ]*)")
  ) |>
  ggplot(aes(x = Date, y = value, group = Series, colour = Series)) +
  geom_line() +
  xlab("Year") +
  ylab("Number of prisoners ('000)") +
  scale_colour_manual(values = cols) +
  facet_grid(. ~ Group, scales = "free_y") +
  scale_x_continuous(breaks = seq(2006, 2018, by = 2)) +
  theme(axis.text.x = element_text(angle = 90, hjust = 1)) +
  geom_vline(xintercept = 2017)
gridExtra::grid.arrange(p1, p2, ncol = 1)
Figure 10.8: Coherent forecasts for the total Australian adult prison population and for the population grouped by state, by legal status and by gender.

Similar code was used to produce Figure 10.9. The left panel plots the coherent forecasts for interactions between states and gender. The right panel shows forecasts for the bottom-level series.

Figure 10.9: Coherent forecasts for the Australian adult prison population grouped by all interactions of attributes.

The accuracy() command is useful for evaluating the forecast accuracy across hierarchical or grouped structures. The following table summarises the accuracy of the bottom-up and the optimal reconciliation approaches, forecasting 2015 Q1 to 2016 Q4 as a test period.

The results show that the optimal reconciliation approach generates more accurate forecasts especially for the top level. In general, we find that as the optimal reconciliation approach uses information from all levels in the structure, it generates more accurate coherent forecasts than the other traditional alternatives which use limited information.

Accuracy of Australian prison population forecasts for different groups of series.
Bottom-up
Optimal
MAPE MASE MAPE MASE
Total 5.32 1.84 3.08 1.06
State 7.59 1.88 7.62 1.85
Legal status 6.40 1.76 4.32 1.14
Gender 8.62 2.68 8.72 2.74
Bottom 15.82 2.23 15.25 2.16
All series 12.41 2.16 12.02 2.08

10.8 Exercises

  1. Write out the \bm{S} matrices for the Australian tourism hierarchy and the Australian prison grouped structure. Use the smatrix command to verify your answers.
  2. Generate 8-step-ahead bottom-up forecasts using ARIMA models for the visnights Australian domestic tourism data. Plot the coherent forecasts by level and comment on their nature. Are you satisfied with these forecasts?
  3. Model the aggregate series for Australian domestic tourism data visnights using an ARIMA model. Comment on the model. Generate and plot 8-step-ahead forecasts from the ARIMA model and compare these with the bottom-up forecasts generated in question 2 for the aggregate level.
  4. Generate 8-step-ahead optimally reconciled coherent forecasts using ARIMA base forecasts for the visnights Australian domestic tourism data. Plot the coherent forecasts by level and comment on their nature. How and why are these different to the bottom-up forecasts generated in question 2 above.
  5. Using the last two years of the visnights Australian domestic tourism data as a test set, generate bottom-up, top-down and optimally reconciled forecasts for this period and compare their accuracy.

10.9 Further reading

There are no other textbooks which cover hierarchical forecasting in any depth, so interested readers will need to tackle the original research papers for further information.

  • Gross & Sohl (1990) provide a good introduction to the top-down approaches.
  • The reconciliation methods were developed in a series of papers, which are best read in the following order: Hyndman et al. (2011), Athanasopoulos et al. (2009), Hyndman et al. (2016), Wickramasuriya et al. (2019).
  • Athanasopoulos et al. (2017) extends the reconciliation approach to deal with temporal hierarchies.


  1. Australia comprises eight geographic areas six states and two territories: Australian Capital Territory, New South Wales, Northern Territory, Queensland, South Australia, Tasmania, Victoria, Western Australia. In this example we consider all eight areas.↩︎

  2. Note that k_{h} is a proportionality constant. It does not need to be estimated or specified here as it gets cancelled out in Equation 10.8.↩︎