https://github.com/cran/bayestestR
Tip revision: 601edcd8d1306ebea478657861c54fa9c69a52f3 authored by Dominique Makowski on 31 May 2021, 05:40:09 UTC
version 0.10.0
version 0.10.0
Tip revision: 601edcd
test-check_prior.R
.runThisTest <- Sys.getenv("RunAllbayestestRTests") == "yes"
if (.runThisTest &&
require("rstanarm") &&
require("testthat") &&
require("bayestestR") &&
require("brms") &&
packageVersion("insight") > "0.13.2") {
skip_on_cran()
# stanreg --------------------------
set.seed(333)
model1 <- insight::download_model("stanreg_lm_1")
expect_equal(
check_prior(model1)$Prior_Quality,
c("informative", "uninformative")
)
expect_equal(
check_prior(model1, method = "lakeland")$Prior_Quality,
c("informative", "informative")
)
# brms -----------------------------
# all `brms` examples in circus have uniform prior distribution, so
# need to use a custom example here
set.seed(333)
model2 <- brm(rating ~ period + carry + cs(treat),
data = inhaler, family = sratio("logit"),
prior = set_prior("normal(0,5)"),
chains = 2, silent = TRUE, refresh = 0
)
expect_equal(
check_prior(model2)$Prior_Quality,
c(
"uninformative", "informative", "informative", "uninformative",
"uninformative", "uninformative", "informative", "informative"
)
)
expect_equal(
check_prior(model2, method = "lakeland")$Prior_Quality,
c(
"informative", "informative", "informative", "informative",
"informative", "informative", "informative", "informative"
)
)
}