aboutsummaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorJohannes Ranke <jranke@uni-bremen.de>2022-09-29 17:31:15 +0200
committerJohannes Ranke <jranke@uni-bremen.de>2022-09-29 17:31:15 +0200
commit584308a7fbf6c7c5eff342b64b451fdaf1af91c6 (patch)
treec051f1d0609120ee55107d854e1db85bb7cb5eda /tests
parent65319a145f12fc76e4f3bffb5f699ec21ba3bccd (diff)
Add set_nd_nq previously in pfm
pfm depends on mkin anyways, so reexporting set_nd_nq and set_nd_nq_focus in pfm should provide reasonable continuity.
Diffstat (limited to 'tests')
-rw-r--r--tests/testthat/print_sfo_saem_1.txt6
-rw-r--r--tests/testthat/summary_hfit_sfo_tc.txt2
-rw-r--r--tests/testthat/test_set_nd.R86
3 files changed, 90 insertions, 4 deletions
diff --git a/tests/testthat/print_sfo_saem_1.txt b/tests/testthat/print_sfo_saem_1.txt
index a11e1e96..34eea058 100644
--- a/tests/testthat/print_sfo_saem_1.txt
+++ b/tests/testthat/print_sfo_saem_1.txt
@@ -7,13 +7,13 @@ Data:
Likelihood computed by importance sampling
AIC BIC logLik
- 1311 1315 -649
+ 1312 1316 -650
Fitted parameters:
estimate lower upper
-parent_0 1e+02 99.13 1e+02
+parent_0 1e+02 99.28 1e+02
k_parent 4e-02 0.03 4e-02
a.1 9e-01 0.75 1e+00
b.1 5e-02 0.04 5e-02
-SD.parent_0 7e-01 -1.09 3e+00
+SD.parent_0 2e-01 -6.33 7e+00
SD.k_parent 3e-01 0.20 4e-01
diff --git a/tests/testthat/summary_hfit_sfo_tc.txt b/tests/testthat/summary_hfit_sfo_tc.txt
index ad701cee..e3e2f7e4 100644
--- a/tests/testthat/summary_hfit_sfo_tc.txt
+++ b/tests/testthat/summary_hfit_sfo_tc.txt
@@ -45,7 +45,7 @@ SD.log_k_parent 0.3 0.1 0.4
Variance model:
est. lower upper
-a.1 0.91 0.64 1.17
+a.1 0.90 0.64 1.17
b.1 0.05 0.04 0.06
Backtransformed parameters:
diff --git a/tests/testthat/test_set_nd.R b/tests/testthat/test_set_nd.R
new file mode 100644
index 00000000..232e7c62
--- /dev/null
+++ b/tests/testthat/test_set_nd.R
@@ -0,0 +1,86 @@
+context("Processing of residue series")
+
+# FOCUS (2014) page 76 (parent) and page 132 (metabolite)
+
+parent_1 <- c(.12, .09, .05, .03, "nd", "nd", "nd", "nd", "nd", "nd")
+parent_2 <- c(.12, .09, .05, .03, "nd", "nd", .03, "nd", "nd", "nd")
+parent_3 <- c(.12, .09, .05, .03, "nd", "nd", .06, "nd", "nd", "nd")
+metabolite <- c("nd", "nd", "nd", 0.03, 0.06, 0.10, 0.11, 0.10, 0.09, 0.05, 0.03, "nd", "nd")
+
+test_that("Simple residue series are processed as intended", {
+
+ expect_equal(set_nd_nq(parent_1, 0.02),
+ c(.12, .09, .05, .03, .01, rep(NA, 5)))
+
+ expect_equal(set_nd_nq(parent_2, 0.02, loq = 0.05),
+ c(.12, .09, .05, .03, .01, .01, .03, .01, NA, NA))
+
+ expect_equal(set_nd_nq(metabolite, 0.02, loq = 0.05),
+ c(NA, NA, .01, .03, .06, .1, .11, .1, .09, .05, .03, .01, NA))
+
+ expect_equal(set_nd_nq(c("nd", 1, 0.2, "nd"), 0.1),
+ c(NA, 1, 0.2, 0.05))
+
+})
+
+test_that("Simple residue series are processed as in the FOCUS guidance", {
+
+ # Parent 1
+ expect_error(set_nd_nq_focus(parent_1, 0.02),
+ "You need to specify an LOQ")
+ expect_equal(set_nd_nq_focus(parent_1, 0.02, 0.05),
+ c(.12, .09, .05, .03, .01, rep(NA, 5)))
+
+ # Parent 2
+ expect_equal(set_nd_nq_focus(parent_2, 0.02, loq = 0.05),
+ c(.12, .09, .05, .03, .01, rep(NA, 5)))
+
+ # Parent 3
+ expect_equal(set_nd_nq_focus(parent_3, 0.02, loq = 0.05),
+ c(.12, .09, .05, .03, .01, .01, .06, .01, NA, NA))
+
+ # Metabolite
+ expect_equal(set_nd_nq_focus(metabolite, 0.02, loq = 0.05),
+ c(0, NA, .01, .03, .06, .1, .11, .1, .09, .05, .03, .01, NA))
+
+})
+
+test_that("Examples Boesten et al. (2015, p. 57/58) are correctly processed", {
+ table_8 <- matrix(
+ c(10, 10, rep("nd", 4),
+ 10, 10, rep("nq", 2), rep("nd", 2),
+ 10, 10, 10, "nq", "nd", "nd",
+ "nq", 10, "nq", rep("nd", 3),
+ "nd", "nq", "nq", rep("nd", 3),
+ rep("nd", 6), rep("nd", 6)),
+ ncol = 6, byrow = TRUE)
+ table_8_processed <- set_nd_nq(table_8, 0.5, 1.5, time_zero_presence = TRUE)
+ table_9 <- matrix(
+ c(10, 10, 0.25, 0.25, NA, NA,
+ 10, 10, 1, 1, 0.25, NA,
+ 10, 10, 10, 1, 0.25, NA,
+ 1, 10, 1, 0.25, NA, NA,
+ 0.25, 1, 1, 0.25, NA, NA,
+ NA, 0.25, 0.25, NA, NA, NA,
+ rep(NA, 6)),
+ ncol = 6, byrow = TRUE)
+ expect_equal(table_8_processed, table_9)
+
+ table_10 <- matrix(
+ c(10, 10, rep("nd", 4),
+ 10, 10, rep("nd", 4),
+ 10, 10, 10, rep("nd", 3),
+ "nd", 10, rep("nd", 4),
+ rep("nd", 18)),
+ ncol = 6, byrow = TRUE)
+ table_10_processed <- set_nd_nq(table_10, 0.5, time_zero_presence = TRUE)
+ table_11 <- matrix(
+ c(10, 10, 0.25, rep(NA, 3),
+ 10, 10, 0.25, rep(NA, 3),
+ 10, 10, 10, 0.25, NA, NA,
+ 0.25, 10, 0.25, rep(NA, 3),
+ NA, 0.25, rep(NA, 4),
+ rep(NA, 12)),
+ ncol = 6, byrow = TRUE)
+ expect_equal(table_10_processed, table_11)
+})

Contact - Imprint