Skip to content

Commit

Permalink
column naming for brms CI (fix bbolker#87)
Browse files Browse the repository at this point in the history
  • Loading branch information
bbolker committed Mar 8, 2020
1 parent 09a11b2 commit 0339744
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 4 deletions.
8 changes: 4 additions & 4 deletions R/brms_tidiers.R
Original file line number Diff line number Diff line change
Expand Up @@ -246,12 +246,12 @@ tidy.brmsfit <- function(x, parameters = NA,
stopifnot(length(conf.level) == 1L)
probs <- c((1 - conf.level) / 2, 1 - (1 - conf.level) / 2)
if (conf.method == "HPDinterval") {
out[, c("conf.low", "conf.high")] <-
coda::HPDinterval(coda::as.mcmc(samples), prob=conf.level)
cc <- coda::HPDinterval(coda::as.mcmc(samples), prob=conf.level)
} else {
out[, c("conf.low", "conf.high")] <-
t(apply(samples, 2, stats::quantile, probs = probs))
cc <- t(apply(samples, 2, stats::quantile, probs = probs))
}
out$conf.low <- cc[,1]
out$conf.high <- cc[,2]
}
## figure out component
out$component <- dplyr::case_when(grepl("(^|_)zi",out$term) ~ "zi",
Expand Down
15 changes: 15 additions & 0 deletions tests/testthat/test-brms.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@

stopifnot(require("testthat"), require("broom.mixed"))

if (require(brms, quietly = TRUE) && require(rstanarm, quietly=TRUE)) {
load(system.file("extdata", "brms_example.rda",
package = "broom.mixed",
mustWork = TRUE
))

context("brms models")

## GH #87
expect_true(all(c("conf.low","conf.high") %in%
names(tidy(brms_multi,conf.int=TRUE))))
}

0 comments on commit 0339744

Please sign in to comment.