Extract Coefficient Information from Models

# S3 method for cv.glmnet
extract.coef(model, lambda = "lambda.min", ...)

Arguments

model

Model object from which to extract information.

lambda

Value of penalty parameter. Can be either a numeric value or one of "lambda.min" or "lambda.1se"

...

Further arguments

Value

A data.frame containing the coefficient, the standard error and the variable name.

Details

Gets the coefficient values and variable names from a model. Since glmnet does not have standard errors, those will just be NA.

Examples

library(glmnet) library(ggplot2) library(useful) data(diamonds) diaX <- useful::build.x(price ~ carat + cut + x - 1, data=diamonds, contrasts=FALSE) diaY <- useful::build.y(price ~ carat + cut + x - 1, data=diamonds) modG1 <- cv.glmnet(x=diaX, y=diaY, k=5) extract.coef(modG1)
#> Value SE Coefficient #> (Intercept) 1305.104963 NA (Intercept) #> carat 10053.977527 NA carat #> cutFair -1510.568409 NA cutFair #> cutGood -354.484329 NA cutGood #> cutVery Good 22.573009 NA cutVery Good #> cutPremium -4.642002 NA cutPremium #> cutIdeal 319.428622 NA cutIdeal #> x -950.756928 NA x