简体   繁体   中英

Extract coefficients from penalized regression

I am using the sparse group lasso, which is a penalized regression. The package I am using is SGL. I tried to run the examples in my R, and the code is given as below

set.seed(1)
n = 50; p = 100; size.groups = 10
index <- ceiling(1:p / size.groups)
X = matrix(rnorm(n * p), ncol = p, nrow = n)
beta = (-2:2)
y = X[,1:5] %*% beta + 0.1*rnorm(n)
data = list(x = X, y = y)
cvFit = cvSGL(data, index, type = "linear")

I tried to extract the regression coefficient of cvFit , but it turns out to be

coef(cvFit)
NULL

Can anyone tell me what is wrong? Thanks in advance.

这将从具有最小λ值的模型中提取系数。

coef(fit,s=cvfit$lambda.min)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM