Skip to main content

Questions tagged [glmnet]

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

Filter by
Sorted by
Tagged with
1 vote
0 answers
40 views

Knockoff R package removing ALL variables based on LASSO, Why?

I am simulating a data set from a linear regression model and selecting the variables using LASSO (glmnet). The selection works relatively well with ...
Jack's user avatar
  • 11
1 vote
0 answers
42 views

Lasso model by glmnet package in small sample size [closed]

I want to create a lasso model, but I can't have a test set because I have a small sample size. So, I want to use cross-validation to evaluate the model. I have seen that functions like ...
muhammad's user avatar
3 votes
0 answers
68 views

null model in glmnet

With lm models I can construct a null model like this: lm(y ~ 1, data=df) What would the equivalent be in ...
locus's user avatar
  • 1,643
2 votes
1 answer
87 views

Comparing glmnet models part 2

I'd like to compare performance between two models that use different sets of predictors. I'm trying to implement what Roland suggested I did in his answer: ...
locus's user avatar
  • 1,643
2 votes
1 answer
117 views

comparing glmnet models

The anova function doesn't allow comparison of glmnet models: ...
locus's user avatar
  • 1,643
0 votes
0 answers
49 views

How can you constrain the intercept of a glmnet model to be positive?

If I use the lower.limits = 0 argument, it doesn't apply to the intercept for some reason. I can't find any documentation as to why or how to do it. Any ideas? ...
PaulG's user avatar
  • 1,297
0 votes
0 answers
36 views

weird lasso prediction when using lambda 1se

I have performed a leave-one out cross-validated prediction using a lasso regression (with both lambda min and lambda 1se). My sample size is 52 and I have a bit more than 20 predictors. While lambda ...
Simon's user avatar
  • 1
0 votes
0 answers
61 views

Generalized linear mixed effect model for negatively skewed outcome with negative values

I have a continuous outcome that is negatively skewed and includes negative, positive, and zero values. There are multiple measurements per subject, and the assumptions of a linear mixed-effects model ...
anb16's user avatar
  • 1
2 votes
2 answers
1k views

Too good to be true? Ridge prediction

I have a small data set of 18 persons. I have an outcome variable Y, and 200 predictors. These predictors were chosen based on biology and prior data. I used the caret R package and split the data set ...
user2862862's user avatar
1 vote
1 answer
176 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
35 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
41 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
19 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
65 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
115 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
91 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
119 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
1 vote
1 answer
119 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
  • 147
1 vote
0 answers
150 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
  • 21
1 vote
1 answer
408 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
1 vote
1 answer
154 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. $$ ...
Han Chen's user avatar
  • 123
0 votes
1 answer
65 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
194 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
1 vote
1 answer
83 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
217 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
2 votes
1 answer
574 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
384 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
174 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
2 votes
0 answers
269 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
  • 131
5 votes
1 answer
1k 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
3 votes
2 answers
1k 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
141 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
  • 275
1 vote
0 answers
38 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
  • 275
-1 votes
1 answer
88 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
506 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
156 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
109 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
1k 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
453 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
267 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
  • 528
1 vote
2 answers
841 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
1 vote
1 answer
335 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
  • 61
4 votes
0 answers
641 views

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

...
Adrian's user avatar
  • 2,919
2 votes
1 answer
884 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
4k 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
  • 363
0 votes
1 answer
193 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
351 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
  • 528
1 vote
1 answer
450 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 ...
Taylor Fang's user avatar
1 vote
0 answers
295 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
1 vote
1 answer
2k 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

1
2 3 4 5
10