Glance accepts a model object and returns a tibble::tibble() with exactly one row of model summaries. The summaries are typically goodness of fit measures, p-values for hypothesis tests on residuals, or model convergence information.

Glance never returns information from the original call to the modelling function. This includes the name of the modelling function or any arguments passed to the modelling function.

Glance does not calculate summary measures. Rather, it farms out these computations to appropriate methods and gathers the results together. Sometimes a goodness of fit measure will be undefined. In these cases the measure will be reported as NA.

# S3 method for glmnet
glance(x, ...)

Arguments

x

A glmnet object returned from glmnet::glmnet().

...

Additional arguments. Not used. Needed to match generic signature only. Cautionary note: Misspelled arguments will be absorbed in ..., where they will be ignored. If the misspelled argument has a default value, the default value will be used. For example, if you pass conf.lvel = 0.9, all computation will proceed using conf.level = 0.95. Additionally, if you pass newdata = my_tibble to an augment() method that does not accept a newdata argument, it will use the default value for the data argument.

See also

Value

A tibble::tibble() with exactly one row and columns:

npasses

total passes over the data across all lambda values

nulldev

null deviance

Examples

library(glmnet) set.seed(2014) x <- matrix(rnorm(100*20),100,20) y <- rnorm(100) fit1 <- glmnet(x,y) tidy(fit1)
#> # A tibble: 1,086 x 5 #> term step estimate lambda dev.ratio #> <chr> <dbl> <dbl> <dbl> <dbl> #> 1 (Intercept) 1 -0.207 0.152 0 #> 2 (Intercept) 2 -0.208 0.139 0.00464 #> 3 V16 2 -0.00292 0.139 0.00464 #> 4 V17 2 -0.0148 0.139 0.00464 #> 5 (Intercept) 3 -0.209 0.127 0.0111 #> 6 V16 3 -0.0150 0.127 0.0111 #> 7 V17 3 -0.0286 0.127 0.0111 #> 8 (Intercept) 4 -0.210 0.115 0.0165 #> 9 V16 4 -0.0260 0.115 0.0165 #> 10 V17 4 -0.0412 0.115 0.0165 #> # ... with 1,076 more rows
glance(fit1)
#> # A tibble: 1 x 2 #> nulldev npasses #> <dbl> <int> #> 1 104. 255
library(dplyr) library(ggplot2) tidied <- tidy(fit1) %>% filter(term != "(Intercept)") ggplot(tidied, aes(step, estimate, group = term)) + geom_line()
ggplot(tidied, aes(lambda, estimate, group = term)) + geom_line() + scale_x_log10()
ggplot(tidied, aes(lambda, dev.ratio)) + geom_line()
# works for other types of regressions as well, such as logistic g2 <- sample(1:2, 100, replace=TRUE) fit2 <- glmnet(x, g2, family="binomial") tidy(fit2)
#> # A tibble: 976 x 5 #> term step estimate lambda dev.ratio #> <chr> <dbl> <dbl> <dbl> <dbl> #> 1 (Intercept) 1 -0.241 0.177 1.78e-15 #> 2 (Intercept) 2 -0.241 0.161 1.57e- 2 #> 3 V13 2 0.0620 0.161 1.57e- 2 #> 4 (Intercept) 3 -0.241 0.147 2.88e- 2 #> 5 V13 3 0.119 0.147 2.88e- 2 #> 6 (Intercept) 4 -0.241 0.134 3.98e- 2 #> 7 V13 4 0.171 0.134 3.98e- 2 #> 8 (Intercept) 5 -0.242 0.122 4.91e- 2 #> 9 V13 5 0.220 0.122 4.91e- 2 #> 10 (Intercept) 6 -0.243 0.111 5.69e- 2 #> # ... with 966 more rows