Skip to content

Commit

Permalink
fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
strengejacke committed Mar 15, 2024
1 parent 15a660f commit 5842c15
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 7 deletions.
4 changes: 2 additions & 2 deletions R/check_residuals.R
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ check_residuals.default <- function(x, alternative = c("two.sided", "less", "gre
#' @export
check_residuals.performance_simres <- function(x, alternative = c("two.sided", "less", "greater"), ...) {
alternative <- match.arg(alternative)
ts <- suppressWarnings(
ts_test <- suppressWarnings(
stats::ks.test(
stats::residuals(x),
"punif",
Expand All @@ -51,7 +51,7 @@ check_residuals.performance_simres <- function(x, alternative = c("two.sided", "
)
)

p.val <- ts$p.value
p.val <- ts_test$p.value

attr(p.val, "data") <- x
attr(p.val, "object_name") <- insight::safe_deparse_symbol(substitute(x))
Expand Down
14 changes: 10 additions & 4 deletions R/check_zeroinflation.R
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,13 @@
#' @param x Fitted model of class `merMod`, `glmmTMB`, `glm`, or `glm.nb`
#' (package **MASS**).
#' @param tolerance The tolerance for the ratio of observed and predicted
#' zeros to considered as over- or underfitting zeros. A ratio
#' between 1 +/- `tolerance` is considered as OK, while a ratio
#' beyond or below this threshold would indicate over- or underfitting.
#' zeros to considered as over- or underfitting zeros. A ratio
#' between 1 +/- `tolerance` is considered as OK, while a ratio
#' beyond or below this threshold would indicate over- or underfitting.
#' @param alternative A character string specifying the alternative hypothesis.
#' @param ... Arguments passed down to [`simulate_residuals()`]. This only applies
#' for models with zero-inflation component, or for models of class `glmmTMB`
#' from `nbinom1` or `nbinom2` family.
#'
#' @return A list with information about the amount of predicted and observed
#' zeros in the outcome, as well as the ratio between these two values.
Expand All @@ -23,7 +27,9 @@
#' or hurdle models, the results from `check_zeroinflation()` are likely to be
#' unreliable. In such cases, it is recommended to use `simulate_residuals()`
#' first, followed by `check_zeroinflation()` to check for zero-inflation,
#' e.g.: `check_zeroinflation(simulate_residuals(model))`.
#' e.g.: `check_zeroinflation(simulate_residuals(model))`. Usually, such models
#' are detected automatically and `check_zeroinflation()` internally calls
#' `simulate_residuals()` if necessary.
#'
#' @family functions to check model assumptions and and assess model quality
#'
Expand Down
10 changes: 9 additions & 1 deletion man/check_zeroinflation.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 5842c15

Please sign in to comment.