Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
@@ -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",
Expand Down
7 changes: 6 additions & 1 deletion NEWS.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Comment thread
strengejacke marked this conversation as resolved.

* Fixed issue in `test_likelihoodratio_ListLavaan()` that was extracting the
Expand Down
5 changes: 5 additions & 0 deletions R/check_collinearity.R
Original file line number Diff line number Diff line change
Expand Up @@ -447,9 +447,14 @@
}


.check_collinearity <- function(x, component, ci = 0.95, verbose = TRUE) {

Check warning on line 450 in R/check_collinearity.R

View workflow job for this annotation

GitHub Actions / lint-changed-files / lint-changed-files

file=R/check_collinearity.R,line=450,col=1,[cyclocomp_linter] Reduce the cyclomatic complexity of this expression from 46 to at most 40. Consider replacing high-complexity sections like loops and branches with helper functions.

Check warning on line 450 in R/check_collinearity.R

View workflow job for this annotation

GitHub Actions / lint / lint

file=R/check_collinearity.R,line=450,col=1,[cyclocomp_linter] Reduce the cyclomatic complexity of this expression from 46 to at most 40. Consider replacing high-complexity sections like loops and branches with helper functions.
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)) {
Expand Down Expand Up @@ -566,7 +571,7 @@
return(NULL)
}

R <- stats::cov2cor(v)

Check warning on line 574 in R/check_collinearity.R

View workflow job for this annotation

GitHub Actions / lint-changed-files / lint-changed-files

file=R/check_collinearity.R,line=574,col=3,[object_overwrite_linter] 'R' is an exported object from package 'tools'. Avoid re-using such symbols.

Check warning on line 574 in R/check_collinearity.R

View workflow job for this annotation

GitHub Actions / lint / lint

file=R/check_collinearity.R,line=574,col=3,[object_overwrite_linter] 'R' is an exported object from package 'tools'. Avoid re-using such symbols.
detR <- det(R)

result <- vector("numeric")
Expand Down
4 changes: 2 additions & 2 deletions tests/testthat/test-check_autocorrelation_simres.R
Original file line number Diff line number Diff line change
@@ -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")

Expand Down Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion tests/testthat/test-check_normality.R
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Comment thread
strengejacke marked this conversation as resolved.
m <- lm(mpg ~ wt + cyl + gear + disp, data = mtcars)
res <- simulate_residuals(m)
out <- check_normality(res)
Expand Down
2 changes: 1 addition & 1 deletion tests/testthat/test-check_outliers.R
Original file line number Diff line number Diff line change
Expand Up @@ -415,7 +415,7 @@


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(
Expand Down Expand Up @@ -462,7 +462,7 @@
test_that("check_outliers numeric, z-score", {
data(mtcars)
out <- check_outliers(mtcars$mpg, method = "zscore", threshold = 2)
expect_equal(which(as.numeric(out) == 1), c(18, 20))

Check warning on line 465 in tests/testthat/test-check_outliers.R

View workflow job for this annotation

GitHub Actions / lint-changed-files / lint-changed-files

file=tests/testthat/test-check_outliers.R,line=465,col=3,[expect_identical_linter] Use expect_identical(x, y) by default; resort to expect_equal() only when needed, e.g. when setting ignore_attr= or tolerance=.
})


Expand All @@ -471,9 +471,9 @@
data(Harman.5, package = "psych")
pc <- psych::principal(Harman.5, 2, rotate = "varimax")
out <- check_outliers(pc)
expect_equal(which(as.numeric(out) == 1), 5)

Check warning on line 474 in tests/testthat/test-check_outliers.R

View workflow job for this annotation

GitHub Actions / lint-changed-files / lint-changed-files

file=tests/testthat/test-check_outliers.R,line=474,col=3,[expect_identical_linter] Use expect_identical(x, y) by default; resort to expect_equal() only when needed, e.g. when setting ignore_attr= or tolerance=.
out <- check_outliers(pc, threshold = 0.1)
expect_equal(which(as.numeric(out) == 1), integer(0))

Check warning on line 476 in tests/testthat/test-check_outliers.R

View workflow job for this annotation

GitHub Actions / lint-changed-files / lint-changed-files

file=tests/testthat/test-check_outliers.R,line=476,col=3,[expect_identical_linter] Use expect_identical(x, y) by default; resort to expect_equal() only when needed, e.g. when setting ignore_attr= or tolerance=.
out <- check_outliers(pc, threshold = 0.02)
expect_equal(which(as.numeric(out) == 1), c(3, 5, 6, 8))

Check warning on line 478 in tests/testthat/test-check_outliers.R

View workflow job for this annotation

GitHub Actions / lint-changed-files / lint-changed-files

file=tests/testthat/test-check_outliers.R,line=478,col=3,[expect_identical_linter] Use expect_identical(x, y) by default; resort to expect_equal() only when needed, e.g. when setting ignore_attr= or tolerance=.
})
18 changes: 7 additions & 11 deletions tests/testthat/test-check_overdispersion.R
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@

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")

Expand Down Expand Up @@ -141,7 +141,7 @@

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)
Expand Down Expand Up @@ -181,7 +181,7 @@

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")
Comment thread
strengejacke marked this conversation as resolved.
skip_if_not(getRversion() >= "4.0.0")
data(Salamanders, package = "glmmTMB")

Expand All @@ -190,16 +190,12 @@
family = glmmTMB::genpois(),
data = Salamanders
)
expect_equal(

Check warning on line 193 in tests/testthat/test-check_overdispersion.R

View workflow job for this annotation

GitHub Actions / lint-changed-files / lint-changed-files

file=tests/testthat/test-check_overdispersion.R,line=193,col=3,[expect_identical_linter] Use expect_identical(x, y) by default; resort to expect_equal() only when needed, e.g. when setting ignore_attr= or tolerance=.
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"
)
)
})
2 changes: 1 addition & 1 deletion tests/testthat/test-check_residuals.R
Original file line number Diff line number Diff line change
@@ -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)
Expand Down
24 changes: 12 additions & 12 deletions tests/testthat/test-check_zeroinflation.R
Original file line number Diff line number Diff line change
Expand Up @@ -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")

Expand Down Expand Up @@ -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"
),
Expand All @@ -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")
Expand All @@ -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"
),
Expand All @@ -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)
Expand All @@ -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")
Comment thread
strengejacke marked this conversation as resolved.
skip_if_not(getRversion() >= "4.0.0")
data(Salamanders, package = "glmmTMB")

Expand All @@ -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"
),
Expand Down
Loading