diff --git a/DESCRIPTION b/DESCRIPTION index 58d92d257..5f125bf81 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,7 +1,7 @@ Type: Package Package: performance Title: Assessment of Regression Models Performance -Version: 0.16.0.3 +Version: 0.16.0.4 Authors@R: c(person(given = "Daniel", family = "Lüdecke", diff --git a/NEWS.md b/NEWS.md index 838ee9900..8c769dee4 100644 --- a/NEWS.md +++ b/NEWS.md @@ -12,9 +12,14 @@ `modelbased::estimate_prediction()` and returns posterior predictive data in the same format as for other supported models. +* Updated tests to work with the next release of the *DHARMa* package + (version 0.5.0). + ## Bug fixes -* Fixed issue in `check_collinearity()` that was causing inflated VIF values +* Fixed issue in `check_collinearity()` for models from the *fixest* package. + +* Fixed issue in `check_collinearity()` that was causing inflated VIF values when applied to clm and clmm models from the ordinal package. * Fixed issue in `test_likelihoodratio_ListLavaan()` that was extracting the diff --git a/R/check_collinearity.R b/R/check_collinearity.R index fdb684c2d..41ade1c89 100644 --- a/R/check_collinearity.R +++ b/R/check_collinearity.R @@ -450,6 +450,11 @@ check_collinearity.zerocount <- function( .check_collinearity <- function(x, component, ci = 0.95, verbose = TRUE) { v <- .safe(insight::get_varcov(x, component = component, verbose = FALSE)) + # fix class for fixest, which returns a "fixest_vcov" here + if (inherits(v, "fixest_vcov")) { + v <- array(v, dim = dim(v), dimnames = dimnames(v)) + } + # sanity check if (is.null(v)) { if (isTRUE(verbose)) { diff --git a/tests/testthat/test-check_autocorrelation_simres.R b/tests/testthat/test-check_autocorrelation_simres.R index 7a49d69f1..bd1738d82 100644 --- a/tests/testthat/test-check_autocorrelation_simres.R +++ b/tests/testthat/test-check_autocorrelation_simres.R @@ -1,5 +1,5 @@ test_that("check_autocorrelation works with simulated residuals", { - skip_if_not_installed("DHARMa") + skip_if_not_installed("DHARMa", minimum_version = "0.5.0") skip_if_not_installed("glmmTMB") skip_if_not(getRversion() >= "4.0.0") @@ -30,7 +30,7 @@ test_that("check_autocorrelation works with simulated residuals", { test_that("check_autocorrelation.DHARMa works", { - skip_if_not_installed("DHARMa") + skip_if_not_installed("DHARMa", minimum_version = "0.5.0") # Test that the DHARMa method works data(mtcars) diff --git a/tests/testthat/test-check_normality.R b/tests/testthat/test-check_normality.R index 4867adf4a..a015b9d0e 100644 --- a/tests/testthat/test-check_normality.R +++ b/tests/testthat/test-check_normality.R @@ -83,7 +83,7 @@ test_that("check_normality | t-test", { test_that("check_normality | simulated residuals", { - skip_if_not_installed("DHARMa") + skip_if_not_installed("DHARMa", minimum_version = "0.5.0") m <- lm(mpg ~ wt + cyl + gear + disp, data = mtcars) res <- simulate_residuals(m) out <- check_normality(res) diff --git a/tests/testthat/test-check_outliers.R b/tests/testthat/test-check_outliers.R index 37ca26c98..62eb10646 100644 --- a/tests/testthat/test-check_outliers.R +++ b/tests/testthat/test-check_outliers.R @@ -415,7 +415,7 @@ test_that("check_outliers on numeric data only", { test_that("check_outliers with DHARMa", { - skip_if_not_installed("DHARMa") + skip_if_not_installed("DHARMa", minimum_version = "0.5.0") mt1 <- mtcars[, c(1, 3, 4)] # create some fake outliers and attach outliers to main df mt2 <- rbind( diff --git a/tests/testthat/test-check_overdispersion.R b/tests/testthat/test-check_overdispersion.R index 1af6b1327..84c82fd0b 100644 --- a/tests/testthat/test-check_overdispersion.R +++ b/tests/testthat/test-check_overdispersion.R @@ -77,7 +77,7 @@ test_that("check_overdispersion, glmmTMB-poisson mixed", { test_that("check_overdispersion, zero-inflated and negbin", { skip_if_not_installed("glmmTMB") - skip_if_not_installed("DHARMa") + skip_if_not_installed("DHARMa", minimum_version = "0.5.0") skip_if_not(getRversion() >= "4.0.0") data(Salamanders, package = "glmmTMB") @@ -141,7 +141,7 @@ test_that("check_overdispersion, zero-inflated and negbin", { test_that("check_overdispersion, MASS::negbin", { skip_if_not_installed("MASS") - skip_if_not_installed("DHARMa") + skip_if_not_installed("DHARMa", minimum_version = "0.5.0") set.seed(3) mu <- rpois(500, lambda = 3) x <- rnorm(500, mu, mu * 3) @@ -181,7 +181,7 @@ test_that("check_overdispersion, MASS::negbin", { test_that("check_overdispersion, genpois", { skip_if_not_installed("glmmTMB") - skip_if_not_installed("DHARMa") + skip_if_not_installed("DHARMa", minimum_version = "0.5.0") skip_if_not(getRversion() >= "4.0.0") data(Salamanders, package = "glmmTMB") @@ -193,13 +193,9 @@ test_that("check_overdispersion, genpois", { expect_equal( check_overdispersion(model), structure( - list( - dispersion_ratio = 0.971975646955856, - p_value = 0.88 - ), - class = c("check_overdisp", "see_check_overdisp") - ), - tolerance = 1e-4, - ignore_attr = TRUE + list(dispersion_ratio = 1.13005481966618, p_value = 0.408), + class = c("check_overdisp", "see_check_overdisp"), + object_name = "model" + ) ) }) diff --git a/tests/testthat/test-check_residuals.R b/tests/testthat/test-check_residuals.R index 526ba02c5..0fc3269d8 100644 --- a/tests/testthat/test-check_residuals.R +++ b/tests/testthat/test-check_residuals.R @@ -1,6 +1,6 @@ test_that("check_residuals and simulate_residuals", { skip_on_cran() - skip_if_not_installed("DHARMa") + skip_if_not_installed("DHARMa", minimum_version = "0.5.0") set.seed(123) dat <- DHARMa::createData(sampleSize = 100, overdispersion = 0.5, family = poisson()) m <- glm(observedResponse ~ Environment1, family = poisson(), data = dat) diff --git a/tests/testthat/test-check_zeroinflation.R b/tests/testthat/test-check_zeroinflation.R index 53f8af9f5..e91c9305f 100644 --- a/tests/testthat/test-check_zeroinflation.R +++ b/tests/testthat/test-check_zeroinflation.R @@ -22,7 +22,7 @@ test_that("check_zeroinflation", { test_that("check_zeroinflation, glmmTMB with and without zero-inflation component", { skip_if_not_installed("glmmTMB") - skip_if_not_installed("DHARMa") + skip_if_not_installed("DHARMa", minimum_version = "0.5.0") set.seed(123) data(Salamanders, package = "glmmTMB") @@ -95,9 +95,9 @@ test_that("check_zeroinflation, glmer.nb", { list( predicted.zeros = 153, observed.zeros = 155L, - ratio = 0.987329032258065, + ratio = 0.986916129032258, tolerance = 0.1, - p.value = 0.944 + p.value = 0.92 ), class = "check_zi" ), @@ -108,7 +108,7 @@ test_that("check_zeroinflation, glmer.nb", { test_that("check_zeroinflation, glmmTMB nbinom", { skip_if_not_installed("glmmTMB") - skip_if_not_installed("DHARMa") + skip_if_not_installed("DHARMa", minimum_version = "0.5.0") skip_on_cran() data(Salamanders, package = "glmmTMB") @@ -122,11 +122,11 @@ test_that("check_zeroinflation, glmmTMB nbinom", { check_zeroinflation(m), structure( list( - predicted.zeros = 389, + predicted.zeros = 386, observed.zeros = 387L, - ratio = 1.00635658914729, + ratio = 0.996196382428941, tolerance = 0.1, - p.value = 0.944 + p.value = 0.952 ), class = "check_zi" ), @@ -137,7 +137,7 @@ test_that("check_zeroinflation, glmmTMB nbinom", { test_that("check_zeroinflation, MASS::negbin", { skip_if_not_installed("MASS") - skip_if_not_installed("DHARMa") + skip_if_not_installed("DHARMa", minimum_version = "0.5.0") set.seed(3) mu <- rpois(500, lambda = 3) x <- rnorm(500, mu, mu * 3) @@ -164,7 +164,7 @@ test_that("check_zeroinflation, MASS::negbin", { test_that("check_zeroinflation, genpois", { skip_if_not_installed("glmmTMB") - skip_if_not_installed("DHARMa") + skip_if_not_installed("DHARMa", minimum_version = "0.5.0") skip_if_not(getRversion() >= "4.0.0") data(Salamanders, package = "glmmTMB") @@ -177,11 +177,11 @@ test_that("check_zeroinflation, genpois", { check_zeroinflation(model), structure( list( - predicted.zeros = 386, + predicted.zeros = 382, observed.zeros = 387L, - ratio = 0.997860465116279, + ratio = 0.98831007751938, tolerance = 0.1, - p.value = 1 + p.value = 0.64 ), class = "check_zi" ),