Reconciles a hierarchy using the middle out reconciliation method. The response variable of the hierarchy must be aggregated using sums. The forecasted time points must match for all series in the hierarchy, which must be strictly hierarchical.

reconcile_mo(model, split = 1)

middle_out(models, split = 1)

Arguments

model

A column of models in a mable (e.g. mutate(ets = reconcile_mint(ets))), a model data frame, or a model specification (e.g. model(ets = reconcile_mint(ETS(y)))).

split

The middle level of the hierarchy from which the bottom-up and top-down approaches are used above and below respectively. Either the number of levels below the top level (starting from 1 for the level just below the total), or the name of the key variable of that level.

models

Used instead of model by the superseded names.

Details

The forecasts of the split level are aggregated bottom-up for the levels above it, and disaggregated top-down (using the forecast proportions) for the levels below it. Splitting at the bottom level is bottom-up reconciliation.

Superseded names

[Superseded]

middle_out() is the original name of reconcile_mo(), and is kept for existing code. New code should use reconcile_mo(), consistent with the other reconcile_*() functions.

Examples

library(fable)
tourism_agg <- tsibble::tourism %>%
  dplyr::filter(State %in% c("Tasmania", "Northern Territory")) %>%
  aggregate_key(State / Region, Trips = sum(Trips))

tourism_agg %>%
  model(snaive = SNAIVE(Trips)) %>%
  dplyr::mutate(snaive = reconcile_mo(snaive, split = "State")) %>%
  forecast(h = 4)
#> # A fable: 60 x 6 [1Q]
#> # Key:     State, Region, .model [15]
#>    State              Region        .model Quarter
#>    <chr*>             <chr*>        <chr>    <qtr>
#>  1 Northern Territory Alice Springs snaive 2018 Q1
#>  2 Northern Territory Alice Springs snaive 2018 Q2
#>  3 Northern Territory Alice Springs snaive 2018 Q3
#>  4 Northern Territory Alice Springs snaive 2018 Q4
#>  5 Northern Territory Barkly        snaive 2018 Q1
#>  6 Northern Territory Barkly        snaive 2018 Q2
#>  7 Northern Territory Barkly        snaive 2018 Q3
#>  8 Northern Territory Barkly        snaive 2018 Q4
#>  9 Northern Territory Darwin        snaive 2018 Q1
#> 10 Northern Territory Darwin        snaive 2018 Q2
#> # ℹ 50 more rows
#> # ℹ 2 more variables: Trips <dist>, .mean <dbl>