-
-
Notifications
You must be signed in to change notification settings - Fork 87
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
4c805bf
commit bb1a2f3
Showing
1 changed file
with
22 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |