Questions tagged [glmnet]

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

Filter by
Sorted by
Tagged with
1 vote
1 answer
24 views

Using glmnet engine in tidymodels to fit models with percent data as response

I am interested in using penalized regression (LASSO) with the glmnet engine in tidymodels to fit a model with a response ...
Bryant's user avatar
  • 11
0 votes
0 answers
29 views

Can LASSO still perform regularization on summarized data?

Currently, we are trying to predict future revenue from existing users. We use the revenue collected after 14 days of membership to predict 3 year membership. We train the model and make predictions ...
Demetri Pananos's user avatar
0 votes
0 answers
32 views

Is Pearson's chi-squared appropriate for models with low deviance explained?

I'm working on fitting a binomial GLM using LASSO in R (package glmnet). My response variable is a proportion which is generated using count data (successes and failures). The main purpose of my model ...
pfadenhw's user avatar
0 votes
0 answers
18 views

How to estimate the probability of a binary event using lags of independent variables [closed]

My apologies if this is a trivial question. I need some help to estimate the probability of bankruptcy, using the lags of several explanatory variables. I want to use historical data and estimate the ...
user27808's user avatar
0 votes
0 answers
55 views

Estimating the probability of an event using the logistic function in R

I need some help to estimate the probability of bankruptcy, using the lags of several explanatory variables. I want to use historical data and estimate the parameters using a logit/probit model, and ...
user27808's user avatar
3 votes
1 answer
94 views

Inference for high dimensional models based on running a (G)LM on the union of selected variables across best subset fits on bootstrapped datasets

I am in the process of developing an R package for best subset selection, which approximates the best subset using an iterative adaptive ridge regression procedure (with the weighted least squares ...
Tom Wenseleers's user avatar
1 vote
1 answer
41 views

Tuning lambda in glmnet mgaussian multitask learning model for optimal support recovery

I was using a multivariate gaussian (mgaussian) glmnet model to solve the multitask learning problem below (deconvolution of a ...
Tom Wenseleers's user avatar
1 vote
1 answer
39 views

Bootstrapped Prediction Interval for Adaptive Lasso

I am attempting to calculate a 95% prediction interval from an adaptive lasso model using the glmnet:: package in R. I adapted my method from the Python code in ...
Sean McKenzie's user avatar
0 votes
0 answers
32 views

dev.ratio in glmnet

After running glmnet I can get a pseudo R-squared with glmnet.fit$dev.ratio. Does this take into account the complexity of the ...
locus's user avatar
  • 1,181
1 vote
1 answer
106 views

Different sets of features selected by three different functions in R for running LASSO Regressions despite the same random seed for each

The GitHub Repository for this research project has all of the code included in this question. Brief background context: I am just finishing up the work on my part as a coauthor on a research project ...
Marlen's user avatar
  • 145
0 votes
0 answers
56 views

Relaxed Adaptive Lasso

I recently came across this study describing the benefits of the author's relaxed adaptive LASSO regression. The author describes a simple algorithm (which appears to be glmnet, effectively), as well ...
Nate's user avatar
  • 11
0 votes
0 answers
21 views

How is the intercept fit in glmnet when doing logistic regression?

In this question, it's explained how the intercept is fit under normal linear regression. It is given that it is calculated using $$\beta_0 = \bar{y} - \sum_{j=1}^p \hat{\beta}_j \bar{x}_j$$ How is ...
user19904's user avatar
  • 105
1 vote
1 answer
151 views

Getting glmnet to select excatly given number of features?

I am using glmnet for feature selection, given a gaussian dependent variable. Part of my code is like this: ...
user7831861's user avatar
0 votes
1 answer
50 views

How `glmnet` re-scales `penalty.factor` with `Inf` values

I know how glmnet re-scales the penalty.factor with a sum nvar as discussed in this post. $$ ...
HCR's user avatar
  • 78
0 votes
1 answer
45 views

cva.glmnet() lambda value does not give correct number of non-zero predictors in glmnet()

I have an issue with specifying the lambda value based on cva.glmnet(). The lowest "binomial deviance" was attained in my data with ...
Scott Hebert's user avatar
1 vote
1 answer
92 views

glmnet Ridge Regression Plot makes no sense (to me at least)

I have a data set with around 50 variables and I am applying ridge and lasso on this data set. What I´ve noticed is, that the plot for the lambda values does differ from the mean values I get when ...
Jayme Derril's user avatar
0 votes
0 answers
99 views

Variable selection in logistic model for complex survey data in R

The dataset I use comes from a one stage proportional stratified design and consists entirely of categorical variables. In order to perform survey sample analyses, I first specify the design using the ...
Louis De Montalte's user avatar
0 votes
1 answer
54 views

Multinomial logit: why likelihood for one observation uses probabilities of all classes?

When dealing with non-binary discrete-choice outcomes, one common way of modeling such problems as a function of some covariates is through a multinomial logit/logistic model, in which there is one ...
anymous.asker's user avatar
0 votes
0 answers
126 views

LASSO regression for categorical variables

Suppose there are several categorical variables included in the LASSO regression. For a categorical variable with more than two factors, it is mandatory to create a dummy table. For example, the ...
Joshua Henrina's user avatar
1 vote
1 answer
265 views

Massive difference between R's glmnet and Python's sklearn regarding Lasso regression

I have a burning question. First, in Python: ...
user2961927's user avatar
0 votes
0 answers
160 views

Using natural spline in glmnet

I want to ask if it is possible to include a natural spline(as one predictor) in the lasso model. When I do that in glm model, I can use ns() function on the ...
brushington's user avatar
1 vote
0 answers
140 views

Logistic LASSO with observation weights in HDM in R

I'm trying to run a logistic LASSO regression using the HDM package in R (hdm::rlassologit), but because my dataset is very ...
John Kazowski's user avatar
1 vote
0 answers
154 views

how to bring in splines (bs()) into lasso logistic regression (cv.glmnet)

Assume I have train dataset below, I avoided using model.matrix() and instead I used dummyVars() because I want dummy variables ...
Mathica's user avatar
  • 121
5 votes
1 answer
728 views

How to implement Adaptive Lasso penalty for a Logistic regression in Python?

I want to use an Adaptive Lasso instead of a standard Lasso because of the Oracle properties of the former. However, I cannot seem to find an option to implement an Adaptive Lasso for a logistic ...
Jim R.'s user avatar
  • 53
0 votes
0 answers
53 views

How to weight the observation in the glmnet package?

I have several imputed datasets, and I would like to run a single lasso regression on the stacked imputed datasets (as if it were 1 dataset) and weight each observation by the fraction of missing ...
Herbert's user avatar
1 vote
0 answers
34 views

Fitting an intercept with glmnet

I've been looking through this answer as to the behaviour of glmnet with an intercept. I've found other penalised packages do something similar, where the intercept is calculated at the end (after ...
Tom's user avatar
  • 75
3 votes
2 answers
705 views

cv.glmnet vs glmnet

I'm using glmnet to fit a ridge regression model on some data and evaluate the model's test MSE. The lambda value I select is derived from cross-validation. I'm ...
C C's user avatar
  • 53
0 votes
0 answers
96 views

Changing Reference Levels of Categorical Variables Changes Confusion Matrix & Prediction Probabilities

I am trying to understand why changing the reference level of a factor changes the results of a model. Consider this example: ...
mapleleaf's user avatar
  • 265
1 vote
0 answers
28 views

Formula versus Non-Formula Interface Categorical Variables train() glmnet

I am comparing the confusion matrix between the formula interface and the non-formula interface using caret's train() for elastic net. I am trying to understand why the two interfaces produces ...
mapleleaf's user avatar
  • 265
-1 votes
1 answer
57 views

What do you do when your GLM has a significant predictor, high AIC, and significant chi square value?

As stated in the title, I have a significant predictor (and 2 predictors in the other model) and a significant Chi-Square value but the AIC value is high. As I interpret these findings, the ...
pworts's user avatar
  • 19
2 votes
1 answer
275 views

Assessing violations of the Cox proportional hazards assumptions

Cox models assume proportionality. These assumptions can often be formally tested (an example in R is cox.zph from the ...
carbocation's user avatar
2 votes
0 answers
121 views

R: What is the difference of the Lasso for variable selection between the packages glmnet and hdm

For my PhD I use a Lasso approach in R for variable selection. Now, I used the package glmnet and also hdm. What is the difference of the basic lasso estimator for logistic regression in these two ...
Irazall's user avatar
  • 170
2 votes
1 answer
69 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 (...
Sally's user avatar
  • 21
1 vote
1 answer
863 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 ...
big tree's user avatar
4 votes
1 answer
342 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 ...
hela's user avatar
  • 43
0 votes
0 answers
162 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 <...
Thomas's user avatar
  • 468
1 vote
2 answers
605 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 ...
seeker_after_truth's user avatar
0 votes
1 answer
211 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 ...
Fabian's user avatar
  • 39
4 votes
0 answers
475 views

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

...
Adrian's user avatar
  • 2,699
2 votes
1 answer
631 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 ...
zeming's user avatar
  • 21
1 vote
1 answer
3k 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 ...
Parseval's user avatar
  • 361
0 votes
1 answer
160 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 ...
aloleary's user avatar
2 votes
1 answer
246 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. ...
Thomas's user avatar
  • 468
0 votes
1 answer
397 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 ...
Matt Frank's user avatar
1 vote
0 answers
225 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) ...
cno's user avatar
  • 111
0 votes
1 answer
1k 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 ...
Fedor Duzhin's user avatar
2 votes
0 answers
40 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 ...
Mark's user avatar
  • 335
0 votes
1 answer
643 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 ...
KLee's user avatar
  • 117
1 vote
0 answers
50 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....
KLee's user avatar
  • 117
0 votes
2 answers
1k 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 ...
FrsLry's user avatar
  • 145

1
2 3 4 5
9