Skip to content

Commit

Permalink
add test
Browse files Browse the repository at this point in the history
  • Loading branch information
strengejacke committed Mar 2, 2024
1 parent 113abdc commit bd4fe6a
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 3 deletions.
6 changes: 3 additions & 3 deletions R/check_model_diagnostics.R
Original file line number Diff line number Diff line change
Expand Up @@ -53,10 +53,10 @@

if (is.null(res_) || all(is.na(res_))) {
if (verbose) {
if (!is.null(model_info$family)) {
fam <- paste0("`", model_info$family, "`")
} else {
if (is.null(model_info$family)) {
fam <- "model"

Check warning on line 57 in R/check_model_diagnostics.R

View check run for this annotation

Codecov / codecov/patch

R/check_model_diagnostics.R#L57

Added line #L57 was not covered by tests
} else {
fam <- paste0("`", model_info$family, "`")
}
insight::format_alert(
paste(
Expand Down
21 changes: 21 additions & 0 deletions tests/testthat/test-check_model.R
Original file line number Diff line number Diff line change
Expand Up @@ -51,3 +51,24 @@ test_that("`check_model()` works for quantreg", {
x <- check_model(qm, verbose = FALSE)
expect_s3_class(x, "check_model")
})

test_that("`check_model()` warnings for tweedie", {
skip_if_not_installed("glmmTMB")
skip_if_not_installed("lme4")
data(sleepstudy, package = "lme4")
set.seed(123)
d <- sleepstudy[sample.int(50), ]
m <- suppressWarnings(glmmTMB::glmmTMB(Reaction ~ Days,
data = d,
family = glmmTMB::tweedie
))
expect_message(
expect_message(
expect_message(
check_model(m, iterations = 1, verbose = TRUE),
regex = "Not enough model terms"
),
regex = "QQ plot could not"
)
)
})

0 comments on commit bd4fe6a

Please sign in to comment.