Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

try to reduce warnings in examples and use examplesIf #616

Merged
merged 3 commits into from
Sep 15, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions R/looic.R
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
10 changes: 5 additions & 5 deletions R/model_performance.bayesian.R
Original file line number Diff line number Diff line change
Expand Up @@ -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])
Expand Down
4 changes: 2 additions & 2 deletions R/model_performance.rma.R
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
18 changes: 14 additions & 4 deletions R/r2_bayes.R
Original file line number Diff line number Diff line change
Expand Up @@ -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)
#' }
#'
Expand All @@ -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)
#' }
#' }
Expand All @@ -104,7 +114,7 @@
mean(i)
}
}),
"SE" = rapply(r2_bayesian, function(i) {

Check warning on line 117 in R/r2_bayes.R

View workflow job for this annotation

GitHub Actions / lint-changed-files / lint-changed-files

file=R/r2_bayes.R,line=117,col=7,[keyword_quote_linter] Only quote named arguments to functions if necessary, i.e., if the name is not a valid R symbol (see ?make.names).
if (robust) {
stats::mad(i)
} else {
Expand All @@ -112,9 +122,9 @@
}
}),
# "Estimates" = rapply(r2_bayesian, bayestestR::point_estimate, centrality = "all", dispersion = TRUE),
"CI" = rapply(r2_bayesian, bayestestR::hdi, ci = ci),

Check warning on line 125 in R/r2_bayes.R

View workflow job for this annotation

GitHub Actions / lint-changed-files / lint-changed-files

file=R/r2_bayes.R,line=125,col=7,[keyword_quote_linter] Only quote named arguments to functions if necessary, i.e., if the name is not a valid R symbol (see ?make.names).
"ci_method" = "HDI",

Check warning on line 126 in R/r2_bayes.R

View workflow job for this annotation

GitHub Actions / lint-changed-files / lint-changed-files

file=R/r2_bayes.R,line=126,col=7,[keyword_quote_linter] Only quote named arguments to functions if necessary, i.e., if the name is not a valid R symbol (see ?make.names).
"robust" = robust

Check warning on line 127 in R/r2_bayes.R

View workflow job for this annotation

GitHub Actions / lint-changed-files / lint-changed-files

file=R/r2_bayes.R,line=127,col=7,[keyword_quote_linter] Only quote named arguments to functions if necessary, i.e., if the name is not a valid R symbol (see ?make.names).
)
} else {
structure(
Expand All @@ -126,7 +136,7 @@
mean(i)
}
}),
"SE" = lapply(r2_bayesian, function(i) {

Check warning on line 139 in R/r2_bayes.R

View workflow job for this annotation

GitHub Actions / lint-changed-files / lint-changed-files

file=R/r2_bayes.R,line=139,col=7,[keyword_quote_linter] Only quote named arguments to functions if necessary, i.e., if the name is not a valid R symbol (see ?make.names).
if (robust) {
stats::mad(i)
} else {
Expand All @@ -134,9 +144,9 @@
}
}),
# "Estimates" = lapply(r2_bayesian, bayestestR::point_estimate, centrality = "all", dispersion = TRUE),
"CI" = lapply(r2_bayesian, bayestestR::hdi, ci = ci),

Check warning on line 147 in R/r2_bayes.R

View workflow job for this annotation

GitHub Actions / lint-changed-files / lint-changed-files

file=R/r2_bayes.R,line=147,col=7,[keyword_quote_linter] Only quote named arguments to functions if necessary, i.e., if the name is not a valid R symbol (see ?make.names).
"ci_method" = "HDI",

Check warning on line 148 in R/r2_bayes.R

View workflow job for this annotation

GitHub Actions / lint-changed-files / lint-changed-files

file=R/r2_bayes.R,line=148,col=7,[keyword_quote_linter] Only quote named arguments to functions if necessary, i.e., if the name is not a valid R symbol (see ?make.names).
"robust" = robust

Check warning on line 149 in R/r2_bayes.R

View workflow job for this annotation

GitHub Actions / lint-changed-files / lint-changed-files

file=R/r2_bayes.R,line=149,col=7,[keyword_quote_linter] Only quote named arguments to functions if necessary, i.e., if the name is not a valid R symbol (see ?make.names).
)
}
}
Expand Down Expand Up @@ -168,13 +178,13 @@
res <- insight::find_response(model)
if (mi[[1]]$is_mixed) {
br2_mv <- list(
"R2_Bayes" = rstantools::bayes_R2(

Check warning on line 181 in R/r2_bayes.R

View workflow job for this annotation

GitHub Actions / lint-changed-files / lint-changed-files

file=R/r2_bayes.R,line=181,col=13,[keyword_quote_linter] Only quote named arguments to functions if necessary, i.e., if the name is not a valid R symbol (see ?make.names).
model,
re.form = NULL,
re_formula = NULL,
summary = FALSE
),
"R2_Bayes_marginal" = rstantools::bayes_R2(

Check warning on line 187 in R/r2_bayes.R

View workflow job for this annotation

GitHub Actions / lint-changed-files / lint-changed-files

file=R/r2_bayes.R,line=187,col=13,[keyword_quote_linter] Only quote named arguments to functions if necessary, i.e., if the name is not a valid R symbol (see ?make.names).
model,
re.form = NA,
re_formula = NA,
Expand Down
4 changes: 2 additions & 2 deletions man/looic.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions man/model_performance.rma.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 5 additions & 5 deletions man/model_performance.stanreg.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

18 changes: 14 additions & 4 deletions man/r2_bayes.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading