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
1 answer

Issues with getting data formatted correctly for R's glmnet

I'm trying to fit a poisson model using glmnet, but I can't seem to get the data in the right form right. All the variables are categorical. The is an earlier question dealing with pretty much the same problem, but the solutions given didn't help…
JenSCDC
  • 101
  • 3
0
votes
0 answers

Logistic regression with cross validation cv.glmnet() not giving me auc values?

I have just started working with the glmnet package in R. I have s a dataset which has about 130,000 features and about 32000 rows of data. Here is the code to create the model myModel = cv.glmnet(data.matrix(modelData), modelData$ACTION, …
Abhi
  • 399
  • 2
  • 7
  • 21
0
votes
0 answers

error in all false (r0) object 'r_all0' not found

I am getting the below error while trying cv.glmnet from glmnet package in R. Error in all false (r0) object 'r_all0' not found Code below {wrap.glmnet.mdl.cv <- cv.glmnet(red.trn.x, red.trn.y, family="binomial")} I am not able to figure out…
maverick
  • 1
  • 3
0
votes
1 answer

Lasso in R package glmnet: solution not optimal?

I am just trying to understand the lasso implemented in R package glmnet. I am fitting the data but the solution I get for a lambda of my choice is not minimising the criteria of the lasso, for instance if I move the solution in one way I can get a…
0
votes
1 answer

Caret: Error in switch(tolower(trControl$method), oob = NULL, alt_cv = , cv = createFolds(y,

I'm using caret package to tune alpha and lambda parameters for glmnet model. My features are in X (dataframe, 47 obs. of 14474 variables, a p>>N problem) and the dependent variable, y is a dataframe of 47 obs. of 1 variable. When I try trC =…
PGreen
  • 3,239
  • 3
  • 24
  • 29
-1
votes
1 answer

Recall is always 1 when using Lasso regardless of lambda value in R

I am trying to get the prediction accuracy, precision and recall when running Lasso logistic model but it turns out that no matter what lambda I set, the recall is always 1 (even when I set lambda = 0) Below is my code. Here I'm using Smartket…
-1
votes
1 answer

What is the 's' argument for in predict.glm() function?

I'm having trouble parsing the help files for the predict() function when using a glmnet()-defined model. I don't see mention of an 's' argument anywhere. However, in the example code below, it appears to be a way to feed a regularization…
TheProletariat
  • 916
  • 2
  • 11
  • 23
-1
votes
1 answer

How to extract multiple levels of coefficients into data frame in R?

I extracted the coefficients from my glmnet model with code: best_lambda_fit_coef <- coef(best_lambda_fit) I got a list of coefficients that are in dgCMatrix, but I'm not sure how to make it a data frame. I looked the answer from Mehrad in …
cheklapkok
  • 439
  • 1
  • 5
  • 11
-1
votes
1 answer

"Argument Y Missing" when trying to implement Lasso in R?

Trying to perform feature selection in R. I am using the glmnet package to do this. Here is my code so far: lasso_model = glmnet(as.matrix(x = lasso, y = lasso_target, standardize=TRUE, alpha=1)) lasso is a dataframe full of numeric and categoric…
rmahesh
  • 739
  • 2
  • 14
  • 30
-1
votes
1 answer

glmnet error when running a documentation example

I am currently running an example in the glmnet documentation (https://cran.r-project.org/web/packages/glmnet/glmnet.pdf page 3): > x=matrix(rnorm(100*20),100,20) > y=rnorm(100) > fit1=glmnet(x,y) > plot(fit1,xvar="lambda") However, I get this…
John McClain
  • 51
  • 1
  • 2
-1
votes
1 answer

Elastic net with Cox regression

I am trying to perform elastic net with cox regression on 120 samples with ~100k features. I tried R with the glmnet package but R is not supporting big matrices (it seems R is not designed for 64 bit). Furthermore, the package glmnet does support…
user985611
  • 139
  • 8
-2
votes
1 answer

Large Matrix to run in cv.glmnet() for multinomial classification

I am working on a large matrix with number of samples N=40 and features, P=7130. I am trying to fit the cv.glmnet() for the ridge but i am getting error while doing this. The dimensions of the dataset is (40,7130) The code for the cv.glmnet() is as…
botloggy
  • 383
  • 2
  • 15
-5
votes
1 answer

Lambda Issue, or cross validation

I am doing double cross validation with LASSO of glmnet package, however when I plot the results I am getting lambda of 0 - 150000 which is unrealistic in my case, not sure what is wrong I am doing, can someone point me in the right direction.…
1 2 3
39
40