The glmnet package uses the LASSO range of lambda settings, scaled from the maximum lambda_max , in which no predictors are selected. I want to know how glmnet calculates this lambda_max value. For example, in a trivial dataset:
set.seed(1) library("glmnet") x <- matrix(rnorm(100*20),100,20) y <- rnorm(100) fitGLM <- glmnet(x,y) max(fitGLM$lambda)
The batch vignette ( http://www.jstatsoft.org/v33/i01/paper ) describes in section 2.5 that it calculates this value as follows:
sx <- as.matrix(scale(x)) sy <- as.vector(scale(y)) max(abs(colSums(sx*sy)))/100
Which is clearly close, but not the same. So what makes this difference? And in a related question, how could I calculate lambda_max for logistic regression?
source share