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

glmnet error "Error in lognet(x, is.sparse, ix, jx, y, weights, offset, alpha, nobs, : (list) object cannot be coerced to type 'double'"

My data I am having a problem running logistic regression for my data, first I used glm function in r but got the following warning: Warning message: glm.fit: fitted probabilities numerically 0 or 1 occurred Now I am trying to do glmnet because the…
MRM
  • 1,099
  • 2
  • 12
  • 29
0
votes
1 answer

Why does the number of observations reduce using model.matrix in ridge regression?

I'm using glmnet package in R for ridge regression. I tried on Hitters dataset from ISLR package. The problem is, when I use model.matrix to create the design matrix, the number of observations reduced for unknown reason. This is the…
Ashley
  • 67
  • 1
  • 7
0
votes
0 answers

invalid mtry error when trying to do RFE?

I am newer with programming in R. I am trying to do RFE on 300 predictors to ideally select the 30 most informative predictors and capture the ranking of the predictors. I have fit a logistic regression model as such: var_selected = [.....column…
rmahesh
  • 739
  • 2
  • 14
  • 30
0
votes
0 answers

How to fix in cv.glmnet the Error of different rows?

I try to Cross validate my data to get a good lambda parameter. The cross validation give me an error output because of different weights. I didn´t set up any wheigts so far. i thought its a problem of the number of rows in y.train and X.mat.train…
0
votes
1 answer

How do I set y for gmlnet with several predictors

I am supposed to find the intercept term using Ridge Regression model. "Use Ridge Regression with alpha = 0 to and lambda = 0, divorce as the response and all the other variables as predictors." I know I'm supposed to convert my data to matrix mode…
delete
  • 75
  • 6
0
votes
2 answers

Using glmnet to find optimized model for a given number of predictors

I'm attempting to use LASSO for a slightly different function than originally designed. I have a 22 different tasks on a test, which, when averaged, produce a final score. I want to see which combination of a limited number of tasks would best…
jsizzle
  • 78
  • 8
0
votes
1 answer

Issue running glmnet() for mtcars dataset

Whenever I run glmnet(mpg ~ ., data = mtcars, alpha=1) (from the glmnet package) I get the following error: "Error in glmnet(mpg ~ ., data = mtcars, alpha = 1) : unused argument (data = mtcars)" Any ideas for how to deal with this? I think its…
bob
  • 610
  • 5
  • 23
0
votes
1 answer

rpy2 glmnet getting coefficients with row names

I am using glmnet in Python using rpy2. However, I am not sure how to return the row names of the matrix in Python. Following only returns the matrix but not the variable names. model = glm.cv_glmnet(x=XW_1, y=Y_1, **{'penalty.factor':…
Buyan
  • 1
0
votes
1 answer

tidy predictions and confusion matrix with glmnet

Consider this example: library(quanteda) library(caret) library(glmnet) library(dplyr) dtrain <- data_frame(text = c("Chinese Beijing Chinese", "Chinese Chinese Shanghai", "Chinese…
ℕʘʘḆḽḘ
  • 18,566
  • 34
  • 128
  • 235
0
votes
1 answer

using glmnet with future

On windows, I have difficulties using library(doparallel) which seems to crash after a few glmnet calls So I am trying to use the future package (https://github.com/HenrikBengtsson/future) with glmnet but I am unsure what is the best way to proceed…
ℕʘʘḆḽḘ
  • 18,566
  • 34
  • 128
  • 235
0
votes
0 answers

Minimal glmnet example for factors

I am trying to understand how to use the R package glmnet. Suppose I have a dataset, representing games played between two teams, with the 'win' column defining the result. library(RcppAlgos) library(dplyr) data <-…
ThanksABundle
  • 385
  • 1
  • 8
0
votes
0 answers

Stepwise Logistic Regression, stopping at best N features

I'm interested in exploring what shakes out of a stepwise logistic regression from the top N variables...whether that is 5 or 15 depending upon my preference of this. I've tried to play around with the caret…
runningbirds
  • 6,235
  • 13
  • 55
  • 94
0
votes
1 answer

Performing lasso regularization with factors and numeric predictors?

I have a data set in which I want to perform lasso for feature elimination. I am currently following a guide online in R as I am new to R. The data is stored in a dataframe. The target has been removed from the dataframe and is stored in its own…
rmahesh
  • 739
  • 2
  • 14
  • 30
0
votes
1 answer

glmnet plots - no axes or labels

I'm playing around with the standard plots in glmnet and am having an issue - axes and labels aren't being displayed. If I try: cv <- cv.glmnet(x, y, alpha = 1, family = "binomial", type.measure = "class") plot(cv) mod <- glmnet(x, y, alpha = 0,…
LucaS
  • 887
  • 1
  • 9
  • 22
0
votes
1 answer

For loop in R with predict

I'd like to run a prediction across different alphas using the glmnet package. y is a (14x1) dependent variable, x is a series (14x19) of independent variables. Dput data below. x <- Macro[1:13,3:21] x <- as.matrix(x) y <- Macro[1:13,2:2] y <-…
ZJAY
  • 2,517
  • 9
  • 32
  • 51