Skip to content

Commit

Permalink
Merge branch 'main' into strengejacke/issue606
Browse files Browse the repository at this point in the history
  • Loading branch information
strengejacke committed Sep 10, 2023
2 parents e5b2768 + 0a620b9 commit 678f022
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 14 deletions.
2 changes: 1 addition & 1 deletion R/check_collinearity.R
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@
#' examples in R and Stan. 2nd edition. Chapman and Hall/CRC.
#'
#' - Vanhove, J. (2019). Collinearity isn't a disease that needs curing.
#' [webpage](https://janhove.github.io/analysis/2019/09/11/collinearity)
#' [webpage](https://janhove.github.io/posts/2019-09-11-collinearity/)
#'
#' - Zuur AF, Ieno EN, Elphick CS. A protocol for data exploration to avoid
#' common statistical problems: Data exploration. Methods in Ecology and
Expand Down
2 changes: 1 addition & 1 deletion man/check_collinearity.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

24 changes: 12 additions & 12 deletions tests/testthat/test-check_outliers.R
Original file line number Diff line number Diff line change
@@ -1,7 +1,3 @@
skip_if_not_installed("bigutilsr")
skip_if_not_installed("ICS")
skip_if_not_installed("dbscan")

test_that("zscore negative threshold", {
expect_error(
check_outliers(mtcars$mpg, method = "zscore", threshold = -1),
Expand Down Expand Up @@ -80,16 +76,15 @@ test_that("mahalanobis which", {
})

test_that("mahalanobis_robust which", {
skip_if_not_installed("bigutilsr")
expect_identical(
which(check_outliers(mtcars, method = "mahalanobis_robust", threshold = 25)),
as.integer(c(7, 9, 21, 24, 27, 28, 29, 31))
)
})

## FIXME: Fails on CRAN/windows
# (should be fixed but not clear why method mcd needs a seed;
# there should not be an element of randomness to it I think)
test_that("mcd which", {
# (not clear why method mcd needs a seed)
set.seed(42)
expect_identical(
tail(which(check_outliers(mtcars[1:4], method = "mcd", threshold = 45))),
Expand All @@ -98,27 +93,28 @@ 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)
skip_on_cran()
skip_if_not_installed("ICS")
skip_if_not_installed("ICSOutlier")
expect_identical(
which(check_outliers(mtcars, method = "ics", threshold = 0.001)),
as.integer(c(9, 29))
)
})

test_that("optics which", {
skip_if_not_installed("dbscan")
expect_identical(
which(check_outliers(mtcars, method = "optics", threshold = 14)),
as.integer(c(5, 7, 15, 16, 17, 24, 25, 29, 31))
)
})

test_that("lof which", {
skip_if_not_installed("dbscan")
expect_identical(
which(check_outliers(mtcars, method = "lof", threshold = 0.005)),
31L
Expand Down Expand Up @@ -193,6 +189,7 @@ test_that("multiple methods which", {

# We exclude method ics because it is too slow
test_that("all methods which", {
skip_if_not_installed("bigutilsr")
expect_identical(
which(check_outliers(mtcars,
method = c(
Expand All @@ -214,6 +211,7 @@ test_that("all methods which", {


test_that("multiple methods with ID", {
skip_if_not_installed("bigutilsr")
data <- datawizard::rownames_as_column(mtcars, var = "car")
x <- attributes(check_outliers(data,
method = c(
Expand Down Expand Up @@ -261,6 +259,7 @@ test_that("cook which", {
# })

test_that("cook multiple methods which", {
skip_if_not_installed("dbscan")
model <- lm(disp ~ mpg + hp, data = mtcars)
expect_identical(
which(check_outliers(model, method = c("cook", "optics", "lof"))),
Expand All @@ -269,6 +268,7 @@ test_that("cook multiple methods which", {
})

test_that("pareto which", {
skip_if_not_installed("dbscan")
skip_if_not_installed("rstanarm")
set.seed(123)
model <- rstanarm::stan_glm(mpg ~ qsec + wt, data = mtcars, refresh = 0)
Expand All @@ -281,6 +281,7 @@ test_that("pareto which", {
})

test_that("pareto multiple methods which", {
skip_if_not_installed("dbscan")
skip_if_not_installed("rstanarm")
set.seed(123)
model <- rstanarm::stan_glm(mpg ~ qsec + wt, data = mtcars, refresh = 0)
Expand Down Expand Up @@ -310,7 +311,6 @@ test_that("BayesFactor which", {
# 7. Next, we test grouped output

test_that("cook multiple methods which", {
skip_if_not_installed("datawizard")
iris2 <- datawizard::data_group(iris, "Species")
z <- attributes(check_outliers(iris2, method = c("zscore", "iqr")))
expect_named(
Expand Down

0 comments on commit 678f022

Please sign in to comment.