diff --git a/DESCRIPTION b/DESCRIPTION index b6f58b233..3f970c585 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,7 +1,7 @@ Type: Package Package: performance Title: Assessment of Regression Models Performance -Version: 0.12.4.8 +Version: 0.12.4.9 Authors@R: c(person(given = "Daniel", family = "Lüdecke", diff --git a/NEWS.md b/NEWS.md index a181937d8..be90d0056 100644 --- a/NEWS.md +++ b/NEWS.md @@ -18,6 +18,9 @@ * `check_outliers()` did not warn that no numeric variables were found when only the response variable was numeric, but all relevant predictors were not. +* `check_collinearity()` did not work for glmmTMB models when zero-inflation + component was set to `~0`. + # performance 0.12.4 ## Changes diff --git a/R/check_collinearity.R b/R/check_collinearity.R index a7e1299c1..1cb0b6913 100644 --- a/R/check_collinearity.R +++ b/R/check_collinearity.R @@ -405,7 +405,7 @@ check_collinearity.zerocount <- function(x, .check_collinearity <- function(x, component, ci = 0.95, verbose = TRUE) { - v <- insight::get_varcov(x, component = component, verbose = FALSE) + v <- .safe(insight::get_varcov(x, component = component, verbose = FALSE)) # sanity check if (is.null(v)) { diff --git a/tests/testthat/test-check_collinearity.R b/tests/testthat/test-check_collinearity.R index d62aec75d..a3ce2b54c 100644 --- a/tests/testthat/test-check_collinearity.R +++ b/tests/testthat/test-check_collinearity.R @@ -218,3 +218,17 @@ test_that("check_collinearity, invalid data", { m1 <- lm(y ~ 1, data = dd) expect_error(check_collinearity(m1), "Can't extract variance-covariance matrix") }) + +test_that("check_collinearity, glmmTMB hurdle w/o zi", { + skip_if_not_installed("glmmTMB") + data(Salamanders, package = "glmmTMB") + mod_trunc_error <- glmmTMB::glmmTMB( + count ~ spp + mined + (1 | site), + data = Salamanders[Salamanders$count > 0, , drop = FALSE], + family = glmmTMB::truncated_nbinom2(), + ziformula = ~ 0, + dispformula = ~ 1 + ) + out <- check_collinearity(mod_trunc_error) + expect_equal(out$VIF, c(1.03414, 1.03414), tolerance = 1e-3) +})