问题描述
我预测的时间序列很大(超过5,000个).我想使用分层方法来完成此任务,因为我会进行更高级别的预测,然后将预测分配给每个SKU.我认为有必要这样做,以便放大较低的地理细节级别,同时进行较高级别的预测(自上而下).
I am forecasting on a large set of time series (5,000+). I would like to do this with a hierarchical approach were I do the forecasting at a higher level and then allocate the forecast down to each SKU. I see a need for doing this in order to zoom into a lower geographic level of detail, while doing the forecasting on a higher level (top-down).
例如,在下面,您看到我正在考虑的结构的示例.
For example, below you see a sample of the structure that I am thinking about.
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.
I would like to do the top-down forecast at continent level (i.e. Europe or Africa) level. Then allocate the appropriate share to the countries, then to the clients within that country and then to the SKU.
在"hts"软件包的文档中,有一个有关如何使用两级层次结构执行此操作的示例.我想知道是否有人可以建议如何使用多级层次结构?
In the documentation of the ‘hts’ package there is an example on how to do this with a two-level hierarchy. I was wondering whether somebody could advise on how to do this with a multi-level hierarchy?
推荐答案
我们在hts
软件包(v4 +)中引入了新概念nodes
,以替换旧的gmatrix
.为了说明nodes
的用法,下面是一个具有4个级别(不包括总计)和24个底部时间序列的层次结构的示例.
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)
nodes
的每个元素指定每个节点在该级别具有的子代数.
Each element of nodes
specifies the number of children each node has at that level.
树图如下所示:
=> 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
这篇关于如何在多层结构中使用"hts"?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!