2014-04-09 30 views
1

我想創建一個hts的節點結構 - 任何人都可以幫助我得到這個權利?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()節點參數?我已經閱讀了文檔,但仍不能完全理解它對於2級以上的結構。有一個old question along these lines,答案現在已過時(我認爲)。

非常感謝。

回答

1

按照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 

我希望在構建節點結構有超過2級幫助。

+0

感謝您在這裏的幫助球員。我現在正在工作。我有成千上萬的孩子時間系列,所以變得相當混亂。 –