tests/testthat/test-tornado_glmnet.R

context("test-tornado_glmnet")

test_that("tornado glmnet works", {
  testthat::skip_if_not_installed("glmnet")

  torn <- tornado(glmnet_model, modeldata = mtcars, form = glmnet_form, s = "lambda.1se",
                  type = "PercentChange", alpha = 0.10)
  expect_equal(class(torn), "tornado_plot")
  g <- plot(torn, plot = FALSE, xlabel = "MPG")
  g <- g + ggtitle("Test: glmnet")
  plot(g)
})

test_that("tornado glmnet works with weights", {
  testthat::skip_if_not_installed("glmnet")

  torn <- tornado(glmnet_model_weighted, modeldata = mtcars, form = glmnet_form, s = "lambda.1se",
                  type = "PercentChange", alpha = 0.10)
  expect_equal(class(torn), "tornado_plot")
  g <- plot(torn, plot = FALSE, xlabel = "MPG")
  g <- g + ggtitle("Test: glmnet with weights")
  plot(g)
})
bertcarnell/tornado documentation built on Aug. 6, 2024, 10:17 p.m.