swh:1:snp:2c68a6c5a8af2f06ac2c0225927f25b54fd1f9d0
Raw File
Tip revision: 6313ce21ea98857cf95d996de7978cfd52175e59 authored by Dominique Makowski on 08 April 2021, 04:40:02 UTC
version 0.9.0
Tip revision: 6313ce2
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")
  )
}
back to top