glmnet Questions

4

Solved

I'm trying to use the glmnet package on a dataset. I'm using cv.glmnet() to get a lambda value for glmnet(). I'm excluding columns 1,2,7,12 as they are: id column, response column, contain NA's, an...
Eveland asked 10/12, 2011 at 17:3

4

I have 2 data frames in R with epigenetic data. To use one of them as a train set and the other as a test set in the glmnet package, the column number if them have to match. As both of the data fra...
Distillery asked 5/11, 2020 at 13:23

2

Solved

In the last few months I've worked on a number of projects where I've used the glmnet package to fit elastic net models. It's great, but the interface is rather bare-bones compared to most R modell...
Rebeca asked 17/3, 2015 at 7:55

3

I am running the following (truncated) code using glmnet in R # do a lot of things to create the design matrix called x.design > glmnet(x.design, y, thresh=1e-11) where x.design is a n x p d...
Valonia asked 18/2, 2019 at 21:46

9

I would like to extract the glmnet generated model coefficients and create a SQL query from them. The function coef(cv.glmnet.fit) yields a 'dgCMatrix' object. When I convert it to a matrix using a...
Pitchford asked 6/1, 2015 at 14:29

4

Solved

I am trying to create a model using glmnet, (currently using cv to find the lambda value) and I am getting an error NA/NaN/Inf in foreign function call (arg 5). I believe this has something to do w...
Ballou asked 18/2, 2014 at 15:27

1

Solved

My problem I would like to build a logistic regression model with a high AUC in predicting a binary variable. I would like to use the following approach (if feasible): Use an elastic net model (gl...
Geaghan asked 14/3, 2021 at 4:34

3

I am performing lasso regression in R using glmnet package: fit.lasso <- glmnet(x,y) plot(fit.lasso,xvar="lambda",label=TRUE) Then using cross-validation: cv.lasso=cv.glmnet(x,y) plot(cv...
Teepee asked 30/5, 2018 at 18:0

5

Solved

The glmnet package uses a range of LASSO tuning parameters lambda scaled from the maximal lambda_max under which no predictors are selected. I want to find out how glmnet computes this lambda_max v...
Dodder asked 12/8, 2014 at 6:43

3

Solved

I have a set of multicollinear variables and I'm trying to use ridge regression to tackle that. I am using the glmnet package in R with alpha = 0 (for ridge regression). library(glmnet) I have ...
Rumrunner asked 1/7, 2017 at 14:26

2

I'm having an issue with glmnet in that I keep getting the error message "Error in elnet(x, is.sparse, ix, jx, y, weights, offset, type.gaussian, : NA/NaN/Inf in foreign function call (arg 5) In ...
Gory asked 7/2, 2014 at 18:48

2

it just reports: Cholmod error 'X and/or Y have wrong dimensions' at file ../MatrixOps/cholmod_sdmult.c, line 90. i don't know why. x.m <- data.matrix(train[,c(1:43)]) x.m [is.na(x.m)] &...
Flare asked 11/4, 2018 at 11:46

3

I'm trying to build a model with the glmnet package, but I'm getting the following error when I run the following line: #library('glmnet') x = model.matrix(response ~ ., data = acgh_frame[,c(3:nco...
Tetrabrach asked 28/9, 2015 at 15:44

2

Solved

When I am using R, how can I save a model built by glmnet to a file, and then read it from the file so as to use it to predict? Is it also the same if I use cv.glmnet to build the model? Thanks!...
Ecbatana asked 9/12, 2013 at 3:26

1

Solved

I want to calculate variable importance for glmnet model in R. I am using glmnet package for fitting the elastic net model like library(glmnet) library(caret) library(vip) data_y <- as.vector(m...
Vannie asked 21/9, 2020 at 8:55

2

I'm running an elastic net on a generalized linear model with the glmnet and caret packages in R. My response variable is cost (where cost > $0) and hence I'd like to specify a Gaussian family wi...
Whitacre asked 8/8, 2014 at 15:21

1

Solved

I estimated a glmnet logistic regression using tidymodels. But I couldn't figure out 2 things, which are closely related, in tidymodels: a) how to extract the estimated coefficients b) save the es...
Swag asked 25/7, 2020 at 11:8

1

When estimating a lasso model via the glmnet package, I am wondering whether it is better to: (a) pull coefficients / predictions / deviance straight from the cv.fit object procured from cv.glmnet,...
Hellenism asked 30/11, 2017 at 21:7

1

Solved

I'm sure there is an elegant way to extract the best alpha and lambda after running cva.glmnet but somehow I cannot find it. Here is the code I am using in the meantime. Thank you library(data.t...
Florous asked 21/2, 2019 at 9:48

3

Solved

I'm wondering if I can get AIC and BIC from GLMNet. I've found glmnet.cr that seems to be able to do it but my response is time, not ordinal. I could calculate it myself from likelihood but glmnet ...
Cuda asked 1/12, 2016 at 20:46

2

Getting an error when using glmnet in Caret Example below Load Libraries library(dplyr) library(caret) library(C50) Load churn data set from library C50 data(churn) create x and y variables...
Lethalethal asked 10/1, 2018 at 2:27

3

Solved

I am using following code with glmnet: > library(glmnet) > fit = glmnet(as.matrix(mtcars[-1]), mtcars[,1]) > plot(fit, xvar='lambda') However, I want to print out the coefficients at...
Pewter asked 1/6, 2015 at 4:3

3

Solved

Why there is no possibility to pass only 1 explanatory variable to model in glmnet function from glmnet package when it is possible in glm function from base? Code and error are below: > modelX...
Biancabiancha asked 24/3, 2015 at 11:14

2

I have been working on a data set and using glmnet for linear LASSO/Ridge regressions. For the sake of simplicity, let's assume that the model I am using is the following: cv.glmnet(train.feature...

7

I am trying to predict probabilities in a dataset using glmnet. My code reads: bank <- read.table("http://www.stat.columbia.edu/~madigan/W2025/data/BankSortedMissing.TXT",header=TRUE) bank$rich...
Chuckwalla asked 12/3, 2015 at 15:14

© 2022 - 2025 — McMap. All rights reserved.