tests/testthat/test-find_formula.R

test_that("`find_formula` works with `mgcv::gam()`", {
  skip_if_not_installed("mgcv")
  set.seed(2) ## simulate some data...
  dat <- mgcv::gamSim(1, n = 50, dist = "normal", scale = 2, verbose = FALSE)
  b <- mgcv::gam(list(y ~ s(x0) + s(x1) + s(x2), ~ s(x3)), family = mgcv::gaulss(), data = dat)

  f <- find_formula(b)
  expect_named(f, c("conditional", "scale"))
  expect_identical(f$conditional, formula("y ~ s(x0) + s(x1) + s(x2)"))
  expect_identical(f$scale, formula("~s(x3)"))
})


test_that("formula warns for badly formulated response", {
  data(iris)
  model <- lm(iris[, 2] ~ Species, data = iris)
  expect_warning(formula_ok(model), regex = "Using indexed")
})
easystats/insight documentation built on Oct. 2, 2024, 8:19 a.m.