From 05336ec12f75b5eb696f698c97028ae46dee0b00 Mon Sep 17 00:00:00 2001 From: Daniel Date: Fri, 29 Sep 2023 13:30:12 +0200 Subject: [PATCH] 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) {