diff --git a/R/model_performance.mixed.R b/R/model_performance.mixed.R index 2c9d0ea1b..499196dab 100644 --- a/R/model_performance.mixed.R +++ b/R/model_performance.mixed.R @@ -35,11 +35,9 @@ #' on returned indices. #' } #' -#' @examples -#' if (require("lme4")) { -#' model <- lmer(Petal.Length ~ Sepal.Length + (1 | Species), data = iris) -#' model_performance(model) -#' } +#' @examplesIf require("lme4") +#' model <- lme4::lmer(Petal.Length ~ Sepal.Length + (1 | Species), data = iris) +#' model_performance(model) #' @export model_performance.merMod <- function(model, metrics = "all", diff --git a/R/performance_rmse.R b/R/performance_rmse.R index b5044044f..0cc5eac90 100644 --- a/R/performance_rmse.R +++ b/R/performance_rmse.R @@ -20,16 +20,15 @@ #' #' @return Numeric, the root mean squared error. #' -#' @examples -#' if (require("nlme")) { -#' m <- lme(distance ~ age, data = Orthodont) +#' @examplesIf require("nlme") +#' data(Orthodont, package = "nlme") +#' m <- nlme::lme(distance ~ age, data = Orthodont) #' -#' # RMSE -#' performance_rmse(m, normalized = FALSE) +#' # RMSE +#' performance_rmse(m, normalized = FALSE) #' -#' # normalized RMSE -#' performance_rmse(m, normalized = TRUE) -#' } +#' # normalized RMSE +#' performance_rmse(m, normalized = TRUE) #' @export performance_rmse <- function(model, normalized = FALSE, verbose = TRUE) { tryCatch( diff --git a/R/performance_score.R b/R/performance_score.R index 7c606c71f..58a701069 100644 --- a/R/performance_score.R +++ b/R/performance_score.R @@ -32,7 +32,7 @@ #' #' @seealso [`performance_logloss()`] #' -#' @examples +#' @examplesIf require("glmmTMB") #' ## Dobson (1990) Page 93: Randomized Controlled Trial : #' counts <- c(18, 17, 15, 20, 10, 20, 25, 13, 12) #' outcome <- gl(3, 1, 9) @@ -41,17 +41,15 @@ #' #' performance_score(model) #' \dontrun{ -#' if (require("glmmTMB")) { -#' data(Salamanders) -#' model <- glmmTMB( -#' count ~ spp + mined + (1 | site), -#' zi = ~ spp + mined, -#' family = nbinom2(), -#' data = Salamanders -#' ) +#' data(Salamanders, package = "glmmTMB") +#' model <- glmmTMB::glmmTMB( +#' count ~ spp + mined + (1 | site), +#' zi = ~ spp + mined, +#' family = nbinom2(), +#' data = Salamanders +#' ) #' -#' performance_score(model) -#' } +#' performance_score(model) #' } #' @export performance_score <- function(model, verbose = TRUE, ...) { diff --git a/man/model_performance.merMod.Rd b/man/model_performance.merMod.Rd index 2145ec379..519f1ee0a 100644 --- a/man/model_performance.merMod.Rd +++ b/man/model_performance.merMod.Rd @@ -58,8 +58,8 @@ on returned indices. } } \examples{ -if (require("lme4")) { - model <- lmer(Petal.Length ~ Sepal.Length + (1 | Species), data = iris) - model_performance(model) -} +\dontshow{if (require("lme4")) (if (getRversion() >= "3.4") withAutoprint else force)(\{ # examplesIf} +model <- lme4::lmer(Petal.Length ~ Sepal.Length + (1 | Species), data = iris) +model_performance(model) +\dontshow{\}) # examplesIf} } diff --git a/man/performance_rmse.Rd b/man/performance_rmse.Rd index cd9b84e87..bea4534b5 100644 --- a/man/performance_rmse.Rd +++ b/man/performance_rmse.Rd @@ -35,13 +35,14 @@ range of the response variable. Hence, lower values indicate less residual variance. } \examples{ -if (require("nlme")) { - m <- lme(distance ~ age, data = Orthodont) +\dontshow{if (require("nlme")) (if (getRversion() >= "3.4") withAutoprint else force)(\{ # examplesIf} +data(Orthodont, package = "nlme") +m <- nlme::lme(distance ~ age, data = Orthodont) - # RMSE - performance_rmse(m, normalized = FALSE) +# RMSE +performance_rmse(m, normalized = FALSE) - # normalized RMSE - performance_rmse(m, normalized = TRUE) -} +# normalized RMSE +performance_rmse(m, normalized = TRUE) +\dontshow{\}) # examplesIf} } diff --git a/man/performance_score.Rd b/man/performance_score.Rd index 2dc85faf5..162f3ed13 100644 --- a/man/performance_score.Rd +++ b/man/performance_score.Rd @@ -38,6 +38,7 @@ Code is partially based on \href{https://drizopoulos.github.io/GLMMadaptive/reference/scoring_rules.html}{GLMMadaptive::scoring_rules()}. } \examples{ +\dontshow{if (require("glmmTMB")) (if (getRversion() >= "3.4") withAutoprint else force)(\{ # examplesIf} ## Dobson (1990) Page 93: Randomized Controlled Trial : counts <- c(18, 17, 15, 20, 10, 20, 25, 13, 12) outcome <- gl(3, 1, 9) @@ -46,18 +47,17 @@ model <- glm(counts ~ outcome + treatment, family = poisson()) performance_score(model) \dontrun{ -if (require("glmmTMB")) { - data(Salamanders) - model <- glmmTMB( - count ~ spp + mined + (1 | site), - zi = ~ spp + mined, - family = nbinom2(), - data = Salamanders - ) +data(Salamanders, package = "glmmTMB") +model <- glmmTMB::glmmTMB( + count ~ spp + mined + (1 | site), + zi = ~ spp + mined, + family = nbinom2(), + data = Salamanders +) - performance_score(model) -} +performance_score(model) } +\dontshow{\}) # examplesIf} } \references{ Carvalho, A. (2016). An overview of applications of proper scoring rules.