Questions tagged [glmnet]

glmnet is an R package for Lasso and elastic-net regularized generalized linear models.

Overview

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

Tag usage

Questions on should be about implementation and programming problems, not about the statistical or theoretical properties of the technique.
Consider whether your question might be better suited to Cross Validated, the Stack Exchange site for statistics, machine learning and data analysis.

598 questions
0
votes
2 answers

Extract data from glmnet output data

I am trying to do feature selection using the glmnet package. I have been about to run the glmnet. However, I have a tough time understanding the output. My goal is to get the list of genes and their respective coefficients so I can rank the list…
Son nguyen
  • 29
  • 4
0
votes
1 answer

Using glmnet to predict a continuous variable in a dataset

I have this data set. wbh I wanted to use the R package glmnet to determine which predictors would be useful in predicting fertility. However, I have been unable to do so, most likely due to not having a full understanding of the package. The…
Srikar Murali
  • 135
  • 2
  • 15
0
votes
1 answer

How can I get the coefficients of a glmnet model into a dataframe?

I've trained a glmnet model with caret pen.params = expand.grid(lambda = exp(seq(-3,3,0.05)) , alpha = 1 ) model.penalized = train(y~., data = d.train, trControl = fitControl, …
Demetri Pananos
  • 6,770
  • 9
  • 42
  • 73
0
votes
1 answer

What's the effect of "weights" argument in caret::glmnet() function?

I would like to found out what's happening if a customized weights list (not all equalling to 1 as default) is passed to glmnet(). I have looked into the glmnet package @github: glmnet but could not figure out what's going underneath. Is it the…
CcMango
  • 377
  • 1
  • 4
  • 15
0
votes
0 answers

Predict function in library(glmnet) in R

I am fitting a logistic regression for a binary classification problem. Now I would like to find the source code of predict function and see how "predict" works. > methods(predict) [1] predict.ar* predict.Arima* …
0
votes
1 answer

glmnet: Convert predicted probabilities to predicted classes

I ran cv.glmnet using a Poisson distribution for a binary outcome. The predict function returns predicted probabilities, but not predicted classes. How do I convert the probabilities into classes so I might generate a confusionMatrix to determine…
C_H
  • 191
  • 14
0
votes
0 answers

Automatic scaling of predictors in glmnet

In An Introduction to Statistical Learning, James and colleagues state "In contrast, the ridge regression coefficient estimates can change substantially when multiplying a given predictor by a constant. Therefore, it is best to apply ridge…
llewmills
  • 2,959
  • 3
  • 31
  • 58
0
votes
1 answer

cv.glmnet gives auc value greater than 1

I want to get the AUC on the testing set from cv.glmnet for the best set of hyperparameters. according to this post. I should run cvm and get it, however, when I do this i get a value greater than 1, and my understanding is that the AUC should be…
pd441
  • 2,644
  • 9
  • 30
  • 41
0
votes
2 answers

k-fold cross validation of glmnet group predictions

I have a set of predictors that are partially correlated and I would like to reduce them to a functional set and use the reduced model for prediction. I am able to find a good lambda to use by using the > require(glmnet); require(glmnetUtils) >…
Fredrik Karlsson
  • 485
  • 8
  • 21
0
votes
0 answers

What is the correct way to predict ROC for logistic regression with ridge?

I am trying to get AUC value from the logistic regression for 2 classes classification problem. Response of this data is factor of 1 (terrible) and 2 (great). The model is built as follow: fit.ridge = glmnet(xmat, as.numeric(train$response), alpha =…
designil
  • 763
  • 3
  • 9
  • 17
0
votes
1 answer

how to get probabilities between 0 and 1 using glmnet categorical regression

My response variable is categorical, from 1 to 7. I understand using glmnet I can set the type to response and get the probability of the prediction. prob.vec = predict.cv.glmnet(cvfit, newx = X.test, s = "lambda.min", type =…
Areza
  • 5,623
  • 7
  • 48
  • 79
0
votes
0 answers

Using cv.glmnet on a very large data-set

I use the cv.glmnet() function to estimate a penalized multinomial logit model. Since the datset is far too large to make things reproducable, I show the call of the function: cvfit = cv.glmnet(x= X, y=as.numeric(dat$choice_t) , …
Jogi
  • 304
  • 4
  • 15
0
votes
1 answer

Penalized GLM using the glmet - package

Since I have a lot of explanatory variables, I want to perform a penalized estimation of a multinomial logit model. Using the glmnet package, I would proceede as follows: library(glmnet) data(MultinomialExample) cvfit=cv.glmnet(x, y,…
Jogi
  • 304
  • 4
  • 15
0
votes
2 answers

Using glmnet on binomial data error

I imported some data as follows surv <- read.table("http://www.stat.ufl.edu/~aa/glm/data/Student_survey.dat",header = T) x <- as.matrix(select(surv,-ab)) y <- as.matrix(select(surv,ab)) glmnet::cv.glmnet(x,y,alpha=1,,family="binomial",type.measure =…
Alex
  • 2,603
  • 4
  • 40
  • 73
0
votes
1 answer

glmnet.ElastiNet:lambda_path argument

I am learning from: https://github.com/JWarmenhoven/ISLR-python/blob/master/Notebooks/Chapter%206.ipynb and have issues with following code: grid = 10**np.linspace(10,-2,100) ridge3 = gln.ElasticNet(alpha=0, lambda_path=grid) ridge3.fit(X, y) What…
econ
  • 495
  • 3
  • 6
  • 16