From b720518aab74eb9d8958dbddfd0e38d5b3b420cd Mon Sep 17 00:00:00 2001 From: Daniel Date: Tue, 22 Oct 2024 11:23:36 +0200 Subject: [PATCH 1/6] Remove deprecated funs and args --- DESCRIPTION | 2 +- NAMESPACE | 2 -- NEWS.md | 10 ++++++++++ R/check_convergence.R | 5 +++-- R/check_heterogeneity_bias.R | 9 +-------- R/check_predictions.R | 20 -------------------- man/check_heterogeneity_bias.Rd | 10 +--------- man/check_predictions.Rd | 6 ------ 8 files changed, 16 insertions(+), 48 deletions(-) diff --git a/DESCRIPTION b/DESCRIPTION index 2b7fe815a..c3cc4e65f 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", 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/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.} From 1a52409c8b0c058671f3d1968b48376fb305558e Mon Sep 17 00:00:00 2001 From: Daniel Date: Tue, 22 Oct 2024 11:25:58 +0200 Subject: [PATCH 2/6] comment --- R/simulate_residuals.R | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) 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.") } From 0f32a2b68e79811da4e4aaa3ad55ab5dd3b77ad3 Mon Sep 17 00:00:00 2001 From: Daniel Date: Tue, 22 Oct 2024 11:53:22 +0200 Subject: [PATCH 3/6] update test --- tests/testthat/test-check_zeroinflation.R | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/tests/testthat/test-check_zeroinflation.R b/tests/testthat/test-check_zeroinflation.R index 38a5c7726..95344933d 100644 --- a/tests/testthat/test-check_zeroinflation.R +++ b/tests/testthat/test-check_zeroinflation.R @@ -122,11 +122,11 @@ test_that("check_zeroinflation, glmmTMB nbinom", { check_zeroinflation(fit), structure( list( - predicted.zeros = 462, - observed.zeros = 482L, - ratio = 0.95850622406639, + predicted.zeros = 424, + observed.zeros = 401L, + ratio = 1.05636907730673, tolerance = 0.1, - p.value = 0.776 + p.value = 0.784 ), class = "check_zi" ), From e66edad23f333480a61b6e6d23b4579c599f4a7c Mon Sep 17 00:00:00 2001 From: Daniel Date: Tue, 22 Oct 2024 12:17:43 +0200 Subject: [PATCH 4/6] suggest --- DESCRIPTION | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/DESCRIPTION b/DESCRIPTION index c3cc4e65f..abac13053 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -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, From ab79c7ff1be094a098cb6fa89d12cde934251d99 Mon Sep 17 00:00:00 2001 From: Daniel Date: Tue, 22 Oct 2024 12:20:17 +0200 Subject: [PATCH 5/6] update test --- tests/testthat/test-check_zeroinflation.R | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/tests/testthat/test-check_zeroinflation.R b/tests/testthat/test-check_zeroinflation.R index 95344933d..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 = 424, - observed.zeros = 401L, - ratio = 1.05636907730673, + predicted.zeros = 389, + observed.zeros = 387L, + ratio = 1.00635658914729, tolerance = 0.1, - p.value = 0.784 + p.value = 0.944 ), class = "check_zi" ), From 31483bc91eaa4aee92f633b2d6d544655a4850dd Mon Sep 17 00:00:00 2001 From: Daniel Date: Tue, 22 Oct 2024 12:24:59 +0200 Subject: [PATCH 6/6] typo --- R/performance_aicc.R | 2 +- man/performance_aicc.Rd | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) 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/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{