2016-04-17 29 views
1

RでHTSパッケージを使用して、階層内で売上予測を実行するのに最適なレベルを評価しています。forecast.htsメソッドを使用するとエラーが発生する

私が持っている問題は、tdfpを使用して予測を実行しているときです(下位の予測を使用して下位を分解する)。残りのモデルは正常に動作しています。あなたの助けを再構築するための

手順を事前に

感謝: 私はエラーmeessageがある:

"Error en rowsum.default(flist[[j + 1L]], repcount) : incorrect length for 'group'" 

ファイルのエラーを再現するためには、(うまくいけばそれが動作中に見つけることができ、

https://github.com/memdux/hts_error.git

あなたは以下のコードを使用することができ、エラーを再現するために:私は専門家)ではありませんよ

require("forecast") 
require("hts") 

dates_input= read.csv("test_data_dates.csv",sep =";", dec = ".") 
soh= read.csv("test_data_values.csv",sep =";", dec = ".") 

soh_matrix = as.matrix(soh) 

ts_soh = ts(soh_matrix, 
      start=c(2012, 01), 
      end=c(2015, 01), 
      frequency=12) 

y <- hts(ts_soh, characters = c(2, 3, 4, 3, 5)) 

train = window(y, start = c(2012,1), end = c(2014, 9)) 
test = window(y, start = c(2014,10), end = c(2015, 1)) 

fcst_hts_3 = forecast.gts(train, h = 4, method = "tdfp", fmethod = "arima") 
# Same error if using forecast (no gts) and/or ets as forecast method 

答えて

1

また、この問題はhts v5.1.4で発生しました。 TdFp関数は、charactersパラメーターの一般的なトップレベルラベルが気に入らないようです。私の場合、すべてのラベルは "R03"で始まり、charactersパラメータはc(3,2、...)で始まります。この部分文字列をラベルから削除し、charactersパラメータをc(2、...)に変更したところ、すべてうまくいきました。

$ nodes:List of 5 
..$ Level 1: int 1 
..$ Level 2: 'table' int[1(1d)] 10 
... 
$ labels: List of 6 
..$ Level 0: chr "Total" 
..$ Level 1: chr "R03" 

一方だった第二のケースで:HTSは、オブジェクト変数が持っていた最初のケ​​ースで

$ nodes :List of 4 
    ..$ Level 1: int 10 
    ..$ Level 2: 'table' int [1:10(1d)] 5 4 4 4 ... 
... 
$ labels :List of 5 
    ..$ Level 0: chr "Total" 
    ..$ Level 1: chr [1:10] "AC" "AK" "AL" "BA" ... 
関連する問題