From bc9b26435e51df8635f699995a4931a7e8de9b0e Mon Sep 17 00:00:00 2001 From: Bill Denney Date: Thu, 16 May 2024 12:54:20 -0400 Subject: [PATCH] sparse_auc_df and sparse_auc_se are in the parameter list (fix #292) --- R/sparse.R | 32 ++++++++++++++++++++++++++++++++ tests/testthat/test-sparse.R | 12 +++++++++--- 2 files changed, 41 insertions(+), 3 deletions(-) diff --git a/R/sparse.R b/R/sparse.R index fce7f89b..6173db18 100644 --- a/R/sparse.R +++ b/R/sparse.R @@ -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 diff --git a/tests/testthat/test-sparse.R b/tests/testthat/test-sparse.R index b32c99fc..9d03128b 100644 --- a/tests/testthat/test-sparse.R +++ b/tests/testthat/test-sparse.R @@ -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 @@ -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) @@ -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())) + ) +})