我正在尝试为一个hts创建节点结构--有人能帮我做对吗?
我正在处理的层次结构有4个级别(不包括总计)。
Category => Sub_category => Product_type => Product为了重现性,我可以将其简化为以下内容:
structure <- data.frame(H1 = rep(1:2, rep(12, 2)),
H2 = rep(1:4, rep(6, 4)),
H3 = rep(1:8, rep(3, 8)),
H4 = 1:24)鉴于上述结构,如何构造hts()的节点参数?我读过这些文档,但是对于超过两个层次的结构,我仍然不能完全理解它。有一个old question along these lines,它的答案现在已经过时了(我想)。
非常感谢。
发布于 2014-04-09 12:48:10
根据structure数据框架,它使用以下节点结构:
nodes <- list(2, rep(2, 2), rep(2, 4), rep(3, 8)) 列表中的每个元素都给出了该级别每个节点的子节点数。
在绘制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我希望这有助于构建一个超过两个层次的节点结构。
https://stackoverflow.com/questions/22959500
复制相似问题