1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51
|
skip_if_not_installed("curl")
skip_if_offline()
skip_if_not_installed("posterior")
skip_if_not_installed("brms")
skip_on_cran()
model <- insight::download_model("brms_1")
test_that("mp-posterior-draws", {
x <- posterior::as_draws(model)
mp <- model_parameters(x)
expect_equal(mp$Median, c(39.68234, -3.19505, -1.4936, 2.62881, -79.73344), tolerance = 1e-2, ignore_attr = TRUE)
expect_identical(mp$Parameter, c("b_Intercept", "b_wt", "b_cyl", "sigma", "lp__"))
expect_identical(colnames(mp), c("Parameter", "Median", "CI_low", "CI_high", "pd"))
})
test_that("mp-posterior-draws_list", {
x <- posterior::as_draws_list(model)
mp <- model_parameters(x)
expect_equal(mp$Median, c(39.68234, -3.19505, -1.4936, 2.62881, -79.73344), tolerance = 1e-2, ignore_attr = TRUE)
expect_identical(mp$Parameter, c("b_Intercept", "b_wt", "b_cyl", "sigma", "lp__"))
})
test_that("mp-posterior-draws_df", {
x <- posterior::as_draws_df(model)
mp <- model_parameters(x)
expect_equal(mp$Median, c(39.68234, -3.19505, -1.4936, 2.62881, -79.73344), tolerance = 1e-2, ignore_attr = TRUE)
expect_identical(mp$Parameter, c("b_Intercept", "b_wt", "b_cyl", "sigma", "lp__"))
})
test_that("mp-posterior-draws_matrix", {
x <- posterior::as_draws_matrix(model)
mp <- model_parameters(x)
expect_equal(mp$Median, c(39.68234, -3.19505, -1.4936, 2.62881, -79.73344), tolerance = 1e-2, ignore_attr = TRUE)
expect_identical(mp$Parameter, c("b_Intercept", "b_wt", "b_cyl", "sigma", "lp__"))
})
test_that("mp-posterior-draws_array", {
x <- posterior::as_draws_array(model)
mp <- model_parameters(x)
expect_equal(mp$Median, c(39.68234, -3.19505, -1.4936, 2.62881, -79.73344), tolerance = 1e-2, ignore_attr = TRUE)
expect_identical(mp$Parameter, c("b_Intercept", "b_wt", "b_cyl", "sigma", "lp__"))
})
test_that("mp-posterior-draws standard error", {
x <- posterior::as_draws(model)
se1 <- standard_error(x)
se2 <- standard_error(model)
expect_equal(se1$SE[1:4], se2$SE[1:4], tolerance = 1e-2, ignore_attr = TRUE)
})
|