Questions tagged [glmnet]

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

Filter by
Sorted by
Tagged with
2 votes
1 answer
32 views

Regression in data with one group, having just zeros as outcome

I have a data set, consisting of positive and negative patients (virus infection). If the patient is negative, it has 0 as outcome (y), if it is positive it has a positive value, up to 100. The input (...
user avatar
  • 21
0 votes
1 answer
34 views

Confused about prediction output for glmnet package cv.glmnet model

I am using the glmnet package to perform logistic regression on a dataset. The x.train and x.test data is a simple dataset of numbers. y.train and y.test is data with categories "Coffee" and ...
user avatar
4 votes
1 answer
150 views

Adaptive LASSO, confidence interval and sample size

I have almost no experience with math or stat, but I am trying to run an Adaptive LASSO on a continuous outcome with around 200 cases and a list of around 19 variables. Some of these variables have 3 ...
user avatar
  • 43
0 votes
0 answers
67 views

How is type.measure="class" defined for cv.glmnet when using family = "multinomial"

cv.glmnet allows you to run cross validation for a multinomial logistic model to determine the value of lambda to use for LASSO. There are different ways that the ...
user avatar
0 votes
0 answers
48 views

Why does changes in nfolds change the model output of cv.glmnet?

I have a large dataset consisting of snow (1) vs no snow (0) in pixels over a whole year, N = 501,126. I want to compare the two groups and predict why snow melts at a given time. So I decided to use <...
user avatar
  • 332
0 votes
1 answer
127 views

How to get glmnet to work for proportions as response variable

I am trying to run a penalized logistic regression in R. My response variables are proportions (they are winning percentages for a sports team), and I have the number of total games played by each ...
user avatar
0 votes
1 answer
42 views

Can one use NRI and IDI in regularized cox-regression?

I have a dataset with 1500 patients for which I want to predict the outcome of death. I wanted to utilize multivariate cox-regression in a model containing biomarkers and other covariates. I was told ...
user avatar
  • 37
3 votes
0 answers
103 views

Why does cv.glmnet give me different coefficient estimates even if I specify the same lambda?

...
user avatar
  • 321
0 votes
0 answers
76 views

GLM vs GLMNET which should be used for prediction?

I am a little confused on this one: what is the proper procedure for fitting a logistic regression model for prediction, after feature selection: a) fit a glmnet (ie employ penalized maximum ...
user avatar
  • 45
0 votes
0 answers
49 views

shrinkage and glmnet Convergence for nth lambda value

I am using LASSO from glmnet-package to create predictions. Furthermore, I am using cv.glmnet-function to do 5-fold cross-validation to create Lasso.fit. This glmnet-object is then used in predict-...
user avatar
  • 31
2 votes
1 answer
142 views

Convergence issue when fitting LASSO Cox using glmnet() in R

I am trying to compare traditional Cox model and LASSO Cox in data with a counting process structure (see below for the data). I fitted a LASSO Cox model with lambda = 0, which in theory should lead ...
user avatar
  • 21
0 votes
0 answers
81 views

How does caret measure Accuracy and Kappa?

I have trained a logistic elastic net regression using caret package and the method "glmnet", with trainControl set to repeated cross-validation. I don't know how to interpret the Accuracy ...
user avatar
0 votes
0 answers
9 views

How to interpret the variable importance varImp() when training a LASSO/Ridge regression using the library caret and method = "glmnet"?

I have trained an elastic net regularized model and left with my top two variables - both factors. • How can I interpret the importance of each one? • Should I train a new linear model including only ...
user avatar
1 vote
1 answer
554 views

Logistic LASSO regression model in R (glmnet) - predictions very close to 0.5 and bad misclassification error

EDIT: Earlier this question got closed because my question was not precise enough and really contained several questions. I have now tried to make the question more precise. I hope it's ok now. I ...
user avatar
  • 329
0 votes
0 answers
36 views

How does the GLMNET standardize = TRUE option work?

I am struggling to find information about how the standardize = TRUE option as part of the glmnet or cv.glmnet calls works. My understanding (although it might be wrong) is that when the ...
user avatar
  • 101
0 votes
0 answers
36 views

In Ridge/Lasso Regression, What's The Advantage To Using CV Lamda And Then Some Form Of Training/Testing

When running a lasso or ridge regression, cross-validation allows us to find an optimal (minimized lamda.) So - if we were using glmnet with a logistic response variable... ...
user avatar
0 votes
0 answers
12 views

No predictions due to variability in cv.glmnet

I am using elastic net regression with CV.glmnet to predict values for about 500 responses across 900 samples using responses and features in 200 samples. For some of the responses the CV.glmnet model ...
user avatar
  • 1
0 votes
1 answer
35 views

How do you calculate the loglikelihood of a poisson GLM fit with glmnet?

I have fit a poisson GLM to some data using glmnet in MATLAB. I would like to calculate the loglikelihood of the model given the data but am struggling to work out how to do that. I've seen similar ...
user avatar
1 vote
1 answer
53 views

Why does a subset of variables produce a higher AUC value than all variables in a logistic regression?

I have to predict when the soil dries out. The dependent variable is therefore binary (the soil is wet or dry). I have a lot of variables, and I have clustered them together into three main clusters. ...
user avatar
  • 332
0 votes
1 answer
97 views

How exactly does the glmnet in R determine the penalty in ridge regression?

in R, once I call https://www.rdocumentation.org/packages/glmnet/versions/4.1-2/topics/cv.glmnet with alpha = 0, I will magically get a set of coefficients from ridge regression, without having to ...
user avatar
0 votes
0 answers
82 views

lambda scaling in elastic net regression with glmnet vs sklearn

I am trying to get results to agree between glmnet and sklearn elastic net regression for a specific case where I can't normalise the response variable y. I know that for ridge regression (alpha = 0) ...
user avatar
  • 101
0 votes
0 answers
116 views

How does glmnet in caret choose the values of lambda and how does it compute coefficients of the model?

I have a question that I've been struggling with. My students are asking me, but I can't figure it out myself. When I train LASSO regression in R caret, I use the method "glmnet" and a grid ...
user avatar
0 votes
0 answers
13 views

hal9001 vs cv.glmnet different coefficients, lambda stars - how to synchronize? [duplicate]

I am working with hal9001, which calls cv.glmnet in the backend (if it is prompted to do so). I am getting slightly different results with the two approaches though. Ie, I would like the returned ...
user avatar
  • 5,176
0 votes
0 answers
33 views

Why does my Mean Squared Error suddenly become so large in cv.glmnets lasso regrssion?

I performed a Lasso Regression in order to do variable selection. All varaibles are standardized and all coefficients for lambda=0 lie between - 3.3 and +1. Still, when the lambda gets small enough, ...
user avatar
2 votes
0 answers
21 views

How/whether to tune Elastic Net parameters using concentration of risk?

Typically, I see alpha and lambda tuned in elastic net models to minimize cross-validated error. Yet, I have seen a handful of articles by one set of authors where they instead tuned parameters to ...
user avatar
  • 335
0 votes
1 answer
127 views

"standardize = " option in glmnet package

I have one question regarding the standardize option in a glmnet package. I understand that scaling or standardizing dataset is necessary for the regression analysis in order to make the coefficients ...
user avatar
0 votes
0 answers
16 views

What does nzero mean in glmnet multinomial output?

In binary or other continuous case, nzero means the number of non-zero coefficients at each lambda as well as df. But what does it mean in multinomial logistic ...
user avatar
1 vote
0 answers
23 views

Variables that best discriminate groups based on the glmnet package

I am trying to understand how to interpret the result from the glmnet package. What I ultimately want to find is a set of (influential or important) variables that best discriminates three groups (e.g....
user avatar
0 votes
2 answers
132 views

How to determine variable importance for feature selection with glmnet?

Sorry about this question because it has already been asked but I am really lost to find how to determine the variable importance in glmnet?? Variable importance here refer to, for instance, the ...
user avatar
  • 145
4 votes
1 answer
83 views

Suitability of the glmnet defaults (R)

Recently I came across the claim that one should never rely on the "default" lambda sequence from the glmnet package, and it's always best to supply your own one: ...
user avatar
1 vote
0 answers
39 views

Difference between glmnet and nnls for non-negative least squares in R

I'm trying to do some non-negative linear regressions in R, and I found in the blog here https://www.r-bloggers.com/2019/11/non-negative-least-squares/ that either the package ...
user avatar
  • 11
0 votes
1 answer
161 views

Naive-elastic net and elastic net variable selection comparison

The elastic net paper (here) introduced the naive-elastic net and elastic net. The coefficient estimates of naive-elastic net are obtained by solving the problem $$\hat\beta_{naive-enet}=\text{argmin}...
user avatar
  • 263
0 votes
0 answers
95 views

Why does area under curve not change from 0.5?

I have performed a ridge logistic regression with glmnet and now I look at the performance metric AUC. The script is: ...
user avatar
  • 332
1 vote
1 answer
124 views

Correct Interpretation of the glmnet Lambda Grid as a Hyperparameter

I am reviewing the glmnet lambda option and am seeing that the results can vary significantly in some circumstances. I'm ...
user avatar
  • 233
1 vote
0 answers
44 views

LASSO Regression not Improving with Shrinkage Increase

I am trying to reproduce a figure (3.7) from the ESL Book using the dataset for prostate cancer https://web.stanford.edu/~hastie/ElemStatLearn/datasets/prostate.data The figure essentially shows how ...
user avatar
  • 21
2 votes
1 answer
228 views

Different Results for glmnet when standardize = FALSE

I asked this question at stackoverflow, but at this point I'm not exactly sure where it belongs because it is a question related to the standardization process of ...
user avatar
  • 233
1 vote
2 answers
389 views

Including Fixed Effects in a LASSO/Elastic Net regression model (in R)

So this is a question has vaguely been asked before (see 1 and 2) but I have not been able to find a conclusive answer for anywhere. Essentially I have panel data for 300 US firms between 2012-2020 ...
user avatar
  • 11
1 vote
1 answer
51 views

How can `standardize=TRUE` and `intercept=FALSE` be available at the same time in the function `glmnet`?

glmnet is a widely-used R package for generalized linear regression. Among the arguments passed to the main function ...
user avatar
2 votes
1 answer
107 views

Is taking mean of `lambda.1se` from multiple runs of `cv.glmnet` a reasonable approach to dealing with the randomness of lambda?

So for cv.glmnet we get different values of lambda (lambda.min and lambda.1se) due to the randomness in how the data is split. Is it reasonable to repeat ...
user avatar
3 votes
1 answer
332 views

How is the standard error calculated for the `lambda.1se` output in the cv.glmnet function?

I understand that lambda.1se is the largest lambda that gives MSE within one standard error of the minimum MSE. But how is the standard error calculated exactly.
user avatar
0 votes
1 answer
73 views

All p-values rendered non-significant in Cox model after initializing coefficients from glmnet

I have a set of 200 genes that are split into numerical high and low, encoded as (1/2). I have set this variable this way for linearity of the model. Also, stratified by cancer and normal cases. I ...
user avatar
  • 192
0 votes
1 answer
354 views

On glmnet lasso cox model, when to use "deviance and when to use "c"?

I am trying to use glmnet lasso cox model to select the best variables for the model using coxph, like described here https://r.789695.n4.nabble.com/estimating-survival-times-with-glmnet-and-coxph-...
user avatar
  • 192
1 vote
0 answers
27 views

Different Lambdas and Coefficients between cv.glmnet and intercept = FALSE

I'm currently reviewing how to correctly implement glmnet and am having a hard time understanding why the results seem to be different between each method when <...
user avatar
  • 233
2 votes
3 answers
108 views

Why do the results of LASSO regression differ after removing uninformative variables in glmnet?

I am researching therapy response of melanoma patients based on a number of approximately 80 features with a very small sample size of 60 patients. To eliminate features that do not contribute to the ...
user avatar
  • 23
0 votes
0 answers
87 views

glmnet vs. lars for computing the lasso

I've seen this post as well as this one regarding the difference between the lars and glmnet solution paths for fitting the ...
user avatar
  • 233
2 votes
0 answers
140 views

Performing Bagging with the Lasso

I asked this question at StackOverflow but I think it might be better suited for here because I'm hoping to understand the general idea of bagging. I'm trying to implement bagging in ...
user avatar
  • 233
0 votes
0 answers
398 views

Elastic net regression: Should I tune for lambda at the same time as alpha with cv.glmnet?

I am looking for the best $\alpha$ (=ratio between L1 and L2 penalty) and $\lambda$ (=penalty strength) for my elastic net regression model, using the R package ...
user avatar
  • 1
0 votes
1 answer
63 views

Exact way of glmnet computing best lambda

I'm doing some research and want to get the best lambda with cross validation in python. For my dataset the R! package glmnet works pretty well, but I can not find out how it's implemented. There are ...
user avatar
1 vote
0 answers
495 views

Using adaptive LASSO penalty for a logistic regression

So I have this code for running adaptive LASSO in R ...
user avatar
1 vote
0 answers
31 views

Issues with logistic regression using `glmnet` package

I'm trying to use the glmnet package to build a logistic regression model, but I keep getting sensitivity and specificity of 1.000. My data contains two factor ...
user avatar
  • 11

1
2 3 4 5
9