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
1 answer

Lasso error in glmnet for y[train]

I have a problem with the package glmnet in R. I am trying to use it but I am getting the following problem: { > names(mtcars) #lasso ## 75% of the sample size > smp_size <- floor(0.75 * nrow(mtcars)) ## set the seed to make your partition…
SA12
  • 318
  • 2
  • 10
0
votes
2 answers

How does glmnet standardize variables when weights are present?

glmnet allows the user to input a vector of observation weights through the weights argument. glmnet also standardizes (by default) the predictor variables to have zero mean and unit variance. My question is: when weights is provided, does glmnet…
ved
  • 297
  • 3
  • 11
0
votes
1 answer

how to do ridge regression with log-link in R

I want to do a ridge regression in R by using glmnet or lm.ridge. I need to do this regression with log(Y) cost ~ size + weight ⇒ log(cost) ~ size + weight However, I found that there is no link like glm for glmnet or lm.ridge. Any ideas for this…
potatout
  • 187
  • 1
  • 11
0
votes
1 answer

Using glmnet with MATLAB R2016a

i'm trying to use glmnet vignette in MATLAB R2016a on windows 10 (64bit). I downloaded the version from here. Every time that I try to use a function (like cvglmnet) MATLAB crashes. The glmnet version for MATLAB was tested only on MATLAB 2013b…
leonardo vet
  • 119
  • 14
0
votes
2 answers

issue with predict with glmnetUtils

trying to use the glmnetUtils package from GitHub for formula interface to glmnet but predict is not estimating enough values library(nycflights13) # from…
Dominik
  • 782
  • 7
  • 27
0
votes
1 answer

cv.glmnet parallel and memory issue

It is the first time I am using parallel processing in general. The question is mainly about my poor syntax. I would like some help in capturing the output for a large number of cv.glmnet iterations, as I believe I have built cv_loop_run to be badly…
J. Doe.
  • 1,255
  • 1
  • 12
  • 25
0
votes
1 answer

Unable to specify type="response" in Caret's predict function

I am trying to plot a ROC curve for my glmnet regression model. In order to do that, I am trying to predict using type = "response" in predict function: pred_glmnet_s10_2class <- predict(model_train_glmnet_s10_2class, …
trickymaverick
  • 199
  • 1
  • 3
  • 8
0
votes
2 answers

Error using glmnet regression with metric as ROC in Caret

I am training a glmnet regularized logistic regression model using Caret's trainControl and train functions as follows using metric= "ROC" and get the following error: > ctrl_s10_2class <- trainControl(method = "repeatedcv", number = 10, repeats =…
trickymaverick
  • 199
  • 1
  • 3
  • 8
0
votes
1 answer

Problems with preparing data for Lasso regression

I'm trying to take Lasso regression but I can't define well my X and Y in R. #load data >test.data<-read.spss("C:\\Users\\Inhib\\OneDrive\\documents\\dummy.sav",use.value.labels=TRUE, to.data.frame=TRUE) >test.data #testing my data, it's all there…
Gilad Sabo
  • 41
  • 1
  • 5
0
votes
1 answer

R glmnet classification - family = 'binomial', type = 'class', no errors, why am I still getting regression predictions?

I've been mucking around for about a week now, trying to figure this one out, so any help would be greatly appreciated. I've got a data set with a binary target, and continuous predictors. The input looks like this (with more variables, but you…
0
votes
0 answers

Trying to load my data for cv.glmnet

I have txt file on which the results of a research are saved. I called it SPD this way: SPD<-read.table("C:\\Users\\Inhib\\OneDrive\\documents\\mydata.FromR.txt", header=TRUE) when I write then SPD it presents all columns and everything is…
Gilad Sabo
  • 41
  • 1
  • 5
0
votes
0 answers

Attributes of GLMNET Library in R

I was using the glmnet package in R, and I saved my input x, as a csv file. Its dimensions are: 34 by 8.I saved the output variable y as another csv file, and its dimensions were: 34 by 1 Code: x <- read.csv("input.csv") y <-…
204
  • 433
  • 1
  • 5
  • 19
0
votes
0 answers

Previously saved Glmnet model results in error message

I have created a glmnet model to use it with new data for predictions. ypred <- predict(fit, newx = pred.dat, type = "class") but it returns following error message: Error in as.matrix(cbind2(1, newx) %*% nbeta) : error in evaluating the…
KG12
  • 77
  • 1
  • 1
  • 8
0
votes
0 answers

L2 regularized MLR using caret, and how to make sure I am using best model while predicting

I am trying to do L2-regularized MLR on a data set using caret. Following is what I have done so far to achieve this: r_squared <- function ( pred, actual){ mean_actual = mean (actual) ss_e = sum ((pred - actual )^2) ss_total = sum…
0
votes
1 answer

Remove upper axis in plot glmnet

When using glmnet and making a plot of the coefficient path, I would like to remove the axis above the plot. How do you remove this axis? I found this toy example on the web: library(glmnet) age <- c(4,8,7,12,6,9,10,14,7) gender <-…
milan
  • 4,782
  • 2
  • 21
  • 39