Questions tagged [glmnet]

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

Filter by
Sorted by
Tagged with
0
votes
1answer
22 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 ...
0
votes
0answers
30 views

Using adaptive LASSO penalty for a logistic regression

So I have this code for running adaptive LASSO in R ...
0
votes
0answers
13 views

Why does the value of the penalized ridge is divided by 2 in GLMNET? [duplicate]

If you look at GLMNET Vignette, it shows that it solves for the gaussian case: But why does it divide the value of $\parallel \beta \parallel_2^2$ by 2?
0
votes
0answers
9 views

Optimizing models for paired analysis

I want to train a model to classify pre and post samples for 50 patients. The algorithm needs to discriminate ...
1
vote
0answers
22 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 ...
0
votes
0answers
9 views

`glmnet()` variable importance interpretation using `varImp()` and `vi_model()`

I fitted a Lasso Logistic Regression model using glmnet ...
0
votes
1answer
30 views

Why (not) having an intercept term can change the sign of some coefficient in glmnet

Sorry my dataset is pretty big so that I can not post it here. I have a simple glmnet model in R coef(glmnet(Y ~ A + B+ C, data = test_data, family = "binomial", intercept = F), s=0) shows ...
0
votes
0answers
8 views

Different results after updating the code (glmnet function) [duplicate]

I wrote a code performing an elastic net regression with a 10-fold-crossvalidation. the original dataset has 190 variables and 1402 observations. The result were 70 remaining coefficients in the final ...
1
vote
0answers
21 views

How does glmnet put constraints on coefficient upper and lower bounds?

Based on glmnet documentation at https://web.stanford.edu/~hastie/glmnet/glmnet_alpha.html Coefficient upper and lower bounds These are recently added features that enhance the scope of the models. ...
0
votes
0answers
22 views

Feature selection for optimising LOOCV AUC

at the moment I am dealing with the following problem: I have a binary classification problem with low sample size (12 and 36 instances in the two classes) and large number of features (200). My ...
4
votes
1answer
74 views

Ridge coefficient estimates do not match OLS estimates when $\lambda$ = 0

I'm trying to understand why ridge regression coefficient estimates (through the glmnet package in R) do not match the ordinary least squares (OLS) estimates in the ...
0
votes
1answer
138 views

How do I compare cv.glmnet models with AIC?

I am using the glmnet package in R, and not(!) the caret package for my binary ElasticNet regression. I have come to the point ...
0
votes
0answers
18 views

ElasticNet coefficients are different for each cv.glmnet run

I am new to R and cv.glmnet. I have now tried to run my logistic model with ElasticNet instead of stepwise as people in this community suggest. But, I have troubles ...
1
vote
1answer
156 views

How do I calculate confidence intervals on an elastic net regression in R

I am performing an elastic net regression on my data n = 34, p = 46 I first built the model using the "caret" package with the cross validation method to set the optimal alpha and lambda ...
0
votes
1answer
68 views

the meaning and metrics of beta coefficients in glmnet Ridge regression

I have done a ridge regression using the 'glmnet' function in R. Then, after finding the optimal lambda parameter, I checked what are the predictors' beta coefficients by extracting glmnet.fit$beta ...
2
votes
0answers
93 views

Elastic net: how to tune for both lambda and alpha? Why is caret better than cv.glmnet?

I'm learning how to use R to fit Elastic Net models using the glmnet package. There appears to be a function, cv.glmnet that ...
0
votes
0answers
42 views

Issues calculating confidence intervals from glmnet using selectiveInference

I'm trying to use glmnet to run a LASSO fit on a large dataset (n >> p). I want to use the results for inference, so I would like to calculate the confidence ...
3
votes
2answers
340 views

How can a glmnet model with no coefficients have perfect performance?

I sometimes run into situations where glmnet appears to be performing well but actually selects zero features. The AUC is near-perfect but the ...
1
vote
1answer
56 views

Why is glmnet giving non-decreasing objective function values for the lasso?

Summary When I run glmnet on the same LASSO problem by successively decreasing the convergence tolerance (threshold), I have observed that in some cases, the objective function values increase as the ...
0
votes
1answer
64 views

How to determine significant predictors from a multi-variate lasso model?

How can I determine significant predictors from a multi-variate lasso model specifically using glmnet package? The dataset has 11 variables in the output space and 300 variables in the input space. ...
1
vote
1answer
31 views

What does the term “gaussian models” mean?

In the R documentation for the cv.glmnet function, type.measure parameter is described as: loss to use for cross-validation. ...
0
votes
0answers
43 views

Adding natural cubic splines to glmnet.cv predictors and response matrices

I'm performing analysis in R using glmnet.cv. My main goal is to select the optimal set of predictors. I would like to check some of the predictors both in the "pure" form and in the form of natural ...
2
votes
1answer
181 views

Logistic Regression Loss Function: Scikit Learn vs Glmnet

The loss function in sklearn is $$\min_{w,c}{\frac{1}{2}w^Tw+C\sum_{i=1}^N{\log(\exp(-y_i(X_i^Tw+c))+1)}}$$ Whereas the loss function in glmnet is $$\min_{\beta,\beta_0}{-\bigg[\frac{1}{N} \sum_{i=...
0
votes
0answers
107 views

Penalty Factor in Glmnet and the Adaptive Lasso

I'm currently looking at Lasso vs. adaptive Lasso and see that there are different recommendations for the implementation of the adaptive lasso. I have been using the ...
0
votes
1answer
24 views

Difference Between Built-In Cross Validation Functions and Using Caret

I was wondering if someone could provide some insight on the pros/cons of using built-in cross validation functions like cv.glmnet (https://www.rdocumentation.org/packages/glmnet/versions/3.0-2/topics/...
0
votes
0answers
12 views

How can I determine which variable to remove in a GLM with small sample size so that the model runs?

I'm trying to see the isolated and combined effects of precipitation and three different human disturbances indexes are having an effect on the growth of a cactus. I have a gradient of eight different ...
2
votes
0answers
43 views

Weird glmnet ridge regression results with an uncentered design matrix

I was recently trying to figure out what glmnet's ridge regression is doing (7,000 lines of Fortran are no fun) and am confused by its behavior with an uncentered design matrix $X$. I am aware that ...
2
votes
1answer
235 views

Understanding Partial Likelihood Deviance vs lambda relationship in LASSO

I'm analyzing gene expression data using regularized linear regression models (lasso-elastic net-...
2
votes
0answers
37 views

Using LASSO for Only Variable Selection [duplicate]

How valid is an approach of using LASSO to determine appropriate values to then use in a logistic regression that does not use any penalties?
0
votes
0answers
24 views

How do we calculate the predicted survival values in a Lasso model for cross-validated calibration plot?

I want to draw a cross-validated calibration plot for a set of variables selected by a survival Lasso model. I am not sure of the process I should follow. Below is my intuitive way to do it but I am ...
1
vote
1answer
58 views

What leads to discontinuities in the deviance plot from plot.cv.glmnet?

I'm running L1-penalized logistic regression with cv.glmnet. When plotting the mean binomial deviance against a range of Log(λ) using ...
0
votes
1answer
268 views

How to get odds ratio using glmnet?

I ran three regularization methods, lasso, ridge, and elastic net. Lasso was able to get the best accuracy, so I'm selecting it. Is there a way to calculate odds ratio from the coefficients? Does it ...
0
votes
0answers
11 views

Understanding single outlier in model predictions of penalized regression model

I'd like to discuss the following prediction scenario of a fitted penalized (L2) regression model. (The data is hosted statically on Zenodo and interactively downloaded to your temporary R directory -...
0
votes
0answers
26 views

Prediction interval for Poisson Elasticnet GLM

Is it possible to derive prediction intervals for a penalized Poisson generalized linear model ? I am interested in predicting future death rates of a given population. I use the standard Poisson ...
3
votes
0answers
276 views

Why would one want to choose lambda.1se for ridge regression in glmnet?

In R, choosing lambda.1se over lambda.min to get a more parsimonious model is common. This post (and this) also indicated that ...
1
vote
0answers
47 views

BIC-Lasso Shrinkage

I am currently reviewing the below paper and was wondering if it was possible to correctly implement the BIC equation for "BIC-LASSO Shrinkage". This doesn't appear to be the same as the typical BIC ...
1
vote
2answers
359 views

glmnet foldid for time series data

I'm currently working with cv.glmnet and it is my understanding that you should not use normal cross validation for time series data. Is it possible to use the foldid argument with cv.glmnet in order ...
2
votes
1answer
328 views

One standard error rule in repeated K fold?

I’m confused by using one standard error rule in repeated k fold scenario. In k fold cross validation, the standard error is of the error metrics is calculated as: ...
0
votes
0answers
66 views

cv.glmnet with Time Series Data

I'm not sure if this has been asked but I can't seem to find anything regarding the question. Is it possible to use cv.glmnet for time series data? I currently have a blocked time series data frame ...
0
votes
0answers
98 views

Variable selection for Autoregressive Distributed Lag model

I want to create an ADL model on a basis of data set with 20 original variables with 4 different lags for each one of them. Moreover, I'm interested in some interaction effects between predictors. I ...
3
votes
2answers
175 views

glmnet for binary outcomes: Why is “%Dev” inversely correlated with lambda?

I am new to glmnet but would like to apply it to a dataset with binary outcomes. Can you please clarify a few questions for me? Below are the codes and data setup <...
1
vote
1answer
52 views

How should I consider the signs of the beta weights in a composite?

I have some biomarkers ($X_1, \ldots, X_5$) and I want to model an outcome ($Y$) using these biomarkers. The biomarkers are correlated. So I decided to use a ridge regression to stabilize the ...
1
vote
0answers
43 views

Logistic regression in R - understanding function outputs

I'm looking to gain more understanding on how to properly perform logistic regression using R. I have a matrix x with 20 features (columns) and 1000 samples (rows) and a response vector y with values ...
4
votes
0answers
68 views

Different coefficient estimates from ncvreg and glmnet in logistic regression

I'm trying to compare the results from glmnet and ncvreg in logistic regression. The methods have similar coefficients estimates ...
1
vote
1answer
59 views

Meaning of “deviance” when using glmnet and family = “binomial”

When using glmnet in R with family = "binomial" you can set type.measure = "class" or ...
4
votes
0answers
220 views

Results of cv.glmnet in R versus RidgeCV in scikit-learn

I'm having trouble reconciling different values for the ridge parameter that minimizes mean squared error when using RidgeCV in scikit-learn (Python) and cv.glmnet (R). First a few things to note: ...
1
vote
0answers
32 views

glmnet mgaussian lambda in r [closed]

I have built a multi-response regression model using glmnet package in r. I find there are two ways to extract lambda used in the training process. ...
1
vote
0answers
15 views

Glmnet R - can't modify fdev parameter when lower = 0 [closed]

I want to solve the following optimisation problem $\hat{\beta} = \arg \min_{\beta \geq 0} \| y- A\beta\|_2^2 + \lambda \|\beta\|_1$ For that, I am using glmnet package (cv.glmnet for finding $\...
2
votes
2answers
270 views

Combining results of multiple Lasso runs / Variable selection

I would appreciate your opinion on an analysis approach I have in mind. The idea is to do the variable selection with multiple runs of Lasso regression (by glmnet in R). Basically, the workflow would ...
3
votes
1answer
69 views

Why glmnet 's $\lambda$ value is so small? Does it strictly implement the loss function under the hood?

I am running a glmnet fit with 1200000 samples. According to the glmnet doc, $\lambda$ value is the coefficient controlling how much the regularization term contributes to the total loss function. ...

1
2 3 4 5
8