我想在玻璃套索上用刺刀做可变的选择。我在https://github.com/hofnerb/stabs上学习了这些例子,它运行得很好。
但是,我也想强制包括几个变量。这可以在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]任何帮助都将不胜感激!
发布于 2017-04-25 21:05:29
我想通了。由于我们通过设置penalty.factor来强制包含n个变量,我们需要调整三个稳定变量(截止变量、PFER变量、q变量),以确保允许在每个重采样中选择至少n个变量。
有关更多细节,请参见https://github.com/hofnerb/stabs/blob/master/README.md和http://onlinelibrary.wiley.com/doi/10.1111/j.1467-9868.2010.00740.x/full。
https://stackoverflow.com/questions/43507361
复制相似问题