From 39e098b8cc915295e7d5c51a473fbd8b4e44249b Mon Sep 17 00:00:00 2001 From: Indrajeet Patil Date: Thu, 28 Sep 2023 13:10:51 +0200 Subject: [PATCH 1/3] Update html-5-check.yaml --- .github/workflows/html-5-check.yaml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/html-5-check.yaml b/.github/workflows/html-5-check.yaml index 1439a3228..f25b4eeaf 100644 --- a/.github/workflows/html-5-check.yaml +++ b/.github/workflows/html-5-check.yaml @@ -6,8 +6,8 @@ on: pull_request: branches: [main, master] -name: HTML5 check +name: html-5-check jobs: - HTML5-check: + html-5-check: uses: easystats/workflows/.github/workflows/html-5-check.yaml@main From 05336ec12f75b5eb696f698c97028ae46dee0b00 Mon Sep 17 00:00:00 2001 From: Daniel Date: Fri, 29 Sep 2023 13:30:12 +0200 Subject: [PATCH 2/3] Error: check_model() not implemented for models of class lm yet (#630) --- DESCRIPTION | 2 +- NEWS.md | 5 +++++ R/check_model_diagnostics.R | 8 ++++---- 3 files changed, 10 insertions(+), 5 deletions(-) diff --git a/DESCRIPTION b/DESCRIPTION index 3b95351d9..19bada6a3 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,7 +1,7 @@ Type: Package Package: performance Title: Assessment of Regression Models Performance -Version: 0.10.5.4 +Version: 0.10.5.5 Authors@R: c(person(given = "Daniel", family = "Lüdecke", diff --git a/NEWS.md b/NEWS.md index 40e57d346..47fad4e59 100644 --- a/NEWS.md +++ b/NEWS.md @@ -7,6 +7,11 @@ the previous method, which used `parallel::detectCores()`. Now you should set the number of cores via `options(mc.cores = 4)`. +## Bug fixes + +* Fixed issues is `check_model()` for models that used data sets with + variables of class `"haven_labelled"`. + # performance 0.10.5 ## Changes to functions diff --git a/R/check_model_diagnostics.R b/R/check_model_diagnostics.R index 3b86799cc..371e32609 100644 --- a/R/check_model_diagnostics.R +++ b/R/check_model_diagnostics.R @@ -153,7 +153,7 @@ # prepare data for normality of residuals plot ---------------------------------- .diag_norm <- function(model, verbose = TRUE) { - r <- try(stats::residuals(model), silent = TRUE) + r <- try(as.numeric(stats::residuals(model)), silent = TRUE) if (inherits(r, "try-error")) { insight::format_alert(sprintf("Non-normality of residuals could not be computed. Cannot extract residuals from objects of class '%s'.", class(model)[1])) @@ -183,7 +183,7 @@ n_params <- tryCatch(model$rank, error = function(e) insight::n_parameters(model)) infl <- stats::influence(model, do.coef = FALSE) - resid <- insight::get_residuals(model) + resid <- as.numeric(insight::get_residuals(model)) std_resid <- tryCatch(stats::rstandard(model, infl), error = function(e) resid) @@ -212,8 +212,8 @@ ncv <- tryCatch( { data.frame( - x = stats::fitted(model), - y = stats::residuals(model) + x = as.numeric(stats::fitted(model)), + y = as.numeric(stats::residuals(model)) ) }, error = function(e) { From 198578d01e4e85cb1907761b861a59f57ef945bd Mon Sep 17 00:00:00 2001 From: Daniel Date: Fri, 29 Sep 2023 17:34:27 +0200 Subject: [PATCH 3/3] lintr --- R/check_model_diagnostics.R | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/R/check_model_diagnostics.R b/R/check_model_diagnostics.R index 371e32609..46a64f9c2 100644 --- a/R/check_model_diagnostics.R +++ b/R/check_model_diagnostics.R @@ -174,10 +174,10 @@ if (inherits(model, "lm", which = TRUE) == 1) { cook_levels <- round(stats::qf(0.5, s$fstatistic[2], s$fstatistic[3]), 2) - } else if (!is.null(threshold)) { - cook_levels <- threshold - } else { + } else if (is.null(threshold)) { cook_levels <- c(0.5, 1) + } else { + cook_levels <- threshold } n_params <- tryCatch(model$rank, error = function(e) insight::n_parameters(model))