Skip to content

Commit

Permalink
draft check_residuals()
Browse files Browse the repository at this point in the history
  • Loading branch information
mccarthy-m-g committed Oct 26, 2023
1 parent 4c805bf commit bb1a2f3
Showing 1 changed file with 22 additions and 0 deletions.
22 changes: 22 additions & 0 deletions R/check_residuals.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
#' Check uniformity of simulated residuals
#'
#' `check_residuals()` checks generalized linear (mixed) models for uniformity
#' of randomized quantile residuals, which can be used to identify typical model
#' misspecification problems, such as over/underdispersion, zero-inflation, and
#' residual spatial and temporal autocorrelation.
#'
#' @export
check_residuals <- function(x, ...) {
# TODO: This should be an S3 method instead of using ifelse
if (any(class(x) %in% c("performance_simres", "DHARMa"))) {
# tests if the overall distribution conforms to expectations; equivalent to:
# ks.test(residuals(simulated_residuals), "punif")
DHARMa::testUniformity(x, plot = FALSE, ...)
} else {
stop("Unsupported input")
}
}

# methods ------------------------------

# TODO: Add print method

0 comments on commit bb1a2f3

Please sign in to comment.