Skip to content

Commit

Permalink
add tests
Browse files Browse the repository at this point in the history
  • Loading branch information
strengejacke committed Jun 30, 2023
1 parent f4b835c commit e47f543
Show file tree
Hide file tree
Showing 2 changed files with 78 additions and 0 deletions.
68 changes: 68 additions & 0 deletions tests/testthat/_snaps/print.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
# print.describe_posterior

Code
describe_posterior(m)
Warning <simpleWarning>
Could not estimate a good default ROPE range. Using 'c(-0.1, 0.1)'.
Output
Summary of Posterior Distribution
Parameter | Median | 95% CI | pd | ROPE | % in ROPE | Rhat | ESS
-------------------------------------------------------------------------------------------
(Intercept) | 0.96 | [-0.81, 2.51] | 90.00% | [-0.10, 0.10] | 2.54% | 1.011 | 110.00
child | -1.16 | [-1.36, -0.94] | 100% | [-0.10, 0.10] | 0% | 0.996 | 278.00
camper | 0.73 | [ 0.54, 0.91] | 100% | [-0.10, 0.10] | 0% | 0.996 | 271.00

---

Code
describe_posterior(m, effects = "all", component = "all")
Warning <simpleWarning>
Could not estimate a good default ROPE range. Using 'c(-0.1, 0.1)'.
Output
Summary of Posterior Distribution
Parameter | Median | 95% CI | pd | ROPE | % in ROPE | Rhat | ESS
-------------------------------------------------------------------------------------------
(Intercept) | 0.96 | [-0.81, 2.51] | 90.00% | [-0.10, 0.10] | 2.54% | 1.011 | 110.00
child | -1.16 | [-1.36, -0.94] | 100% | [-0.10, 0.10] | 0% | 0.996 | 278.00
camper | 0.73 | [ 0.54, 0.91] | 100% | [-0.10, 0.10] | 0% | 0.996 | 271.00
# Fixed effects (zero-inflated)
Parameter | Median | 95% CI | pd | ROPE | % in ROPE | Rhat | ESS
-------------------------------------------------------------------------------------------
(Intercept) | -0.48 | [-2.03, 0.89] | 78.00% | [-0.10, 0.10] | 10.59% | 0.997 | 138.00
child | 1.85 | [ 1.19, 2.54] | 100% | [-0.10, 0.10] | 0% | 0.996 | 303.00
camper | -0.88 | [-1.61, -0.07] | 98.40% | [-0.10, 0.10] | 0.85% | 0.996 | 292.00
# Random effects (conditional) Intercept: persons
Parameter | Median | 95% CI | pd | ROPE | % in ROPE | Rhat | ESS
--------------------------------------------------------------------------------------------
persons.1 | -0.99 | [-2.68, 0.80] | 92.00% | [-0.10, 0.10] | 2.12% | 1.007 | 106.00
persons.2 | -4.65e-03 | [-1.63, 1.66] | 50.00% | [-0.10, 0.10] | 13.98% | 1.013 | 109.00
persons.3 | 0.69 | [-0.95, 2.34] | 79.60% | [-0.10, 0.10] | 5.08% | 1.010 | 114.00
persons.4 | 1.57 | [-0.05, 3.29] | 96.80% | [-0.10, 0.10] | 1.27% | 1.009 | 114.00
# Random effects (zero-inflated) Intercept: persons
Parameter | Median | 95% CI | pd | ROPE | % in ROPE | Rhat | ESS
-----------------------------------------------------------------------------------------
persons.1 | 1.10 | [-0.23, 2.72] | 94.80% | [-0.10, 0.10] | 3.39% | 0.997 | 166.00
persons.2 | 0.18 | [-0.94, 1.58] | 63.20% | [-0.10, 0.10] | 14.83% | 0.996 | 154.00
persons.3 | -0.30 | [-1.79, 1.02] | 64.00% | [-0.10, 0.10] | 12.29% | 0.997 | 154.00
persons.4 | -1.45 | [-2.90, -0.10] | 98.00% | [-0.10, 0.10] | 0% | 1.000 | 189.00
# Random effects (conditional) SD/Cor: persons
Parameter | Median | 95% CI | pd | ROPE | % in ROPE | Rhat | ESS
-----------------------------------------------------------------------------------------
(Intercept) | 1.42 | [ 0.71, 3.58] | 100% | [-0.10, 0.10] | 0% | 1.010 | 126.00
# Random effects (zero-inflated) SD/Cor: persons
Parameter | Median | 95% CI | pd | ROPE | % in ROPE | Rhat | ESS
-----------------------------------------------------------------------------------------
(Intercept) | 1.30 | [ 0.63, 3.41] | 100% | [-0.10, 0.10] | 0% | 0.996 | 129.00

10 changes: 10 additions & 0 deletions tests/testthat/test-print.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
test_that("print.describe_posterior", {
skip_on_cran()
skip_if_offline()
skip_if_not_or_load_if_installed("brms")
skip_if_not_or_load_if_installed("httr")

m <- insight::download_model("brms_zi_3")
expect_snapshot(describe_posterior(m))
expect_snapshot(describe_posterior(m, effects = "all", component = "all"))
})

0 comments on commit e47f543

Please sign in to comment.