Skip to content

Commit 7314c28

Browse files
committed
docs, test
1 parent 9417ce0 commit 7314c28

5 files changed

+25
-8
lines changed

R/check_residuals.R

+2-1
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,8 @@
1919
#'
2020
#' @inheritSection simulate_residuals Tests based on simulated residuals
2121
#'
22-
#' @seealso [`simulate_residuals()`] and [`check_predictions()`].
22+
#' @seealso [`simulate_residuals()`], [`check_zeroinflation()`],
23+
#' [`check_overdispersion()`] and [`check_predictions()`].
2324
#'
2425
#' @return The p-value of the test statistics.
2526
#'

R/simulate_residuals.R

+6-4
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,8 @@
2020
#' [`check_residuals()`]. The returned object is of class `DHARMa` and
2121
#' `performance_simres`.
2222
#'
23-
#' @seealso [`check_residuals()`] and [`check_predictions()`].
23+
#' @seealso [`check_residuals()`], [`check_zeroinflation()`],
24+
#' [`check_overdispersion()`] and [`check_predictions()`].
2425
#'
2526
#' @details This function is a small wrapper around [`DHARMa::simulateResiduals()`].
2627
#' It basically only sets `plot = FALSE` and adds an additional class attribute
@@ -88,9 +89,10 @@ print.performance_simres <- function(x, ...) {
8889
# DHARMa's method.
8990
msg <- paste0(
9091
"Simulated residuals from a model of class `", class(x$fittedModel)[1],
91-
"` based on ", x$nSim, " simulations. Use `check_residuals()` to check ",
92-
"uniformity of residuals. It is recommended to refer to `?DHARMa::simulateResiudals`",
93-
" and `vignette(\"DHARMa\")` for more information about different settings",
92+
"` based on ", x$nSim, " simulations. Use `check_residuals()` to check",
93+
" uniformity of residuals or `residuals()` to extract simulated residuals.",
94+
" It is recommended to refer to `?DHARMa::simulateResiudals` and",
95+
" `vignette(\"DHARMa\")` for more information about different settings",
9496
" in particular situations or for particular models.\n"
9597
)
9698
cat(insight::format_message(msg))

man/check_residuals.Rd

+2-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

man/simulate_residuals.Rd

+2-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

tests/testthat/test-check_residuals.R

+13-1
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,22 @@
1-
test_that("check_singularity, lme4", {
1+
test_that("check_residuals", {
22
skip_on_cran()
33
skip_if_not_installed("DHARMa")
44
set.seed(123)
55
dat <- DHARMa::createData(sampleSize = 100, overdispersion = 0.5, family = poisson())
66
m <- glm(observedResponse ~ Environment1, family = poisson(), data = dat)
77
res <- simulate_residuals(m)
8+
expect_identical(
9+
capture.output(print(res)),
10+
c(
11+
"Simulated residuals from a model of class `glm` based on 250",
12+
" simulations. Use `check_residuals()` to check uniformity of residuals or",
13+
" `residuals()` to extract simulated residuals. It is recommended to refer",
14+
" to `?DHARMa::simulateResiudals` and `vignette(\"DHARMa\")` for more",
15+
" information about different settings in particular situations or for",
16+
" particular models."
17+
)
18+
)
19+
820
out <- check_residuals(res)
921
expect_equal(out, 0.01884602, ignore_attr = TRUE, tolerance = 1e-4)
1022
expect_identical(

0 commit comments

Comments
 (0)