Skip to content

Commit

Permalink
Merge branch 'main' of github.com:poissonconsulting/mcmcr
Browse files Browse the repository at this point in the history
  • Loading branch information
joethorley committed Sep 30, 2023
2 parents e8cd206 + 5518064 commit 06d6b6d
Showing 1 changed file with 74 additions and 11 deletions.
85 changes: 74 additions & 11 deletions tests/testthat/test-rhat.R
Original file line number Diff line number Diff line change
Expand Up @@ -77,26 +77,89 @@ test_that("rhat.mcmcr NA", {
})

test_that("rhat.mcmcrs", {
withr::local_options(lifecycle_verbosity = "quiet")

expect_identical(rhat(mcmcrs(mcmcr_example, mcmcr_example)), list(mcmcr1 = 2.002, mcmcr2 = 2.002))
expect_identical(rhat(mcmcrs(mcmcr_example, mcmcr_example), bound = TRUE), list(mcmcr1 = 2.002, mcmcr2 = 2.002, bound = 1.891))
expect_identical(
rhat(
mcmcrs(mcmcr_example, mcmcr_example)
),
list(mcmcr1 = 2.002, mcmcr2 = 2.002)
)

lifecycle::expect_deprecated(
expect_identical(
rhat(mcmcrs(mcmcr_example, mcmcr_example), bound = TRUE),
list(mcmcr1 = 2.002, mcmcr2 = 2.002, bound = 1.891)
),
regexp = "`rhat.mcmcrs\\(x, bound = TRUE\\)` returns scalar was deprecated in mcmcr 0.6.1.9001."
)

expect_identical(
rhat(mcmcrs(mcmcr_example, mcmcr_example), by = "parameter"),
list(
mcmcr1 = list(alpha = 2.002, beta = 1.147, sigma = 1),
mcmcr2 = list(alpha = 2.002, beta = 1.147, sigma = 1)
)
)
expect_identical(
rhat(mcmcrs(mcmcr_example, mcmcr_example), bound = TRUE, by = "parameter"),
list(mcmcr1 = list(alpha = 2.002, beta = 1.147, sigma = 1),
mcmcr2 = list(alpha = 2.002, beta = 1.147, sigma = 1),
bound = list(alpha = 1.891, beta = 1.127, sigma = 1))

lifecycle::expect_deprecated(
expect_identical(
rhat(mcmcrs(mcmcr_example, mcmcr_example), bound = TRUE, by = "parameter"),
list(mcmcr1 = list(alpha = 2.002, beta = 1.147, sigma = 1),
mcmcr2 = list(alpha = 2.002, beta = 1.147, sigma = 1),
bound = list(alpha = 1.891, beta = 1.127, sigma = 1))
),
regexp = "`rhat.mcmcrs\\(x, bound = TRUE\\)` returns scalar was deprecated in mcmcr 0.6.1.9001."
)
expect_identical(rhat(mcmcrs(mcmcr_example, mcmcr_example), bound = TRUE, as_df = TRUE), structure(list(all = "all", mcmcr1 = 2.002, mcmcr2 = 2.002, bound = 1.891), class = "data.frame", row.names = c(NA,-1L)))

expect_identical(rhat(mcmcrs(mcmcr_example, mcmcr_example), by = "parameter", bound = TRUE, as_df = TRUE), structure(list(parameter = c("alpha", "beta", "sigma"), mcmcr1 = c(2.002,1.147, 1), mcmcr2 = c(2.002, 1.147, 1), bound = c(1.891, 1.127, 1)), class = "data.frame", row.names = c(NA, -3L)))
lifecycle::expect_deprecated(
expect_identical(
rhat(mcmcrs(mcmcr_example, mcmcr_example), bound = TRUE, as_df = TRUE),
structure(
list(all = "all", mcmcr1 = 2.002, mcmcr2 = 2.002, bound = 1.891),
class = "data.frame", row.names = c(NA,-1L)
)
),
regexp = "`rhat.mcmcrs\\(x, bound = TRUE\\)` returns scalar was deprecated in mcmcr 0.6.1.9001."
)

expect_identical(rhat(mcmcrs(mcmcr_example, mcmcr_example), by = "term", bound = TRUE, as_df = TRUE), structure(list(term = structure(c("alpha[1]", "alpha[2]", "beta[1,1]", "beta[2,1]", "beta[1,2]", "beta[2,2]", "sigma"), class = c("term", "vctrs_vctr")), mcmcr1 = c(2.002, 2.002, 1.147, 1.147, 1.147,1.147, 1), mcmcr2 = c(2.002, 2.002, 1.147, 1.147, 1.147, 1.147, 1), bound = c(1.891, 1.891, 1.127, 1.127, 1.127, 1.127, 1)), class = "data.frame", row.names = c(NA, -7L)))
lifecycle::expect_deprecated(
expect_identical(
rhat(
mcmcrs(mcmcr_example, mcmcr_example),
by = "parameter", bound = TRUE, as_df = TRUE
),
structure(
list(
parameter = c("alpha", "beta", "sigma"),
mcmcr1 = c(2.002,1.147, 1),
mcmcr2 = c(2.002, 1.147, 1),
bound = c(1.891, 1.127, 1)),
class = "data.frame",
row.names = c(NA, -3L)
)
),
regexp = "`rhat.mcmcrs\\(x, bound = TRUE\\)` returns scalar was deprecated in mcmcr 0.6.1.9001."
)

lifecycle::expect_deprecated(
expect_identical(
rhat(
mcmcrs(mcmcr_example, mcmcr_example),
by = "term", bound = TRUE, as_df = TRUE
),
structure(
list(
term = structure(
c("alpha[1]", "alpha[2]", "beta[1,1]", "beta[2,1]", "beta[1,2]", "beta[2,2]", "sigma"),
class = c("term", "vctrs_vctr")
),
mcmcr1 = c(2.002, 2.002, 1.147, 1.147, 1.147,1.147, 1),
mcmcr2 = c(2.002, 2.002, 1.147, 1.147, 1.147, 1.147, 1),
bound = c(1.891, 1.891, 1.127, 1.127, 1.127, 1.127, 1)),
class = "data.frame",
row.names = c(NA, -7L)
)
),
regexp = "`rhat.mcmcrs\\(x, bound = TRUE\\)` returns scalar was deprecated in mcmcr 0.6.1.9001."
)
})

0 comments on commit 06d6b6d

Please sign in to comment.