2017-04-19 15 views
0

可変選択のためにglmnetのラッソ上でstabselを使用したいと思います。私はhttps://github.com/hofnerb/stabsの例に従っていて、うまく動作します。stabselでpenalty.factorを使用するR

しかし、いくつかの変数も含めて強制したいと思います。これはglmnetでパラメータ 'penalty.factor'で実現できますが、args.fitfunでこのパラメータを渡すと結果エラー(下記参照)が発生します。

data("bodyfat", package = "TH.data") 
pfac=c(0,0,0,1,0,1,1,1,1) 
stab.glmnet <- stabsel(x = bodyfat[, -2], y = bodyfat[,2], 
          fitfun = glmnet.lasso, cutoff = 0.75, 
          PFER = 1, args.fitfun=list(penalty.factor = pfac)) 
Error in res[[1]] : subscript out of bounds 
In addition: Warning message: 
In run_stabsel(fitter = fit_model, args.fitter = args.fitfun, n = n,  : 
100 fold(s) encountered an error. Results are based on 0 folds only. 
Original error message(s): 
Error : Matrices must have same number of columns in rbind2(.Call(dense_to_Csparse, x), y) 
Error : Matrices must have same number of columns in rbind2(.Call(dense_to_Csparse, x), y) 
Error : Matrices must have same number of columns in rbind2(.Call(dense_to_Csparse, x), y) 
Error : Matrices must have same number of columns in rbind2(.Call(dense_to_Csparse, x), y) 
Error : Matrices must have same number of columns in rbind2(.Call(dense_to_Csparse, x), y) 
Error : Matrices must have same number of columns in rbind2(.Call(dense_to_Csparse, x), y) 
Error : Matrices must have same number of columns in rbind2(.Call(dense_to_Csparse, x), y) 
Error : Matrices must have same number of columns in rbind2(.Call(dense_to_Csparse, x), y) 
Error : Matrices must have same number of columns in rbind2(.Call(dense_to_Csparse, x), y) 
Error : Matrices must have same number of columns in rbind2(.Call(dense_to_Csparse, x [... truncated] 

ご協力いただければ幸いです。

答えて

関連する問題