FAQ Database Discussion Community


Getting coefficient at best lambda in glmnet in R

r,lambda,regression,glmnet
I am using following code with glmnet: > library(glmnet) > fit = glmnet(as.matrix(mtcars[-1]), mtcars[,1]) > plot(fit, xvar='lambda') However, I want to print out the coefficients at best Lambda, like it is done in ridge regression. I see following structure of fit: > str(fit) List of 12 $ a0 : Named...

plot.glmnet increase size of variable labels

r,plot,glmnet
Currently I am using the glmnet package to run a lasso regression (which in the example below is being saved to the "fits" variable. Then when I plot the fits variable it comes up properly but the coefficient labels are very small. Any ideas how I can increase the size...

Running glmnet package in R, getting error “missing value where TRUE/FALSE needed”, maybe due to missing values?

r,glmnet
I am trying to use glmnet from the glmnet package to run a LASSO regression. I am using the following command: library(glmnet) glmnet(a,b,family="binomial",alpha=1) And am getting the error: > Error in if (!all(o)) { : missing value where TRUE/FALSE needed a is a matrix, with numerical values. b is a...

Adding labels on curves in glmnet plot in R

r,plot,glmnet
I am using glmnet package to get following graph from mtcars dataset (regression of mpg on other variables): library(glmnet) fit = glmnet(as.matrix(mtcars[-1]), mtcars[,1]) plot(fit, xvar='lambda') How can I add names of variables to each curve, either at beginning of each curve or at its maximal y point (maximum away from...