Skip to content

Commit

Permalink
Add more tests for meanProb
Browse files Browse the repository at this point in the history
  • Loading branch information
mattfidler committed Oct 4, 2023
1 parent e0d9210 commit 975043c
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 1 deletion.
2 changes: 1 addition & 1 deletion R/confint.R
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ confint.rxSolve <- function(object, parm = NULL, level = 0.95, ...) {
.useT <- TRUE
if (any(names(.args) == "useT")) {
.useT <- .args$useT
checkmate::assertLogical(useT, len=1, any.missing=FALSE, .var.name="pred")
checkmate::assertLogical(.useT, len=1, any.missing=FALSE, .var.name="useT")
}
if (any(names(.args) == "mean")) {
.mean <- .args$mean
Expand Down
24 changes: 24 additions & 0 deletions tests/testthat/test-meanProb.R
Original file line number Diff line number Diff line change
Expand Up @@ -89,4 +89,28 @@ test_that("test meanProb()", {

expect_equal(ci1$eff, ci2$eff)


ci1 <- confint(pk1, "blood", mean=TRUE, useT=FALSE)

# use dplyr
ci2 <- pk1 |>
dplyr::group_by(time) |>
dplyr::reframe(eff=meanProbs(blood, c(0.025, 0.5, 0.975), na.rm=TRUE, names=FALSE, useT=FALSE),
p1=c(0.025, 0.5, 0.975), Percentile=c("2.5%", "50%", "97.5%")) |>
dplyr::arrange(time, p1)

expect_equal(ci1$eff, ci2$eff)

ci1 <- confint(pk1, "blood", mean=TRUE, useT=FALSE, pred=TRUE)

# use dplyr
ci2 <- pk1 |>
dplyr::group_by(time) |>
dplyr::reframe(eff=meanProbs(blood, c(0.025, 0.5, 0.975), na.rm=TRUE, names=FALSE, useT=FALSE,
pred=TRUE),
p1=c(0.025, 0.5, 0.975), Percentile=c("2.5%", "50%", "97.5%")) |>
dplyr::arrange(time, p1)

expect_equal(ci1$eff, ci2$eff)

})

0 comments on commit 975043c

Please sign in to comment.