threeisles
threeisles

Reputation: 331

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?

Upvotes: 0

Views: 735

Answers (1)

rw2
rw2

Reputation: 1815

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 e.g.

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

Upvotes: 0

Related Questions