diff --git a/R/check_predictions.R b/R/check_predictions.R index 121bb27ba..26faf6de2 100644 --- a/R/check_predictions.R +++ b/R/check_predictions.R @@ -197,10 +197,10 @@ pp_check.lm <- function(object, out <- .check_re_formula(out, object, iterations, re_formula, verbose, ...) # save information about model - if (!is.null(model_info)) { - minfo <- model_info - } else { + if (is.null(model_info)) { minfo <- insight::model_info(object) + } else { + minfo <- model_info } # glmmTMB returns column matrix for bernoulli @@ -215,9 +215,10 @@ pp_check.lm <- function(object, } if (is.null(out)) { - insight::format_error( - sprintf("Could not simulate responses. Maybe there is no `simulate()` for objects of class `%s`?", class(object)[1]) - ) + insight::format_error(sprintf( + "Could not simulate responses. Maybe there is no `simulate()` for objects of class `%s`?", + class(object)[1] + )) } # get response data, and response term, to check for transformations @@ -274,9 +275,10 @@ pp_check.glm <- function(object, out <- .check_re_formula(out, object, iterations, re_formula, verbose, ...) if (is.null(out)) { - insight::format_error( - sprintf("Could not simulate responses. Maybe there is no `simulate()` for objects of class `%s`?", class(object)[1]) - ) + insight::format_error(sprintf( + "Could not simulate responses. Maybe there is no `simulate()` for objects of class `%s`?", + class(object)[1] + )) } # get response data, and response term @@ -288,10 +290,10 @@ pp_check.glm <- function(object, out$y <- response[, 1] / rowSums(response, na.rm = TRUE) # safe information about model - if (!is.null(model_info)) { - minfo <- model_info - } else { + if (is.null(model_info)) { minfo <- insight::model_info(object) + } else { + minfo <- model_info } attr(out, "check_range") <- check_range @@ -363,14 +365,14 @@ print.performance_pp_check <- function(x, verbose = TRUE, ...) { if (is.numeric(original)) { if (min(replicated) > min(original)) { insight::print_color( - insight::format_message("Warning: Minimum value of original data is not included in the replicated data.", "Model may not capture the variation of the data."), + insight::format_message("Warning: Minimum value of original data is not included in the replicated data.", "Model may not capture the variation of the data."), # nolint "red" ) } if (max(replicated) < max(original)) { insight::print_color( - insight::format_message("Warning: Maximum value of original data is not included in the replicated data.", "Model may not capture the variation of the data."), + insight::format_message("Warning: Maximum value of original data is not included in the replicated data.", "Model may not capture the variation of the data."), # nolint "red" ) } diff --git a/tests/testthat/test-check_predictions.R b/tests/testthat/test-check_predictions.R index 345697285..a840894dc 100644 --- a/tests/testthat/test-check_predictions.R +++ b/tests/testthat/test-check_predictions.R @@ -119,8 +119,6 @@ test_that("check_predictions, glm, binomial", { set.seed(1) out4 <- check_predictions(mod4) - -dput(head(out4$sim_1)) expect_equal(head(out1$sim_1), c(1, 0.9, 0.9, 0.8, 1, 0.8), tolerance = 1e-4) expect_false(attributes(out1)$model_info$is_bernoulli) expect_equal(head(out2$sim_1), c(1, 0.9, 0.9, 0.8, 1, 0.8), tolerance = 1e-4)