【问题标题】:How to use ‘hts’ with multi-level hierarchies?如何在多级层次结构中使用“hts”?
【发布时间】:2012-11-14 18:46:37
【问题描述】:

我正在对大量时间序列(5,000 多个)进行预测。如果我在更高级别进行预测,然后将预测分配到每个 SKU,我想使用分层方法来做到这一点。我认为有必要这样做以便放大较低的地理细节级别,同时在更高级别(自上而下)进行预测。

例如,您可以在下面看到我正在考虑的结构示例。

Total
  => Europe
     => Netherlands
        => RegionA
           => Client_A_in_Netherlands
              => SKU1
              => SKU2
              => SKU3
           => Client_Q_in_Netherlands
              => SKU15
     => Germany1
        => (...)
           => ClientY_in_Germany
              => SKU89
  => Africa
     => South Africa
        => (...)
           => Client_Z_in_SouthAfrica
              => SKU792

我想在大陆级别(即欧洲或非洲)级别进行自上而下的预测。然后将适当的份额分配给各个国家/地区,然后分配给该国家/地区的客户,然后分配给 SKU。

在“hts”包的文档中,有一个关于如何使用两级层次结构执行此操作的示例。我想知道是否有人可以建议如何使用多级层次结构来做到这一点?

【问题讨论】:

    标签: r hierarchy time-series forecasting


    【解决方案1】:

    我们在 hts 包 (v4+) 中引入了一个新概念 nodes,以取代旧的 gmatrix。为了说明nodes 的用法,下面是一个具有 4 个级别(不包括总数)和 24 个底部时间序列的层次结构示例。

    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)
    

    nodes 的每个元素指定每个节点在该级别的子节点数。

    树状图如下:

    => 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
    

    【讨论】:

      【解决方案2】:

      文档有点简洁,但在定义hts时可以使用多级层次结构

      In the pdf file link to the reference manual 对于 'hts' 包,您将找到该论文的参考。具体来说,在 pdf 的第 7 页上,其中引用了 htseg1

      R。 J Hyndman、R. A. Ahmed、G. Athanasopoulos 和 H.L. Shang (2011) 最佳组合 分层时间序列的预测。 计算统计和数据分析55(9), 2579–2589http://robjhyndman.com/papers/hierarchical/

      该链接(作为工作文件的免费在线版本)具有 3 个级别的示例,这与您的大陆|国家|客户示例非常相似。 http://robjhyndman.com/papers/Hierarchical6.pdf(参见第 14 页第 6 节,标题为数值模拟)

      希望对您有所帮助。

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 2014-07-23
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2022-06-27
        • 2014-11-13
        • 2018-04-26
        • 1970-01-01
        相关资源
        最近更新 更多