首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >penalty.factor在R中的应用

penalty.factor在R中的应用
EN

Stack Overflow用户
提问于 2017-04-19 22:49:38
回答 1查看 519关注 0票数 0

我想在玻璃套索上用刺刀做可变的选择。我在https://github.com/hofnerb/stabs上学习了这些例子,它运行得很好。

但是,我也想强制包括几个变量。这可以在glmnet中实现,参数为'penalty.factor',但在args.fitfun中传递此参数以稳定结果错误(见下文)。

代码语言:javascript
复制
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]

任何帮助都将不胜感激!

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2017-04-25 21:05:29

我想通了。由于我们通过设置penalty.factor来强制包含n个变量,我们需要调整三个稳定变量(截止变量、PFER变量、q变量),以确保允许在每个重采样中选择至少n个变量。

有关更多细节,请参见https://github.com/hofnerb/stabs/blob/master/README.mdhttp://onlinelibrary.wiley.com/doi/10.1111/j.1467-9868.2010.00740.x/full

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/43507361

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档