Skip to content

Commit

Permalink
Housekeeping (fix GH action warnings, lintr, code-style, ...) (#611)
Browse files Browse the repository at this point in the history
* fix warnings in tests

* fix

* vig

* fx vig

* fix

* fix

* fix, lintr

* fix

* lintr, code-style, fix vignette

* fix vignette?

* fix

* fix

* fix

* fix?
  • Loading branch information
strengejacke authored Jun 30, 2023
1 parent 5af07e4 commit 6090d1c
Show file tree
Hide file tree
Showing 27 changed files with 357 additions and 160 deletions.
10 changes: 4 additions & 6 deletions R/bayesfactor_models.R
Original file line number Diff line number Diff line change
Expand Up @@ -204,9 +204,7 @@ bayesfactor_models.default <- function(..., denominator = 1, verbose = TRUE) {
supported_models[!has_terms] <- FALSE
}

objects <- tryCatch(do.call(insight::ellipsis_info, c(mods, verbose = FALSE)),
error = function(...) NULL
)
objects <- .safe(do.call(insight::ellipsis_info, c(mods, verbose = FALSE)))
if (!is.null(objects)) {
were_checked <- inherits(objects, "ListModels")

Expand All @@ -219,9 +217,9 @@ bayesfactor_models.default <- function(..., denominator = 1, verbose = TRUE) {

# Get BIC
if (were_checked && estimator == "REML" &&
any(vapply(mods, insight::is_mixed_model, TRUE)) &&
!isTRUE(attr(objects, "same_fixef")) &&
verbose) {
any(vapply(mods, insight::is_mixed_model, TRUE)) &&
!isTRUE(attr(objects, "same_fixef")) &&
verbose) {
insight::format_warning(
"Information criteria (like BIC) based on REML fits (i.e. `estimator=\"REML\"`)",
"are not recommended for comparison between models with different fixed effects.",
Expand Down
12 changes: 11 additions & 1 deletion R/bci.R
Original file line number Diff line number Diff line change
Expand Up @@ -227,7 +227,17 @@ bci.brmsfit <- function(x, ci = 0.95, effects = c("fixed", "random", "all"),
component <- match.arg(component)

out <- .prepare_output(
bci(insight::get_parameters(x, effects = effects, component = component, parameters = parameters), ci = ci, verbose = verbose, ...),
bci(
insight::get_parameters(
x,
effects = effects,
component = component,
parameters = parameters
),
ci = ci,
verbose = verbose,
...
),
insight::clean_parameters(x)
)

Expand Down
3 changes: 2 additions & 1 deletion R/bic_to_bf.R
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@
#' @param log If `TRUE`, return the `log(BF)`.
#'
#' @references
#' Wagenmakers, E. J. (2007). A practical solution to the pervasive problems of p values. Psychonomic bulletin & review, 14(5), 779-804
#' Wagenmakers, E. J. (2007). A practical solution to the pervasive problems of
#' p values. Psychonomic bulletin & review, 14(5), 779-804
#'
#' @examples
#' bic1 <- BIC(lm(Sepal.Length ~ 1, data = iris))
Expand Down
8 changes: 4 additions & 4 deletions R/check_prior.R
Original file line number Diff line number Diff line change
Expand Up @@ -147,16 +147,16 @@ check_prior.blavaan <- check_prior.brmsfit
priors <- priors[common_columns]
posteriors <- posteriors[common_columns]
if (verbose) {
insight::format_warning("Parameters and priors could not be fully matched. Only returning results for parameters with matching priors.")
insight::format_warning(
"Parameters and priors could not be fully matched. Only returning results for parameters with matching priors."
)
}
}


# for priors whose distribution cannot be simulated, prior values are
# all NA. Catch those, and warn user
all_missing <- sapply(priors, function(i) {
all(is.na(i))
})
all_missing <- vapply(priors, function(i) all(is.na(i)), TRUE)

if (any(all_missing) && verbose) {
insight::format_warning("Some priors could not be simulated.")
Expand Down
2 changes: 1 addition & 1 deletion R/diagnostic_draws.R
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
#' set.seed(333)
#'
#' if (require("brms", quietly = TRUE)) {
#' model <- suppressWarning(brm(mpg ~ wt * cyl * vs,
#' model <- suppressWarnings(brm(mpg ~ wt * cyl * vs,
#' data = mtcars,
#' iter = 100, control = list(adapt_delta = 0.80),
#' refresh = 0
Expand Down
Loading

0 comments on commit 6090d1c

Please sign in to comment.