Is cv.glmnet data overflow with full lambda sequence?

cv.glmnetused by most research papers and companies. When building a similar function, such as cv.glmnetfor glmnet.cr(a similar package that implements lasso ordinal regression to continue), I ran into this problem in cv.glmnet.

`cv.glmnet` first fits the model:



glmnet.object = glmnet(x, y, weights = weights, offset = offset, 
                     lambda = lambda, ...)

After creating an object glmnetwith full data, the next step will look like this: lambdafrom the entire installed model

lambda = glmnet.object$lambda

Now they make sure that the number of folds is more than 3

if (nfolds < 3) 
stop("nfolds must be bigger than 3; nfolds=10 recommended")

A list has been created to store cross-confirmed results.

outlist = as.list(seq(nfolds))

A for loopis performed to match different pieces of data in the theory of cross-validation

  for (i in seq(nfolds)) {
    which = foldid == i
    if (is.matrix(y)) 
      y_sub = y[!which, ]
    else y_sub = y[!which]
    if (is.offset) 
      offset_sub = as.matrix(offset)[!which, ]
    else offset_sub = NULL
#using the lambdas for the complete data 
    outlist[[i]] = glmnet(x[!which, , drop = FALSE], 
                          y_sub, lambda = lambda, offset = offset_sub, 
                          weights = weights[!which], ...)
  }
}

. , lambdas . - , ?. - , . cv.glmnet !

+3
2

, - "" , "" . . , -, , (, ). , , ( ) . , , . . ( ) .

+1

, .

cv.glmnet() -. . lambda==lambda.1se ( lambda.min), @Fabians :

lambda==lambda.min : is the lambda-value where cvm is minimized

lambda==lambda.1se : is the lambda-value where (cvm-cvsd)=cvlow is minimized. This is your optimal lambda

. cv.glmnet() coef(..., s='lambda.1se')

+1

All Articles