Skip to contents

Plot Variable Importance for a GLMNET model

Usage

# S3 method for class 'cv.glmnet'
importance(model_final, model_data, form, dict = NA, nperm = 500, ...)

Arguments

model_final

a model object

model_data

the data used to fit the model

form

the model formula

dict

a variable dictionary for plotting

nperm

the number of permutations used to calculate the importance

...

arguments passed to other methods

Value

an object of type importance_plot

type

the type of importance plot

data

the importance data required for the plot

See also

Examples

if (requireNamespace("glmnet", quietly = TRUE))
{
  form <- formula(mpg ~ cyl*wt*hp)
  mf <- model.frame(form, data = mtcars)
  mm <- model.matrix(mf, mf)
  gtest <- glmnet::cv.glmnet(x = mm, y = mtcars$mpg, family = "gaussian")
  imp <- importance(gtest, mtcars, form, nperm = 50)
  plot(imp)
}