From 6c95f678d7034807453676595c710fe85942dc3c Mon Sep 17 00:00:00 2001 From: Daniel Date: Fri, 15 Sep 2023 12:14:52 +0200 Subject: [PATCH 1/3] try to reduce warnings in examples and use examplesIf --- R/looic.R | 4 ++-- R/model_performance.bayesian.R | 10 +++++----- R/r2_bayes.R | 4 ++-- man/looic.Rd | 4 ++-- man/model_performance.stanreg.Rd | 10 +++++----- man/r2_bayes.Rd | 4 ++-- 6 files changed, 18 insertions(+), 18 deletions(-) diff --git a/R/looic.R b/R/looic.R index d1c7fc49a..8f0a0c66e 100644 --- a/R/looic.R +++ b/R/looic.R @@ -12,13 +12,13 @@ #' @return A list with four elements, the ELPD, LOOIC and their standard errors. #' #' @examplesIf require("rstanarm") -#' model <- rstanarm::stan_glm( +#' model <- suppressWarnings(rstanarm::stan_glm( #' mpg ~ wt + cyl, #' data = mtcars, #' chains = 1, #' iter = 500, #' refresh = 0 -#' ) +#' )) #' looic(model) #' @export looic <- function(model, verbose = TRUE) { diff --git a/R/model_performance.bayesian.R b/R/model_performance.bayesian.R index 576c8abcd..6421206b2 100644 --- a/R/model_performance.bayesian.R +++ b/R/model_performance.bayesian.R @@ -42,25 +42,25 @@ #' #' @examplesIf require("rstanarm") && require("rstantools") && require("BayesFactor") #' \dontrun{ -#' model <- rstanarm::stan_glm( +#' model <- suppressWarnings(rstanarm::stan_glm( #' mpg ~ wt + cyl, #' data = mtcars, #' chains = 1, #' iter = 500, #' refresh = 0 -#' ) +#' )) #' model_performance(model) #' -#' model <- stan_glmer( +#' model <- suppressWarnings(rstanarm::stan_glmer( #' mpg ~ wt + cyl + (1 | gear), #' data = mtcars, #' chains = 1, #' iter = 500, #' refresh = 0 -#' ) +#' )) #' model_performance(model) #' -#' model <- generalTestBF(carb ~ am + mpg, mtcars) +#' model <- BayesFactor::generalTestBF(carb ~ am + mpg, mtcars) #' #' model_performance(model) #' model_performance(model[3]) diff --git a/R/r2_bayes.R b/R/r2_bayes.R index 506c4dde6..c565832c9 100644 --- a/R/r2_bayes.R +++ b/R/r2_bayes.R @@ -43,13 +43,13 @@ #' )) #' r2_bayes(model) #' -#' model <- stan_lmer( +#' model <- suppressWarnings(stan_lmer( #' Petal.Length ~ Petal.Width + (1 | Species), #' data = iris, #' chains = 1, #' iter = 500, #' refresh = 0 -#' ) +#' )) #' r2_bayes(model) #' } #' diff --git a/man/looic.Rd b/man/looic.Rd index 3285be1fc..742ac3482 100644 --- a/man/looic.Rd +++ b/man/looic.Rd @@ -22,13 +22,13 @@ indicative of a better fit. } \examples{ \dontshow{if (require("rstanarm")) (if (getRversion() >= "3.4") withAutoprint else force)(\{ # examplesIf} -model <- rstanarm::stan_glm( +model <- suppressWarnings(rstanarm::stan_glm( mpg ~ wt + cyl, data = mtcars, chains = 1, iter = 500, refresh = 0 -) +)) looic(model) \dontshow{\}) # examplesIf} } diff --git a/man/model_performance.stanreg.Rd b/man/model_performance.stanreg.Rd index 4c26214a5..7398b9f1c 100644 --- a/man/model_performance.stanreg.Rd +++ b/man/model_performance.stanreg.Rd @@ -62,25 +62,25 @@ values mean better fit. See \code{?loo::waic}. \examples{ \dontshow{if (require("rstanarm") && require("rstantools") && require("BayesFactor")) (if (getRversion() >= "3.4") withAutoprint else force)(\{ # examplesIf} \dontrun{ -model <- rstanarm::stan_glm( +model <- suppressWarnings(rstanarm::stan_glm( mpg ~ wt + cyl, data = mtcars, chains = 1, iter = 500, refresh = 0 -) +)) model_performance(model) -model <- stan_glmer( +model <- suppressWarnings(rstanarm::stan_glmer( mpg ~ wt + cyl + (1 | gear), data = mtcars, chains = 1, iter = 500, refresh = 0 -) +)) model_performance(model) -model <- generalTestBF(carb ~ am + mpg, mtcars) +model <- BayesFactor::generalTestBF(carb ~ am + mpg, mtcars) model_performance(model) model_performance(model[3]) diff --git a/man/r2_bayes.Rd b/man/r2_bayes.Rd index f78f38bf6..387202ca9 100644 --- a/man/r2_bayes.Rd +++ b/man/r2_bayes.Rd @@ -74,13 +74,13 @@ if (require("rstanarm") && require("rstantools")) { )) r2_bayes(model) - model <- stan_lmer( + model <- suppressWarnings(stan_lmer( Petal.Length ~ Petal.Width + (1 | Species), data = iris, chains = 1, iter = 500, refresh = 0 - ) + )) r2_bayes(model) } From 9c0359ca30b33d05d0923137d58865cc4511ecf7 Mon Sep 17 00:00:00 2001 From: Daniel Date: Fri, 15 Sep 2023 12:29:23 +0200 Subject: [PATCH 2/3] fix --- R/model_performance.rma.R | 4 ++-- man/model_performance.rma.Rd | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/R/model_performance.rma.R b/R/model_performance.rma.R index 167eb75bb..6a3fb2e93 100644 --- a/R/model_performance.rma.R +++ b/R/model_performance.rma.R @@ -47,8 +47,8 @@ #' See the documentation for `?metafor::fitstats`. #' } #' -#' @examplesIf require("metafor") -#' data(dat.bcg, package = "metafor") +#' @examplesIf require("metafor") && require("metadat") +#' data(dat.bcg, package = "metadat") #' dat <- metafor::escalc( #' measure = "RR", #' ai = tpos, diff --git a/man/model_performance.rma.Rd b/man/model_performance.rma.Rd index 9f2db24b5..69d1923ba 100644 --- a/man/model_performance.rma.Rd +++ b/man/model_performance.rma.Rd @@ -65,8 +65,8 @@ See the documentation for \code{?metafor::fitstats}. } } \examples{ -\dontshow{if (require("metafor")) (if (getRversion() >= "3.4") withAutoprint else force)(\{ # examplesIf} -data(dat.bcg, package = "metafor") +\dontshow{if (require("metafor") && require("metadat")) (if (getRversion() >= "3.4") withAutoprint else force)(\{ # examplesIf} +data(dat.bcg, package = "metadat") dat <- metafor::escalc( measure = "RR", ai = tpos, From 4e063c04605facbc55ad9571ec86db722f0e7227 Mon Sep 17 00:00:00 2001 From: Daniel Date: Fri, 15 Sep 2023 12:51:15 +0200 Subject: [PATCH 3/3] suppressWarnings --- R/r2_bayes.R | 14 ++++++++++++-- man/r2_bayes.Rd | 14 ++++++++++++-- 2 files changed, 24 insertions(+), 4 deletions(-) diff --git a/R/r2_bayes.R b/R/r2_bayes.R index c565832c9..1c8b5c4fa 100644 --- a/R/r2_bayes.R +++ b/R/r2_bayes.R @@ -75,10 +75,20 @@ #' #' \dontrun{ #' if (require("brms")) { -#' model <- brms::brm(mpg ~ wt + cyl, data = mtcars) +#' model <- suppressWarnings(brms::brm( +#' mpg ~ wt + cyl, +#' data = mtcars, +#' silent = 2, +#' refresh = 0 +#' )) #' r2_bayes(model) #' -#' model <- brms::brm(Petal.Length ~ Petal.Width + (1 | Species), data = iris) +#' model <- suppressWarnings(brms::brm( +#' Petal.Length ~ Petal.Width + (1 | Species), +#' data = iris, +#' silent = 2, +#' refresh = 0 +#' )) #' r2_bayes(model) #' } #' } diff --git a/man/r2_bayes.Rd b/man/r2_bayes.Rd index 387202ca9..1370bafda 100644 --- a/man/r2_bayes.Rd +++ b/man/r2_bayes.Rd @@ -106,10 +106,20 @@ if (require("BayesFactor")) { \dontrun{ if (require("brms")) { - model <- brms::brm(mpg ~ wt + cyl, data = mtcars) + model <- suppressWarnings(brms::brm( + mpg ~ wt + cyl, + data = mtcars, + silent = 2, + refresh = 0 + )) r2_bayes(model) - model <- brms::brm(Petal.Length ~ Petal.Width + (1 | Species), data = iris) + model <- suppressWarnings(brms::brm( + Petal.Length ~ Petal.Width + (1 | Species), + data = iris, + silent = 2, + refresh = 0 + )) r2_bayes(model) } }