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

Ridge Regression accuracy in R

I have been stuck on this for some time, and am in need of some help. I am new to R and have never done Ridge Regression using GLMNET. I am trying to learn ML via the MNIST-fashion dataset (https://www.kaggle.com/zalando-research/fashionmnist). …
0
votes
1 answer

R: Remove top axis title base plot

I want to remove or rename the "top axis title" of the following plot based on the package plotmo. Here is a short reproducible example: library(glmnet) library(plotmo) data(mtcars) fit <- glmnet(x=as.matrix(mtcars[,-1]),…
Leo96
  • 489
  • 3
  • 12
0
votes
1 answer

unable to use R's future package for lasso regression with glmnet

I recently discovered R's future package and have already successfully used it. However I am unable to use this package together with predictions for lasso regressions. In the following toy example I first create some toy data, then fit a lasso…
Cettt
  • 11,460
  • 7
  • 35
  • 58
0
votes
1 answer

R: plot_glmnet 2nd x-axis number of coefficients

im am using the plot_glmnet function from the package plotmo, like below mod <- glmnet(as.matrix(mtcars[-1]), mtcars[,1]) plot_glmnet(mod) Is there a way to replace the 2nd x-axis at the top with the degrees of freedom and increase its label size ?
rook1996
  • 237
  • 3
  • 9
0
votes
1 answer

Running 1000 simulations, and storing the output from LASSO

I'm running LASSO using the glmnet package using the following commands: x_ss <- model.matrix(y_variable ~ X_variables, data="data") y_ss <- c(y_variable) cv.output_ss <- cv.glmnet(x_ss,y_ss, alpha=1, family="gaussian",…
Hisham
  • 43
  • 1
  • 4
0
votes
1 answer

A comparison between CVXR and glmnet (elastic net)

I fit a model on a simulated data set to compare glmnet and CVXR results. If I don't have a code mistake, the results are very different. Explicitly glmnet yields results which are very close to the true parameters. Why is this the…
mert
  • 371
  • 2
  • 9
0
votes
1 answer

lassoshooting and glmnet different results

I want to compare lassoshooting and glmnet for lasso. No standardization option in lassoshooting; so i standardized data first, fit the model and re-standardized to original scale. Results are different and it seems lassoshooting beta's is closer…
mert
  • 371
  • 2
  • 9
0
votes
0 answers

ridge, lasso regression error in cv.glmnet and error in randomForest

I am trying to run a ridge, lasso regression as well as randomForest model on the total replacement cost from a csv file. This is what I did as follows: data$TOTAL_REPLACEMENT_VALUE=log(data$TOTAL_REPLACEMENT_VALUE) n_total=nrow(data)…
0
votes
1 answer

glmnet input error, format of the input matrix incorrect

I get the following error Error in storage.mode(y) <- "double" : invalid to change the storage mode of a factor an issue with getting the format of the input matrix right. Here the code: library("glmnet") daten = read.csv("test.csv",header =…
mjs
  • 150
  • 1
  • 20
0
votes
1 answer

how to plot the correct labels in glmnet?

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

How to calculate the cross-validated R2 on a LASSO regression?

I am using this code to fit a model using LASSO regression. library(glmnet) IV1 <- data.frame(IV1 = rnorm(100)) IV2 <- data.frame(IV2 = rnorm(100)) IV3 <- data.frame(IV3 = rnorm(100)) IV4 <- data.frame(IV4 = rnorm(100)) IV5 <- data.frame(IV5 =…
Dave
  • 111
  • 2
  • 11
0
votes
0 answers

Parallel cv.glmnet with large matrix in windows

I'm trying to run parallel cv.glmnet poisson models on a windows machine with 64Gb of RAM. My data is a 20 million row x 200 col sparse matrix, around 10Gb in size. I'm using makecluster and doParallel, and setting parallel = TRUE in cv.glmnet. I…
nolanp2
  • 51
  • 6
0
votes
1 answer

How to specify chosen lambda to fit lasso in R

I have found my best lambda(for lasso) through 10 fold cross validation on my training data set and validated with testing dataset. Now I would like to use my best lambda to fit a model on the whole dataset(using both training and test). How do I…
jijforu
  • 5
  • 4
0
votes
1 answer

Why does R return "object not found" error in plot command for glmnet?

I'm very new to R and was playing with the glmnet package. When I try a toy example following the Stanford vignette, I get an error that says: Error in print(fit) : object 'fit' not found I've tried two slightly different toy models to the same…
tooty44
  • 6,829
  • 9
  • 27
  • 39
0
votes
2 answers

How to plot ROC-curve for logistic regression (LASSO) in R?

I am fitting a logistic regression model to a training data set in R, more specifically a LASSO regression with an L1 penalty. I used the glmnetpackage for that. The code for the model looks like this. t1 <- Sys.time() glmnet_classifier <-…
Lucinho91
  • 175
  • 2
  • 4
  • 16