Skip to content

Commit

Permalink
add test for pars_wo_index
Browse files Browse the repository at this point in the history
  • Loading branch information
yoshidk6 committed Nov 26, 2024
1 parent e1c162f commit d6594fd
Showing 1 changed file with 13 additions and 2 deletions.
15 changes: 13 additions & 2 deletions tests/testthat/test-as_draws.R
Original file line number Diff line number Diff line change
Expand Up @@ -3,26 +3,29 @@ set.seed(123)

mods <- list()
pars <- list()
pars_wo_index <- list()

mods[[1]] <- suppressWarnings(stan_emax(
formula = response ~ exposure,
data = exposure.response.sample,
chains = 2,
iter = 500,
chains = 1, iter = 50, refresh = 0,
show_messages = FALSE
))
pars[[1]] <- c("ec50", "sigma", "gamma", "e0", "emax")
pars_wo_index[[1]] <- c("ec50", "sigma", "gamma", "e0", "emax")

mods[[2]] <- suppressWarnings(stan_emax(
formula = resp ~ conc,
data = exposure.response.sample.with.cov,
param.cov = list(emax = "cov1", e0 = "cov2"),
chains = 1, iter = 50, refresh = 0,
show_messages = FALSE
))
pars[[2]] <- c(
"ec50", "sigma", "gamma", "e0[B0]", "e0[B2]",
"e0[B3]", "emax[A0]", "emax[A1]"
)
pars_wo_index[[2]] <- c("ec50", "sigma", "gamma", "e0", "emax")


test_that("as_draws coercion works", {
Expand Down Expand Up @@ -80,6 +83,14 @@ test_that("as_draws preserves covariate labels", {
),
expected = pars[[i]]
)

expect_equal(
object = posterior::variables(
x = posterior::as_draws_rvars(mods[[i]]),
with_indices = FALSE
),
expected = pars_wo_index[[i]]
)
}
})

0 comments on commit d6594fd

Please sign in to comment.