How to use ‘hts’ with multi-level hierarchies?

不问归期 提交于 2019-12-04 07:59:43
Earo Wang

We introduced a new concept nodes into the hts package (v4+) to replace the old gmatrix. To illustrate the usage of nodes, here's an example of a hierarchy with 4 levels (excluding total) and 24 bottom time series.

bts <- ts(matrix(rnorm(240), nrow = 10, ncol = 24)) 
nodes <- list(2, rep(2, 2), rep(2, 4), rep(3, 8))
hts(bts, nodes = nodes)

Each element of nodes specifies the number of children each node has at that level.

The tree plot is shown below:

=> A
  => AA
    => AAA
      => 3 bottom time series
    => AAB
      => 3 bottom time series
  => AB
    => ABA
      => 3 bottom time series
    => ABB
      => 3 bottom time series
=> B
  => BA
    => BAA
      => 3 bottom time series
    => BAB
      => 3 bottom time series
  => BB
    => BBA
      => 3 bottom time series
    => BBB
      => 3 bottom time series

The documentation is a bit terse, but you can use multi-level hierarchies when defining hts

In the pdf file link to the reference manual for the 'hts' package, you will find a reference to the paper. Specifically, on Page 7 of the pdf, where htseg1 is referenced:

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/

That link (the free online version which is a working paper) has an example with 3 levels, which is very similar to your continent|country|client example. http://robjhyndman.com/papers/Hierarchical6.pdf (See Section 6, page 14 which is titled Numerical Simulations)

Hope that helps.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!