https://github.com/cran/bayestestR
Revision 40f7c88ddf855896018cf20ec8a7ac5fbd0ea2fb authored by Dominique Makowski on 27 January 2020, 05:30:28 UTC, committed by cran-robot on 27 January 2020, 05:30:28 UTC
1 parent d8462ad
Raw File
Tip revision: 40f7c88ddf855896018cf20ec8a7ac5fbd0ea2fb authored by Dominique Makowski on 27 January 2020, 05:30:28 UTC
version 0.5.1
Tip revision: 40f7c88
test-map_estimate.R
if (requireNamespace("rstanarm", quietly = TRUE)) {
  context("map_estimate")

  test_that("map_estimate", {
    testthat::expect_equal(
      as.numeric(map_estimate(distribution_normal(1000))),
      0,
      tolerance = 0.01
    )
  })




  if (require("insight")) {
    m <- insight::download_model("stanreg_merMod_5")

    test_that("map_estimate", {
      testthat::expect_equal(
        map_estimate(m, effects = "all")$Parameter,
        colnames(as.data.frame(m))[1:20]
      )
    })

    m <- insight::download_model("brms_zi_3")

    test_that("map_estimate", {
      testthat::expect_equal(
        map_estimate(m, effects = "all", component = "all")$Parameter,
        c(
          "b_Intercept", "b_child", "b_camper", "r_persons.1.Intercept.",
          "r_persons.2.Intercept.", "r_persons.3.Intercept.", "r_persons.4.Intercept.",
          "b_zi_Intercept", "b_zi_child", "b_zi_camper", "r_persons__zi.1.Intercept.",
          "r_persons__zi.2.Intercept.", "r_persons__zi.3.Intercept.", "r_persons__zi.4.Intercept."
        )
      )
    })
  }
}
back to top