Skip to content

Commit

Permalink
Merge branch 'main' into patch-1
Browse files Browse the repository at this point in the history
  • Loading branch information
strengejacke authored Sep 10, 2023
2 parents db9190e + 7b181e1 commit 96f85bc
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 13 deletions.
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.10.4.1
Version: 0.10.4.2
Authors@R:
c(person(given = "Daniel",
family = "Lüdecke",
Expand Down
3 changes: 3 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@
to fixed effects parameters and currently ignores random effects when detecting
nested models.

* `check_outliers()` for `"ICS"` method is now more stable and less likely to
fail.

# performance 0.10.4

## Changes to functions
Expand Down
33 changes: 21 additions & 12 deletions R/check_outliers.R
Original file line number Diff line number Diff line change
Expand Up @@ -1122,20 +1122,23 @@ check_outliers.data.frame <- function(x,
ID.names = ID.names
))

count.table <- datawizard::data_filter(
out$data_ics, "Outlier_ICS > 0.5"
)
# make sure we have valid results
if (!is.null(out)) {
count.table <- datawizard::data_filter(
out$data_ics, "Outlier_ICS > 0.5"
)

count.table <- datawizard::data_remove(
count.table, "ICS",
regex = TRUE, as_data_frame = TRUE
)
count.table <- datawizard::data_remove(
count.table, "ICS",
regex = TRUE, as_data_frame = TRUE
)

if (nrow(count.table) >= 1) {
count.table$n_ICS <- "(Multivariate)"
}
if (nrow(count.table) >= 1) {
count.table$n_ICS <- "(Multivariate)"
}

outlier_count$ics <- count.table
outlier_count$ics <- count.table
}
}

# OPTICS
Expand Down Expand Up @@ -1787,10 +1790,16 @@ check_outliers.metabin <- check_outliers.metagen
} else {
insight::print_color(sprintf("`check_outliers()` does not support models of class `%s`.\n", class(x)[1]), "red")
}
return(NULL)
}

# Get results
cutoff <- outliers@ics.dist.cutoff
cutoff <- .safe(outliers@ics.dist.cutoff)
# sanity check
if (is.null(cutoff)) {
insight::print_color("Could not detect cut-off for outliers.\n", "red")
return(NULL)
}
out$Distance_ICS <- outliers@ics.distances
out$Outlier_ICS <- as.numeric(out$Distance_ICS > cutoff)

Expand Down
3 changes: 3 additions & 0 deletions tests/testthat/test-check_outliers.R
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,9 @@ test_that("mcd which", {
## FIXME: Fails on CRAN/windows
# (current CRAN version rstan is not compatible with R > 4.2)
test_that("ics which", {
# suddenly fails on R Under development (unstable) (2023-09-07 r85102)
# gcc-13 (Debian 13.2.0-2) 13.2.0
skip_on_os("linux")
skip_if_not_installed("rstan", minimum_version = "2.26.0")
set.seed(42)
expect_identical(
Expand Down

0 comments on commit 96f85bc

Please sign in to comment.