2017-04-19 4 views
0

Je voudrais utiliser stabsel sur le lasso glmnet pour la sélection variable. Je suivais les exemples sur https://github.com/hofnerb/stabs et cela fonctionne très bien.Utiliser penalty.factor dans stabsel dans R

Cependant, je voudrais aussi forcer l'inclusion de plusieurs variables. Cela peut être réalisé dans glmnet avec le paramètre 'penalty.factor', mais en passant ce paramètre dans args.fitfun à l'erreur de résultats stabsel (voir ci-dessous).

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] 

Toute aide serait grandement appréciée!

Répondre