简体   繁体   中英

variable selection Lasso glmnet - how to chose top x variables?

I am building poisson regression glm models and attempting to use glmnet (lasso) to identify variables for inclusion. I have about 150 weather related variables, and when run it through cv.glmnet it identifies about 137 of these as being above lambda.min.

However, from the MSE graph, I can see that much of the benefit in MSE can be obtained from the top 40 or so variables. But these are just labelled 1-153 -

How do I work out the order of variables and link these back to the variable names?

If you look at the coefficients of the fitted model you should see the variable names, which ones have coefficients that have been shrunk to zero (or close to zero) and which haven't.

You can return the coefficients using the coef function on the fitted model eg

fit <- cv.glmnet(x,y)
coef(fit)

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