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

Cannot obtain probability predictions when running elasticnet logistic regression with glmnet in caret package

I've noticed when running penalized logistic regression in caret with the glmnet package, the model predictions are reclassified as 0 or 1 outcomes: mydata <- read.csv("http://www.ats.ucla.edu/stat/data/binary.csv") train_control <-…
RobertF
  • 824
  • 2
  • 14
  • 40
0
votes
1 answer

Lasso: Cross-validation for glmnet

I am using cv.glmnet() to perform cross-validation, by default 10-fold library(Matrix) library(tm) library(glmnet) library(e1071) library(SparseM) library(ggplot2) trainingData <- read.csv("train.csv", stringsAsFactors=FALSE,sep=",", header =…
Desta Haileselassie Hagos
  • 23,140
  • 7
  • 48
  • 53
0
votes
1 answer

Ridge-regression model: glmnet

Fitting a linear-regression model using least squares on my training dataset works fine. library(Matrix) library(tm) library(glmnet) library(e1071) library(SparseM) library(ggplot2) trainingData <- read.csv("train.csv",…
Desta Haileselassie Hagos
  • 23,140
  • 7
  • 48
  • 53
0
votes
1 answer

How to write glmnet results (coefs) into csv or text file in R

I am using R glmnet package for elastic net and results look like this: TRTREJ6M_KIY . TXKIDE -1.317048e-01 TXKIDL . TXKIDR …
Dr. Turkuaz
  • 39
  • 1
  • 10
0
votes
1 answer

extract and refit coxph model with variables selected from glmnet

I want to refit coxph model with variables selected from glmnet. I know how to extract variables name from cv.glmnet fit. However, for categorical data, variable's original name were changed. For example, Sex will become SexM (or SexF). Anyone knows…
Thaole
  • 9
  • 4
0
votes
1 answer

How does glmnet() handle with both penalized and unpenalized covariates?

Is it possible to do a lasso model with both penalized and un-penalized covariates? That is, I want to do an estimate with Y ~ gamma * X + beta * Z, where X is a n*p penalized features and Z a n*q un-penalized covariates of continues or factor…
baidao
  • 493
  • 3
  • 10
0
votes
0 answers

Problem with glmnet R package

I'm using glmnet R package. And before today I had no problems using it. I installed caret two days ago, I had some troubles to install it but I succeeded to do some by re-installing some packages like. Here is the error message I get : Error in…
Martin
  • 131
  • 1
  • 2
0
votes
1 answer

How to add glmnet prediction vector to a dataframe as a regular column

I would like to use glmnet package for classification project. I managed to build the model and get the prdiction per row but I don't see a way to use it as a regular variable. How can I add the prediction vector to the data frame as a regular…
mql4beginner
  • 2,193
  • 5
  • 34
  • 73
0
votes
1 answer

R: Convert a caret train object to glmnet object

I'd like to ask how can I convert the final model that I get from a grid search with caret's 'train' function into an object of the class that is created with the glmnet function, assuming that I specified method='glmnet'.
anymous_asker
  • 113
  • 1
  • 11
0
votes
1 answer

How are the predictions obtained?

I have been unable to find information on how exactly predict.cv.glmnet works. Specifically, when a prediction is being made are the predictions based on a fit that uses all the available data? Or are predictions based on a fit where some data has…
noFearOfBeer
  • 77
  • 1
  • 7
0
votes
2 answers

How to add prior knowledge about predictors in an Elastic net Regression model?

I've a Regression model that is most suitably solved using elastic net. It has a very large number of predictors that I need to select only subset of them. Moreover, there could be correlation between the predictors, so Elastic net was the…
Doaa
  • 436
  • 4
  • 10
0
votes
1 answer

MatLab Mex File Crashing Every Third Run

I am currently trying to run codes from the glmnet package (http://web.stanford.edu/~hastie/glmnet_matlab/index.html). It calls mex files during the process. When I run the functions from the package for the first two times, it works fine. Every…
user191919
  • 724
  • 1
  • 9
  • 27
0
votes
0 answers

Error in Function with glmnet model input

I need to create a function that takes as input a glm poisson model and returns the ration deviance/degrees of freedom. I tried this one with glmnet package: functionGLM <- function(x,y,z) { x<-…
Dimitra D
  • 1
  • 1
0
votes
2 answers

I want to use cv.glmnet from library glmnet in R. One of my variables is a character representation of weekday, of type factor. How can I do this?

I have a dataframe that contains a variable "nameDay", which is a factor variable. The days are represented as characters ("Saturday", "Monday"...), but I have converted them to factors. Here are the top 6 rows from this dataframe for…
JonGor
  • 67
  • 1
  • 9
0
votes
1 answer

reaching max.print on R

I just found a bunch of weather data that I would like to play around with in glmnet in R. First I've been reading and organizing the data in R, and right now I am just trying to look at the raw data of each variable. Unfortunately, each variable…
penguinteacher
  • 37
  • 2
  • 11
1 2 3
39
40