if (requireNamespace("glmnet", quietly = TRUE))
{
form <- formula(mpg ~ cyl*wt*hp)
mf <- model.frame(form, data = mtcars)
mm <- model.matrix(form, data = mf)
gtest <- glmnet::cv.glmnet(x = mm, y= mtcars$mpg, family = "gaussian")
torn <- tornado(gtest, modeldata = mtcars, form = formula(mpg ~ cyl*wt*hp), s = "lambda.1se",
type = "PercentChange", alpha = 0.10)
plot(torn, xlabel = "MPG")
}
Run the code above in your browser using DataLab