Questions tagged [glmnet]

glmnet is an R package for Lasso and elastic-net regularized generalized linear models.

Overview

glmnet is an R package which provides Lasso and elastic-net regularized generalized linear models. It features extremely efficient procedures for fitting the entire Lasso or elastic-net regularization path for linear regression, logistic and multinomial regression models, Poisson regression and the Cox model.

Resources

Tag usage

Questions on should be about implementation and programming problems, not about the statistical or theoretical properties of the technique.
Consider whether your question might be better suited to Cross Validated, the Stack Exchange site for statistics, machine learning and data analysis.

598 questions
0
votes
0 answers

R glmnet multiresponse gaussian, print 'double' error, data import from SPSS

Ι am an absolute beginner at R. I want to use it to do a lasso multiresponse regression model, using a large number of MRI brain metrics to predict 3 or 4 behavioural outcome variables. The original datasets are in SPSS. I have used to 'foreign'…
0
votes
2 answers

How to use glmnet in R for classfication of multiple classes

I'm trying to figure out how to use glmnet to classify a text. I managed to get it working for two classes using family="binomial" type.measure="auc" I wanted to do the same for multiple-classes using multinomial family. I tried something like…
Khenrix
  • 11
  • 1
  • 7
0
votes
1 answer

Extract glmnet's lambda matrix

I would like to extract the lambda-matrix of a ridge regression. I can plot it, but I cannot extract the values. The wanted matrix should include the lambdas (in rows) and the variables including names (in…
r.user.05apr
  • 5,356
  • 3
  • 22
  • 39
0
votes
0 answers

Glmnet lasso logistic regression - Correct form of specifying lambda for final predictions?

I would like to make sure that I am using the prediction method here correctly; maybe I am misinterpreting the parameter "s" here!? My intent is to use the best lambda obtained from cross validation to make my final predictions on a holdout…
CodingButStillAlive
  • 733
  • 2
  • 8
  • 22
0
votes
1 answer

Use penalty.factor in stabsel in R

I'd like to use stabsel on top of glmnet lasso for variable selection. I was following the examples on https://github.com/hofnerb/stabs and it works fine. However, I'd also like to force including several variables. This can be achieve in glmnet…
ybeybe
  • 149
  • 1
  • 12
0
votes
1 answer

r glmnet error: object cannot be coerced to type 'double'

I am trying to obtain the lambda value, I have found this question: R glmnet : "(list) object cannot be coerced to type 'double' " However cannot figure out how to make it apply. here is the code: faba <- read.table("abalone.txt",sep=",") faba$y <-…
rannoudanames
  • 139
  • 1
  • 8
0
votes
0 answers

how to use glmnet in R to obtain percentages for classification

I am trying to do a classification problem. Right now I have a training data set. All data are in these 3 levels: low, medium or high. Now I want to use glmnet package in R to develop a model to classify data into low, medium or high based on some…
Sanguis
  • 113
  • 7
0
votes
0 answers

R : model.matrix for cv.glmnet drops rows from the dataframe

I am having an issue with creating a matrix of explanatory variables for running ridge and lasso regression using cv.glmnet. My original data frame is of dimension 1460*81 and consist of several numeric and factor variables. In order to run glmnet,…
kms
  • 1,810
  • 1
  • 41
  • 92
0
votes
1 answer

How to create a binary preditor from a multivariate glmnet (coxnet) model?

Let´s use the following example: generate survival data (1000 samples with 30…
user86533
  • 323
  • 1
  • 7
  • 18
0
votes
1 answer

glmnet crossvalidation with grouped data

I am using glmnet for web data. Typically the data is categorical (high cardinality of factors) and has millions of samples. I am dealing with 'big data' and want to be memory efficient. Because its categorical, one can more efficiently represent…
seanv507
  • 1,206
  • 1
  • 11
  • 23
0
votes
0 answers

glmnet on binary outcomes with no “0”'s producing “Error in drop(y %*% rep(1, nc))”

I am trying to run the code glmnet(M, R, family="binomial"), where M is a data matrix of size (N by k) and R is a N-dimensional vector of binary values. N is the number of samples and k is the number of variables. In my specific case, R is simply a…
Shoogiebaba
  • 81
  • 10
0
votes
1 answer

How get coefs name from glmnet in R?

I am doing lasso with glmnet in R. I have the lasso coefs out$beta Input: x1 0.5744207722 x2 -0.3575682570 x3 -0.0995794334 How can I extract the name of the variables? Desired output: x1, x2,x3 What I tried $ as.data.frame as.matrix but none of…
Jill Clover
  • 2,168
  • 7
  • 31
  • 51
0
votes
1 answer

using lambda.min to extrace coefficients from model trained with glmnet

I am using glmnet to train the logistic regression model and then try to obtain the coefficients with the specific lambda. I used the simple example here: load("BinomialExample.RData") fit = glmnet(x, y, family = "binomial") coef(fit, s =…
ybwang
0
votes
1 answer

GLMNet convergence issue for penalized regression

I am working on network models for political networks. One of the things I am doing is penalized inference. I am using an adaptive lasso approach by setting a penalty factor for glmnet. I have various parameters in my model: alphas and phis. The…
Frank
  • 1
  • 8
0
votes
0 answers

Trouble predicting a validation dataset on a GLMNET fit in R...

I have the following problem: after splitting my data into training/testing, I am unable to predict the testing with the glmnet fit... Please see the toy example below with the BostonHousing dataset. I think it happens because glmnet (lasso, elnet)…
MEC
  • 71
  • 1
  • 10