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
0 answers

How to regularize the intercept with glmnet

I know that glmnet does not regularize the intercept by default, but I would like to do it anyway. I was taking a look at this question and tried to do what whuber suggested (adding a constant variable and turning the parameter intercept to FALSE) ,…
gsmafra
  • 2,434
  • 18
  • 26
0
votes
2 answers

trying to use exact=TRUE feature in R glmnet

I am trying to use exact=TRUE feature in glmnet. But I am getting an error message. > fit = glmnet(as.matrix(((x_values))), (as.matrix(y_values)),penalty=variable.list$penalty) > coef.exact = coef(fit, s = 0.03, exact = TRUE) Error: used…
itthrill
  • 1,241
  • 2
  • 17
  • 36
0
votes
3 answers

install glmnet in python

Is it possible to install glmnet in python 2 or 3 (windows machine): Using this: conda install glmnet produces this error: packages not found error: ... not available from current channels Does anyone experience similar problems? edit: Using pip…
Niccola Tartaglia
  • 1,537
  • 2
  • 26
  • 40
0
votes
1 answer

How to predict using only weights obtained from glmnet in R?

One can make predictions using predict(fit,newx) method. But how to predict if I don't have the fit object itself but only the weights of the predictors as vector file and new observations for predictors as a matrix file? The predictors and the…
Veera
  • 861
  • 1
  • 9
  • 18
0
votes
1 answer

Elastic Net Regression (Prostate Data)

In the original Elastic net paper, Zou and Hastie, (2005) examined prostate cancer data for comparison purposes. I would like to regenerate the results using glmnet package in R. As mentioned in the paper, the response is lpsa. The training and test…
mert
  • 371
  • 2
  • 9
0
votes
1 answer

glmnet, multinomial prediction returned object

I am attempting to do classification prediction using glmnet, however I cannot deduce what the return object of "glmnet.predict" is supposed to represent. Using the code mlogit_r<-glmnet(train_x, cbind(cns_label,…
user3707850
  • 73
  • 3
  • 8
0
votes
1 answer

Using glmnet for descriptive statistics, what value of lambda to take

I am working on a descriptive (NOT predictive) analysis whereby I wish to compare the magnitudes of the coefficients from a logistic regression type problem - including the intercept. As each variable needs to be described, I have tried standard glm…
Jon
  • 445
  • 3
  • 15
0
votes
1 answer

r: coefficients from glmnet and caret are different for the same lambda

I've read a few Q&As about this, but am still not sure I understand, why the coefficients from glmnet and caret models based on the same sample and the same hyper-parameters are slightly different. Would greatly appreciate an explanation! I am using…
user3245256
  • 1,842
  • 4
  • 24
  • 51
0
votes
0 answers

Classification tree from a binomial glmnet model?

I very much like the simplicity of classification trees for presentations and posters, as they are more aligned with the clinical decision making and therefore provides a familiar way for the reader to digest the fit of a binomial model. However, in…
Fredrik Karlsson
  • 485
  • 8
  • 21
0
votes
0 answers

Gradient Descent Ridge Regression Vs GLMNET package

Why are the parameters estimated using Gradient Descent for Ridge Regression Cost function not matching with the ones returned by the standard GLMNET package. I have implemented a function which estimates the parameters for Ridge Linear regression…
0
votes
0 answers

glmnet odds ratio very low or to infinity

I am implementing logistic regression to create a bankruptcy prediction model in R. My data consists of financial ratios of many companies which I classified as "bad" having the value 0 and "good" having the value 1. However, some of the predictor…
WvO
  • 1
  • 1
0
votes
1 answer

Resampling based performance measure in caret

I perform a penalized logistic regression and I train a model with caret (glmnet). model_fit <- train(Data[,-1], Data[,1], method = "glmnet", family="binomial", metric = "ROC", …
FrancescoVe
  • 1,060
  • 1
  • 7
  • 12
0
votes
1 answer

LASSO analysis (glmnet package). Can I loop the analysis and the results extraction?

I'm using the package glmnet, I need to run several LASSO analysis for the calibration of a large number of variables (%reflectance for each wavelength throughout the spectrum) against one dependent variable. I have a couple of doubts on the…
0
votes
1 answer

R Caret: NA Errors when there is no missing value

I am attempting to run a classification algorithm for a dataset with no missing values. Here is the dataset description: 'data.frame': 59977 obs. of 6 variables: $ gender : Factor w/ 2 levels "F","M": 2 2 2 2 2 2 1 1 2 2 ... $ age …
John Doe
  • 55
  • 8
0
votes
2 answers

Coerce model coefficients to clean, 2-column dataframe

I am fitting an elastic net with cross-validation and I am looking at how big the coefficients are for each predictor: lambda <- cv.glmnet(x = features_training, y = outcomes_training, alpha = 0) elnet <- lambda$glmnet.fit coefs <- coef(elnet, s =…
Ben
  • 429
  • 4
  • 11