https://github.com/cran/bayestestR
Tip revision: 428249f43a9c6fd0c425b28deb5fee51a9525d69 authored by Dominique Makowski on 18 September 2022, 01:46:03 UTC
version 0.13.0
version 0.13.0
Tip revision: 428249f
test-p_to_bf.R
if (requiet("testthat") && requiet("parameters") && requiet("bayestestR")) {
m <- lm(mpg ~ hp + cyl + am, data = mtcars)
p <- coef(summary(m))[-1, 4]
# BF by hand
bfs <- 3 * p * sqrt(insight::n_obs(m))
test_that("p_to_bf works", {
expect_equal(p_to_bf(m, log = FALSE)[-1, ]$BF, exp(-log(bfs)), tolerance = 1e-4, ignore_attr = TRUE)
expect_equal(p_to_bf(m, log = TRUE)[-1, ]$log_BF, -log(bfs), tolerance = 1e-4, ignore_attr = TRUE)
})
}