Questions tagged [glmnet]

R package for lasso and elastic-net regularized generalized linear models.

glmnet is an R package which provides Lasso and elastic-net regularized generalized linear models. It features extremely efficient procedures for fitting the entire Lasso or elastic-net regularization path for linear regression, logistic and multinomial regression models, Poisson regression and the Cox model.

Resources:

431 questions
44
votes
5 answers

Using LASSO from lars (or glmnet) package in R for variable selection

Sorry if this question comes across a little basic. I am looking to use LASSO variable selection for a multiple linear regression model in R. I have 15 predictors, one of which is categorical(will that cause a problem?). After setting my $x$ and $y$…
James
  • 441
  • 1
  • 5
  • 4
43
votes
2 answers

How to interpret glmnet?

I am trying to fit a multivariate linear regression model with approximately 60 predictor variables and 30 observations, so I am using the glmnet package for regularized regression because p>n. I have been going through documentation and other…
Alice
  • 825
  • 2
  • 8
  • 12
41
votes
3 answers

How to present results of a Lasso using glmnet?

I would like to find predictors for a continuous dependent variable out of a set of 30 independent variables. I am using Lasso regression as implemented in the glmnet package in R. Here is some dummy code: # generate a dummy dataset with 30…
jokel
  • 2,403
  • 4
  • 32
  • 40
35
votes
2 answers

Why is lambda "within one standard error from the minimum" is a recommended value for lambda in an elastic net regression?

I understand what role lambda plays in an elastic-net regression. And I can understand why one would select lambda.min, the value of lambda that minimizes cross validated error. My question is Where in the statistics literature is it recommended to…
33
votes
1 answer

Why does glmnet use "naive" elastic net from the Zou & Hastie original paper?

The original elastic net paper Zou & Hastie (2005) Regularization and variable selection via the elastic net introduced elastic net loss function for linear regression (here I assume all variables are centered and scaled to unit variance):…
amoeba
  • 93,463
  • 28
  • 275
  • 317
32
votes
4 answers

LASSO with interaction terms - is it okay if main effects are shrunk to zero?

LASSO regression shrinks coefficients towards zero, thus providing effectively model selection. I believe that in my data there are meaningful interactions between nominal and continuous covariates. Not necessarily, however, are the 'main effects'…
tomka
  • 5,874
  • 3
  • 30
  • 71
32
votes
3 answers

How to build the final model and tune probability threshold after nested cross-validation?

Firstly, apologies for posting a question that has already been discussed at length here, here, here, here, here, and for reheating an old topic. I know @DikranMarsupial has written about this topic at length in posts and journal papers, but I'm…
31
votes
2 answers

Choosing optimal alpha in elastic net logistic regression

I'm performing an elastic-net logistic regression on a health care dataset using the glmnet package in R by selecting lambda values over a grid of $\alpha$ from 0 to 1. My abbreviated code is below: alphalist <- seq(0,1,by=0.1) elasticnet <-…
RobertF
  • 4,380
  • 6
  • 29
  • 46
31
votes
1 answer

Feature selection & model with glmnet on Methylation data (p>>N)

I would like to use GLM and Elastic Net to select those relevant features + build a linear regression model (i.e., both prediction and understanding, so it would be better to be left with relatively few parameters). The output is continuous. It's…
PGreen
  • 565
  • 1
  • 6
  • 11
29
votes
2 answers

Why is glmnet ridge regression giving me a different answer than manual calculation?

I'm using glmnet to calculate ridge regression estimates. I got some results that made me suspicious in that glmnet is really doing what I think it does. To check this I wrote a simple R script where I compare the result of ridge regression done by…
John
  • 291
  • 3
  • 3
24
votes
2 answers

Does caret train function for glmnet cross-validate for both alpha and lambda?

Does the R caret package cross-validate over both alpha and lambda for the glmnet model? Running this code, eGrid <- expand.grid(.alpha = (1:10) * 0.1, .lambda = (1:10) * 0.1) Control <- trainControl(method =…
mrquestion
  • 273
  • 1
  • 2
  • 7
23
votes
1 answer

Caret and coefficients (glmnet)

I am interested in utilizing caret for making inferences on a particular data set. Is it possible to do the following: produce coefficients of a glmnet model I trained in caret. I would like to use glmnet because of the inherent feature selection…
user2300643
  • 741
  • 2
  • 5
  • 13
22
votes
1 answer

What to conclude from this lasso plot (glmnet)

Following is the plot of glmnet with default alpha(1, hence lasso) using mtcars data set in R with mpg as the DV and others as the predictor variables. glmnet(as.matrix(mtcars[-1]), mtcars[,1]) What can we conclude from this plot regarding…
rnso
  • 8,893
  • 14
  • 50
  • 94
20
votes
5 answers

Variablity in cv.glmnet results

I am using cv.glmnet to find predictors. The setup I use is as…
user4673
  • 1,461
  • 4
  • 17
  • 26
20
votes
2 answers

Variable importance from GLMNET

I am looking at using the lasso as a method for selecting features and fitting a predictive model with a binary target. Below is some code I was playing with to try out the method with regularized logistic regression. My question is I get a group…
B_Miner
  • 7,560
  • 20
  • 81
  • 144
1
2 3
28 29