diff --git a/DESCRIPTION b/DESCRIPTION index 2b7fe815a..abac13053 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,7 +1,7 @@ Type: Package Package: performance Title: Assessment of Regression Models Performance -Version: 0.12.4.1 +Version: 0.12.4.2 Authors@R: c(person(given = "Daniel", family = "Lüdecke", @@ -95,7 +95,7 @@ Suggests: cplm, dagitty, dbscan, - DHARMa, + DHARMa (>= 0.4.7), estimatr, fixest, flextable, @@ -129,7 +129,7 @@ Suggests: nonnest2, ordinal, parallel, - parameters (>= 0.21.6), + parameters (>= 0.22.0), patchwork, pscl, psych, diff --git a/NAMESPACE b/NAMESPACE index 08f6bcc15..d35d82547 100644 --- a/NAMESPACE +++ b/NAMESPACE @@ -566,7 +566,6 @@ export(check_multimodal) export(check_normality) export(check_outliers) export(check_overdispersion) -export(check_posterior_predictions) export(check_predictions) export(check_residuals) export(check_singularity) @@ -602,7 +601,6 @@ export(performance_rmse) export(performance_roc) export(performance_rse) export(performance_score) -export(posterior_predictive_check) export(print_html) export(print_md) export(r2) diff --git a/NEWS.md b/NEWS.md index 4f0984b48..9eb5ded26 100644 --- a/NEWS.md +++ b/NEWS.md @@ -1,3 +1,13 @@ +# performance 0.12.5 + +## Breaking changes + +* Deprecated arguments and alias-function-names have been removed. + +## Changes + +* Increased accuracy for `check_convergence()` for *glmmTMB* models. + # performance 0.12.4 ## Changes diff --git a/R/check_convergence.R b/R/check_convergence.R index 6f7628a12..f60a7e298 100644 --- a/R/check_convergence.R +++ b/R/check_convergence.R @@ -98,9 +98,10 @@ check_convergence.merMod <- function(x, tolerance = 0.001, ...) { #' @export -check_convergence.glmmTMB <- function(x, ...) { +check_convergence.glmmTMB <- function(x, tolerance = 0.001, ...) { # https://github.com/glmmTMB/glmmTMB/issues/275 - isTRUE(x$sdr$pdHess) + # https://stackoverflow.com/q/79110546/2094622 + isTRUE(all.equal(x$fit$convergence, 0, tolerance = tolerance)) && isTRUE(x$sdr$pdHess) } diff --git a/R/check_heterogeneity_bias.R b/R/check_heterogeneity_bias.R index 755f47dfa..2414873cc 100644 --- a/R/check_heterogeneity_bias.R +++ b/R/check_heterogeneity_bias.R @@ -27,7 +27,6 @@ #' @param nested Logical, if `TRUE`, the data is treated as nested. If `FALSE`, #' the data is treated as cross-classified. Only applies if `by` contains more #' than one variable. -#' @param group Deprecated. Use `by` instead. #' #' @seealso #' For further details, read the vignette @@ -44,15 +43,9 @@ #' iris$ID <- sample(1:4, nrow(iris), replace = TRUE) # fake-ID #' check_heterogeneity_bias(iris, select = c("Sepal.Length", "Petal.Length"), by = "ID") #' @export -check_heterogeneity_bias <- function(x, select = NULL, by = NULL, nested = FALSE, group = NULL) { +check_heterogeneity_bias <- function(x, select = NULL, by = NULL, nested = FALSE) { insight::check_if_installed("datawizard", minimum_version = "0.12.0") - ## TODO: deprecate later - if (!is.null(group)) { - insight::format_warning("Argument `group` is deprecated and will be removed in a future release. Please use `by` instead.") # nolint - by <- group - } - if (insight::is_model(x)) { by <- insight::find_random(x, split_nested = TRUE, flatten = TRUE) if (is.null(by)) { diff --git a/R/check_predictions.R b/R/check_predictions.R index fbc3b5eaf..c903f4309 100644 --- a/R/check_predictions.R +++ b/R/check_predictions.R @@ -423,26 +423,6 @@ pp_check.glmmTMB <- #' S3method(bayesplot::pp_check, BFBayesFactor) - -# aliases -------------------------- - -#' @rdname check_predictions -#' @export -posterior_predictive_check <- function(object, ...) { - .Deprecated("check_predictions()") - check_predictions(object, ...) -} - -#' @rdname check_predictions -#' @export -check_posterior_predictions <- function(object, ...) { - .Deprecated("check_predictions()") - check_predictions(object, ...) -} - - - - # methods ----------------------- diff --git a/R/performance_aicc.R b/R/performance_aicc.R index eb10bc40f..74041ac1b 100644 --- a/R/performance_aicc.R +++ b/R/performance_aicc.R @@ -28,7 +28,7 @@ #' scale. To get back to the original scale, the likelihood of the model is #' multiplied by the Jacobian/derivative of the transformation. #' -#' In case it is not possible to return the corrected AIC value, a waring +#' In case it is not possible to return the corrected AIC value, a warning #' is given that the corrected log-likelihood value could not be computed. #' #' @references diff --git a/R/simulate_residuals.R b/R/simulate_residuals.R index 7312c196f..1f58218c0 100644 --- a/R/simulate_residuals.R +++ b/R/simulate_residuals.R @@ -65,9 +65,10 @@ #' @export simulate_residuals <- function(x, iterations = 250, ...) { insight::check_if_installed("DHARMa") - # TODO (low priority): Note that DHARMa::simulateResiduals(x, ...) does its own checks for whether - # or not the model passed to it is supported, do we want to use this or do our - # own checks so we can supply our own error message? + # TODO (low priority): Note that DHARMa::simulateResiduals(x, ...) does its + # own checks for whether or not the model passed to it is supported, do we + # want to use this or do our own checks so we can supply our own error + # message? if (iterations < 2) { insight::format_error("`iterations` must be at least 2.") } diff --git a/man/check_heterogeneity_bias.Rd b/man/check_heterogeneity_bias.Rd index 40b2b66ca..db18ae7ef 100644 --- a/man/check_heterogeneity_bias.Rd +++ b/man/check_heterogeneity_bias.Rd @@ -4,13 +4,7 @@ \alias{check_heterogeneity_bias} \title{Check model predictor for heterogeneity bias} \usage{ -check_heterogeneity_bias( - x, - select = NULL, - by = NULL, - nested = FALSE, - group = NULL -) +check_heterogeneity_bias(x, select = NULL, by = NULL, nested = FALSE) } \arguments{ \item{x}{A data frame or a mixed model object.} @@ -41,8 +35,6 @@ See also section \emph{De-meaning for cross-classified designs} and \item{nested}{Logical, if \code{TRUE}, the data is treated as nested. If \code{FALSE}, the data is treated as cross-classified. Only applies if \code{by} contains more than one variable.} - -\item{group}{Deprecated. Use \code{by} instead.} } \description{ \code{check_heterogeneity_bias()} checks if model predictors or variables may diff --git a/man/check_predictions.Rd b/man/check_predictions.Rd index 148df6994..6c13fc0d5 100644 --- a/man/check_predictions.Rd +++ b/man/check_predictions.Rd @@ -3,8 +3,6 @@ \name{check_predictions} \alias{check_predictions} \alias{check_predictions.default} -\alias{posterior_predictive_check} -\alias{check_posterior_predictions} \title{Posterior predictive checks} \usage{ check_predictions(object, ...) @@ -19,10 +17,6 @@ check_predictions(object, ...) verbose = TRUE, ... ) - -posterior_predictive_check(object, ...) - -check_posterior_predictions(object, ...) } \arguments{ \item{object}{A statistical model.} diff --git a/man/performance_aicc.Rd b/man/performance_aicc.Rd index 529ee53aa..b1d9a1255 100644 --- a/man/performance_aicc.Rd +++ b/man/performance_aicc.Rd @@ -47,7 +47,7 @@ unlike \code{stats::AIC()}, returns the "corrected" AIC value on the original scale. To get back to the original scale, the likelihood of the model is multiplied by the Jacobian/derivative of the transformation. -In case it is not possible to return the corrected AIC value, a waring +In case it is not possible to return the corrected AIC value, a warning is given that the corrected log-likelihood value could not be computed. } \examples{ diff --git a/tests/testthat/test-check_zeroinflation.R b/tests/testthat/test-check_zeroinflation.R index 38a5c7726..53f8af9f5 100644 --- a/tests/testthat/test-check_zeroinflation.R +++ b/tests/testthat/test-check_zeroinflation.R @@ -111,22 +111,22 @@ test_that("check_zeroinflation, glmmTMB nbinom", { skip_if_not_installed("DHARMa") skip_on_cran() + data(Salamanders, package = "glmmTMB") + m <- glmmTMB::glmmTMB( + count ~ spp + mined + (1 | site), + family = glmmTMB::nbinom1(), + data = Salamanders + ) set.seed(1234) - dat <- DHARMa::createData(sampleSize = 1000) - fit <- suppressWarnings(glmmTMB::glmmTMB( - observedResponse ~ Environment1 + (1 | group), - data = dat, - family = glmmTMB::nbinom1() - )) expect_equal( - check_zeroinflation(fit), + check_zeroinflation(m), structure( list( - predicted.zeros = 462, - observed.zeros = 482L, - ratio = 0.95850622406639, + predicted.zeros = 389, + observed.zeros = 387L, + ratio = 1.00635658914729, tolerance = 0.1, - p.value = 0.776 + p.value = 0.944 ), class = "check_zi" ),