r - 在没有截距的情况下使用 SCAD 惩罚拟合 Lasso
问题描述
我正在使用cv.ncvreg
适合. 由于我需要选择使用交叉验证,因此我选择使用函数。我在下面给出了我的代码。Lasso
SCAD
lambda
cv.ncvreg
r
library(ncvreg)
n = 100
p = 10
beta0 = c(2, 0, 3, 0, 0, 1, 0, 0, 0, 0)
X = matrix(rnorm(n * p, 0,1), ncol = p)
y=vector(mode="numeric",length=n)
X[,3]=rnorm(n,2,1)
X[,4]=rnorm(n,4,1)
X[,5]=rnorm(n,5,1)
ei_N=rnorm(n,0,1) # the model errors
y= X%*%beta0 + ei_N
fit = cv.ncvreg(X, y, penalty = "SCAD", standardize=TRUE)
coef = coef(fit, s = "lambda.min")
coef
我获得以下输出
(Intercept) V1 V2 V3 V4 V5 V6 V7
0.06907783 1.98544923 0.00000000 3.01165615 0.00000000 0.00000000 1.00447815 0.00000000
V8 V9 V10
0.00000000 0.00000000 0.00000000
如果您看到输出,则拟合模型具有intercept
. 如果没有一段时间的交叉验证来选择,我如何lasso
适应SCAD
惩罚?谢谢你。intercept
lambda
解决方案
推荐阅读
- python - Importing tflearn is very slow
- charts - Chart.js 从折线图中移除阴影
- php - 将数据从一个视图发送到另一个视图 - 流明 (AMP)
- c - scanf_s() 缓冲区在哪里定义?
- c# - 处理大文本 (JSON) 文件
- python-3.x - 通过不同的行值同时过滤 Pandas
- sql - 将 Windows 系统日期导入 SQL Server
- android - HeifWriter 支持库最低 API 级别为 28
- r - 联合/合并重叠的时间范围
- spring-boot-admin - Spring Boot Admin 在 Cloudfoundry 中的多个服务实例之间不能有区别