Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Summary statistics in glmnet

I have been working on a data set and using glmnet for linear LASSO/Ridge regressions.

For the sake of simplicity, let's assume that the model I am using is the following:

cv.glmnet(train.features, train.response, alpha=1, nlambda=100, type.measure = "mse", nfolds = 10)

I'm preparing a presentation for a client and I need to show the T-stats of variables and R-squared values. In addition, I also need to plot the residuals against the fitted values of the model.

Before creating the functions to do this from scratch, I wanted to ask whether or not this is already covered in the library. I have checked the glmnet vignette but did not find anything.

Thanks for your help!

like image 756
dd_rlwll Avatar asked Jul 05 '15 06:07

dd_rlwll


People also ask

What is the difference between Glmnet and CV Glmnet?

cv. glmnet uses cross validation whereas glmnet simply relies on the cost function.

What is CVM in Glmnet?

glmnet" is returned, which is a list with the ingredients of the cross-validation fit. lambda the values of lambda used in the fits. cvm The mean cross-validated error - a vector of length length(lambda) . cvsd estimate of standard error of svm .

Why is Glmnet so fast?

The code can handle sparse input-matrix formats, as well as range constraints on coefficients. The core of glmnet is a set of Fortran subroutines, which make for very fast execution. The theory and algorithms in this implementation are described in Friedman, Hastie, and Tibshirani (2010), Simon et al.

What is Dev ratio in Glmnet?

From glmnet documentation, dev. ratio is The fraction of (null) deviance explained (for "elnet", this is the R-square).


1 Answers

A partial answer to your question: The plotres function in the plotmo R package is an easy way to plot residuals for a wide variety of models, including glmnet and cv.glmnet models. The plotres vignette included with the package has details. For example

library(glmnet)
data(longley)
mod <- glmnet(data.matrix(longley[,1:6]), longley[,7])
library(plotmo) # for plotres
plotres(mod)

gives the following plot. You can select subplots and modify the plots by passing the appropriate arguments to plotres.

plot

like image 92
Stephen Milborrow Avatar answered Oct 31 '22 06:10

Stephen Milborrow