0

How do I extract variables from elastic net for modeling purposes? (if this is a stupid question and the answer can be found someplace please let me know and I'll look)

I have already done cross validation and determined the alpha but I am trying to figure out how to extract the variables. If I run attributes(on the elastic net) I get the following options - a0, beta, df, dim, lambda, dev.ration, nulldev, npasses, jerr, offset, classnames, call, nobs. Beta looks promising when I look at it but it is hard to match that up to anything else.

x.train <- train3[, -50] #remove column 50 as that was the y  
x.train2 <- data.matrix((x.train[1:55])) #converted it to matrix
y.train <- train3$y

fit.elnet <- glmnet(x.train2, y.train, family="binomial", alpha=.1)
fit.elnet
plot(fit.elnet)
attributes(fit.elnet)
fit.elnet$beta

The ability to extract variables so that I can build a better decision tree or random forest.

westiegirl
  • 11
  • 4
  • I believe it should be `coef()`. – akash87 May 15 '19 at 00:31
  • Thanks I guess this leads me to ask how to interpret the results if I do coef(fit.elnet) – westiegirl May 16 '19 at 18:41
  • As you would with any binomial regression actually! The beauty of LASSO is that it penalizes the model based on size (parsimony) and the coefficients are similarly interpretative as the with binomial regression models.The difference actually may come in when you are looking at the standard errors of estimates. – akash87 May 16 '19 at 19:21

1 Answers1

0

I found the answer here - Extracting coefficient variable names from glmnet into a data.frame - it is David C comment that is labeled 2.

westiegirl
  • 11
  • 4