Skip to content

Commit

Permalink
test
Browse files Browse the repository at this point in the history
  • Loading branch information
strengejacke committed Oct 4, 2023
1 parent 7caea04 commit 6db5121
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions tests/testthat/test-check_heterogeneity_bias.R
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,19 @@ test_that("check_heterogeneity_bias", {
out <- check_heterogeneity_bias(iris, select = c("Sepal.Length", "Petal.Length"), group = "ID")
expect_equal(out, c("Sepal.Length", "Petal.Length"), ignore_attr = TRUE)
expect_output(print(out), "Possible heterogeneity bias due to following predictors: Sepal\\.Length, Petal\\.Length")

m <- lm(Sepal.Length ~ Petal.Length + Petal.Width + Species + ID, data = iris)
expect_error(
check_heterogeneity_bias(m, select = c("Sepal.Length", "Petal.Length"), group = "ID"),
regex = "no mixed model"
)

skip_if_not_installed("lme4")
m <- lme4::lmer(Sepal.Length ~ Petal.Length + Petal.Width + Species + (1 | ID), data = iris)
out <- check_heterogeneity_bias(m, select = c("Sepal.Length", "Petal.Length"), group = "ID")
expect_equal(out, c("Petal.Length", "Petal.Width", "Species"), ignore_attr = TRUE)
expect_output(
print(out),
"Possible heterogeneity bias due to following predictors: Petal\\.Length, Petal\\.Width, Species"
)
})

0 comments on commit 6db5121

Please sign in to comment.