Skip to content

Commit

Permalink
styler
Browse files Browse the repository at this point in the history
  • Loading branch information
strengejacke committed Jul 2, 2023
1 parent bdd4323 commit 939fb8c
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 12 deletions.
6 changes: 3 additions & 3 deletions R/bayesfactor_models.R
Original file line number Diff line number Diff line change
Expand Up @@ -217,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
18 changes: 12 additions & 6 deletions tests/testthat/test-describe_posterior.R
Original file line number Diff line number Diff line change
Expand Up @@ -108,9 +108,12 @@ test_that("describe_posterior", {
set.seed(333)
# Rstanarm
x <- rstanarm::stan_glm(mpg ~ wt, data = mtcars, refresh = 0, iter = 500)
expect_warning({
rez <- describe_posterior(x, centrality = "all", dispersion = TRUE, test = "all")
}, regex = "not be precise")
expect_warning(
{
rez <- describe_posterior(x, centrality = "all", dispersion = TRUE, test = "all")
},
regex = "not be precise"
)
expect_identical(dim(rez), c(2L, 21L))
expect_identical(colnames(rez), c(
"Parameter", "Median", "MAD", "Mean", "SD", "MAP", "CI", "CI_low",
Expand Down Expand Up @@ -269,9 +272,12 @@ test_that("describe_posterior w/ BF+SI", {
# test si
set.seed(555)
suppressMessages(
expect_warning({
rez_si <- si(x)
}, regex = "not be precise")
expect_warning(
{
rez_si <- si(x)
},
regex = "not be precise"
)
)
expect_equal(rez$CI_low, rez_si$CI_low, tolerance = 0.1)
expect_equal(rez$CI_high, rez_si$CI_high, tolerance = 0.1)
Expand Down
9 changes: 6 additions & 3 deletions tests/testthat/test-si.R
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,12 @@ test_that("si.numeric", {
prior <- distribution_normal(1000, mean = 0, sd = 1)
posterior <- distribution_normal(1000, mean = 0.5, sd = 0.3)

expect_warning({
res <- si(posterior, prior)
}, regexp = "40")
expect_warning(
{
res <- si(posterior, prior)
},
regexp = "40"
)
expect_equal(res$CI_low, 0.043, tolerance = 0.02)
expect_equal(res$CI_high, 1.053103, tolerance = 0.02)
expect_s3_class(res, "bayestestR_si")
Expand Down

0 comments on commit 939fb8c

Please sign in to comment.