Skip to content

Commit

Permalink
Merge pull request #293 from billdenney/292-sparse_se-and-sparse_df-m…
Browse files Browse the repository at this point in the history
…issing-from-getintervalcols

sparse_auc_df and sparse_auc_se are in the parameter list (fix #292)
  • Loading branch information
billdenney authored May 16, 2024
2 parents d8ec7cb + bc9b264 commit 3ecb3fc
Show file tree
Hide file tree
Showing 2 changed files with 41 additions and 3 deletions.
32 changes: 32 additions & 0 deletions R/sparse.R
Original file line number Diff line number Diff line change
Expand Up @@ -361,6 +361,38 @@ PKNCA.set.summary(
spread=business.geocv
)

add.interval.col(
"sparse_auc_se",
FUN=NA,
values=c(FALSE, TRUE),
unit_type="auc",
pretty_name="Sparse AUClast standard error",
desc="For sparse PK sampling, the standard error of the area under the concentration time curve from the beginning of the interval to the last concentration above the limit of quantification",
depends="sparse_auclast"
)
PKNCA.set.summary(
name="sparse_auc_se",
description="arithmetic mean and standard deviation",
point=business.mean,
spread=business.sd
)

add.interval.col(
"sparse_auc_df",
FUN=NA,
values=c(FALSE, TRUE),
unit_type="count",
pretty_name="Sparse AUClast degrees of freedom",
desc="For sparse PK sampling, the standard error degrees of freedom of the area under the concentration time curve from the beginning of the interval to the last concentration above the limit of quantification",
depends="sparse_auclast"
)
PKNCA.set.summary(
name="sparse_auc_df",
description="arithmetic mean and standard deviation",
point=business.mean,
spread=business.sd
)

#' Is a PKNCA object used for sparse PK?
#'
#' @param object The object to see if it includes sparse PK
Expand Down
12 changes: 9 additions & 3 deletions tests/testthat/test-sparse.R
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ test_that("sparse_auc", {
time = c(0, 0, 0, 1, 1, 1, 6, 6, 6, 2, 2, 2, 10, 10, 10, 4, 4, 4, 24, 24, 24),
dose = c(100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100)
)
# calculated using the PK library with

# calculated using the PK library with
# v_batch <- PK::auc(data=d_sparse, method="t", design="batch")
# v_serial <- PK::auc(data=d_sparse, method="t", design="ssd")
auclast <- 39.4689 # using linear trapezoidal rule
Expand All @@ -23,7 +23,7 @@ test_that("sparse_auc", {
expect_equal(sparse_batch$sparse_auc, auclast)
expect_equal(sparse_batch$sparse_auc_se, auclast_se_batch)
expect_equal(sparse_batch$sparse_auc_df, NA_real_)

sparse_serial <- pk.calc.sparse_auc(conc=d_sparse$conc, time=d_sparse$time, subject=seq_len(nrow(d_sparse)))
expect_equal(sparse_serial$sparse_auc, auclast)
expect_equal(as.numeric(sparse_serial$sparse_auc_se), auclast_se_serial)
Expand All @@ -36,3 +36,9 @@ test_that("sparse_auclast expected errors", {
class = "pknca_sparse_auclast_change_auclast"
)
})

test_that("sparse_auc_df and sparse_auc_se are in the parameter list (#292)", {
expect_true(
all(c("sparse_auc_df", "sparse_auc_se") %in% names(get.interval.cols()))
)
})

0 comments on commit 3ecb3fc

Please sign in to comment.