diff --git a/tests/testthat/test-check_overdispersion.R b/tests/testthat/test-check_overdispersion.R index 9f38cc5ab..a720e7cdc 100644 --- a/tests/testthat/test-check_overdispersion.R +++ b/tests/testthat/test-check_overdispersion.R @@ -133,3 +133,29 @@ test_that("check_overdispersion, MASS::negbin", { tolerance = 1e-4 ) }) + + +test_that("check_overdispersion, genpois", { + skip_if_not_installed("glmmTMB") + skip_if_not_installed("DHARMa") + skip_if_not(getRversion() >= "4.0.0") + data(Salamanders, package = "glmmTMB") + + model <- glmmTMB::glmmTMB( + count ~ mined + spp + (1 | site), + family = glmmTMB::genpois(), + data = Salamanders + ) + expect_equal( + check_overdispersion(model), + structure( + list( + dispersion_ratio = 1.02883236131678, + p_value = 0.88 + ), + class = c("check_overdisp", "see_check_overdisp") + ), + tolerance = 1e-4, + ignore_attr = TRUE + ) +}) diff --git a/tests/testthat/test-check_zeroinflation.R b/tests/testthat/test-check_zeroinflation.R index ef8ee3e44..38a5c7726 100644 --- a/tests/testthat/test-check_zeroinflation.R +++ b/tests/testthat/test-check_zeroinflation.R @@ -160,3 +160,32 @@ test_that("check_zeroinflation, MASS::negbin", { tolerance = 1e-4 ) }) + + +test_that("check_zeroinflation, genpois", { + skip_if_not_installed("glmmTMB") + skip_if_not_installed("DHARMa") + skip_if_not(getRversion() >= "4.0.0") + data(Salamanders, package = "glmmTMB") + + model <- glmmTMB::glmmTMB( + count ~ mined + spp + (1 | site), + family = glmmTMB::genpois(), + data = Salamanders + ) + expect_equal( + check_zeroinflation(model), + structure( + list( + predicted.zeros = 386, + observed.zeros = 387L, + ratio = 0.997860465116279, + tolerance = 0.1, + p.value = 1 + ), + class = "check_zi" + ), + tolerance = 1e-4, + ignore_attr = TRUE + ) +})