From 05202d258558a60603e45a9fee1a08169dddc74e Mon Sep 17 00:00:00 2001 From: Daniel Date: Thu, 14 Sep 2023 18:40:59 +0200 Subject: [PATCH] suppress Warnings --- R/check_convergence.R | 38 +++++++++++++++++--------------------- man/check_convergence.Rd | 38 ++++++++++++++++++-------------------- 2 files changed, 35 insertions(+), 41 deletions(-) diff --git a/R/check_convergence.R b/R/check_convergence.R index 06d0428a0..25faa7277 100644 --- a/R/check_convergence.R +++ b/R/check_convergence.R @@ -46,31 +46,27 @@ #' #' @family functions to check model assumptions and and assess model quality #' -#' @examples -#' if (require("lme4")) { -#' data(cbpp) -#' set.seed(1) -#' cbpp$x <- rnorm(nrow(cbpp)) -#' cbpp$x2 <- runif(nrow(cbpp)) +#' @examplesIf require("lme4") && require("glmmTMB") +#' data(cbpp, package = "lme4") +#' set.seed(1) +#' cbpp$x <- rnorm(nrow(cbpp)) +#' cbpp$x2 <- runif(nrow(cbpp)) #' -#' model <- glmer( -#' cbind(incidence, size - incidence) ~ period + x + x2 + (1 + x | herd), -#' data = cbpp, -#' family = binomial() -#' ) +#' model <- lm4::glmer( +#' cbind(incidence, size - incidence) ~ period + x + x2 + (1 + x | herd), +#' data = cbpp, +#' family = binomial() +#' ) #' -#' check_convergence(model) -#' } +#' check_convergence(model) #' #' \dontrun{ -#' if (require("glmmTMB")) { -#' model <- glmmTMB( -#' Sepal.Length ~ poly(Petal.Width, 4) * poly(Petal.Length, 4) + -#' (1 + poly(Petal.Width, 4) | Species), -#' data = iris -#' ) -#' check_convergence(model) -#' } +#' model <- suppressWarnings(glmmTMB::glmmTMB( +#' Sepal.Length ~ poly(Petal.Width, 4) * poly(Petal.Length, 4) + +#' (1 + poly(Petal.Width, 4) | Species), +#' data = iris +#' )) +#' check_convergence(model) #' } #' @export check_convergence <- function(x, tolerance = 0.001, ...) { diff --git a/man/check_convergence.Rd b/man/check_convergence.Rd index 501b66704..b5d42cc64 100644 --- a/man/check_convergence.Rd +++ b/man/check_convergence.Rd @@ -63,31 +63,29 @@ or not. } \examples{ -if (require("lme4")) { - data(cbpp) - set.seed(1) - cbpp$x <- rnorm(nrow(cbpp)) - cbpp$x2 <- runif(nrow(cbpp)) +\dontshow{if (require("lme4") && require("glmmTMB")) (if (getRversion() >= "3.4") withAutoprint else force)(\{ # examplesIf} +data(cbpp, package = "lme4") +set.seed(1) +cbpp$x <- rnorm(nrow(cbpp)) +cbpp$x2 <- runif(nrow(cbpp)) - model <- glmer( - cbind(incidence, size - incidence) ~ period + x + x2 + (1 + x | herd), - data = cbpp, - family = binomial() - ) +model <- lm4::glmer( + cbind(incidence, size - incidence) ~ period + x + x2 + (1 + x | herd), + data = cbpp, + family = binomial() +) - check_convergence(model) -} +check_convergence(model) \dontrun{ -if (require("glmmTMB")) { - model <- glmmTMB( - Sepal.Length ~ poly(Petal.Width, 4) * poly(Petal.Length, 4) + - (1 + poly(Petal.Width, 4) | Species), - data = iris - ) - check_convergence(model) -} +model <- suppressWarnings(glmmTMB::glmmTMB( + Sepal.Length ~ poly(Petal.Width, 4) * poly(Petal.Length, 4) + + (1 + poly(Petal.Width, 4) | Species), + data = iris +)) +check_convergence(model) } +\dontshow{\}) # examplesIf} } \seealso{ Other functions to check model assumptions and and assess model quality: