2021年3月19日星期五

How to get the coefficents of a Cross Validated Lasso for a specific lambda (Not the “1se” or “min” lambda)

I runed a CV Lasso with the cv.gamlr function in R. I can get the coefficients for the lambdas that correspond to the "1se" or "min" criterion.

set.seed(123)  lasso<-cv.gamlr(x = X, y = Y, family ='binomial')  coef(lasso,select = "1se")  coef(lasso,select = "min")  

¿But what if I want to obtain the coefficients for a specific lambda, stored in the lasso$gamlr$lambda vector? ¿Is it possible to obtain them? For example, to get the coefficients for the first lambda in the model... Something like this:

lambda_100<-  lasso$gamlr$lambda[100]    coef(lasso,select = lambda_100)  

Of course this sends the following error:

Error in match.arg(select) : 'arg' must be NULL or a character vector  

Thanks :)

https://stackoverflow.com/questions/66718416/how-to-get-the-coefficents-of-a-cross-validated-lasso-for-a-specific-lambda-not March 20, 2021 at 01:05PM

没有评论:

发表评论