aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJohannes Ranke <jranke@uni-bremen.de>2020-12-09 10:52:55 +0100
committerJohannes Ranke <jranke@uni-bremen.de>2020-12-09 10:52:55 +0100
commit25fef221d589b5eebe32829633372d785e750d2a (patch)
tree2afd5b929e7d6a12cee19bada564a7905129dea0
parent107ddb89a4a6e0e15d9f82eafcf9eebecf4904ba (diff)
Test print method for mixed.mmkin
-rw-r--r--R/mixed.mmkin.R4
-rw-r--r--tests/testthat/print_mmkin_biphasic_mixed.txt26
-rw-r--r--tests/testthat/setup_script.R1
-rw-r--r--tests/testthat/test_saem.R7
4 files changed, 34 insertions, 4 deletions
diff --git a/R/mixed.mmkin.R b/R/mixed.mmkin.R
index 6fe5130d..7aa5edd5 100644
--- a/R/mixed.mmkin.R
+++ b/R/mixed.mmkin.R
@@ -92,10 +92,10 @@ print.mixed.mmkin <- function(x, digits = max(3, getOption("digits") - 3), ...)
length(unique(x$data$name)), "variable(s) grouped in",
length(unique(x$data$ds)), "datasets\n\n")
- print(x$mmkin)
+ print(x$mmkin, digits = digits)
cat("\nMean fitted parameters:\n")
- print(mean_degparms(x$mmkin))
+ print(mean_degparms(x$mmkin), digits = digits)
invisible(x)
}
diff --git a/tests/testthat/print_mmkin_biphasic_mixed.txt b/tests/testthat/print_mmkin_biphasic_mixed.txt
new file mode 100644
index 00000000..3d92b120
--- /dev/null
+++ b/tests/testthat/print_mmkin_biphasic_mixed.txt
@@ -0,0 +1,26 @@
+Kinetic model fitted by nonlinear regression to each dataset
+Structural model:
+d_parent/dt = - ((k1 * g * exp(-k1 * time) + k2 * (1 - g) * exp(-k2 *
+ time)) / (g * exp(-k1 * time) + (1 - g) * exp(-k2 * time)))
+ * parent
+d_m1/dt = + f_parent_to_m1 * ((k1 * g * exp(-k1 * time) + k2 * (1 - g)
+ * exp(-k2 * time)) / (g * exp(-k1 * time) + (1 - g) *
+ exp(-k2 * time))) * parent - k_m1 * m1
+
+Data:
+509 observations of 2 variable(s) grouped in 15 datasets
+
+<mmkin> object
+Status of individual fits:
+
+ dataset
+model 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
+ DFOP-SFO OK OK OK OK OK OK OK OK OK OK OK OK OK OK OK
+
+OK: No warnings
+
+Mean fitted parameters:
+ parent_0 log_k_m1 f_parent_qlogis log_k1 log_k2
+ 100.700 -6.299 -0.078 -3.094 -3.954
+ g_qlogis
+ 0.027
diff --git a/tests/testthat/setup_script.R b/tests/testthat/setup_script.R
index be4e4658..81f9248d 100644
--- a/tests/testthat/setup_script.R
+++ b/tests/testthat/setup_script.R
@@ -154,6 +154,7 @@ ds_biphasic <- lapply(ds_biphasic_mean, function(ds) {
mmkin_sfo_1 <- mmkin("SFO", ds_sfo, quiet = TRUE, error_model = "tc")
sfo_saemix_1 <- saem(mmkin_sfo_1, quiet = TRUE, transformations = "saemix")
mmkin_biphasic <- mmkin(list("DFOP-SFO" = DFOP_SFO), ds_biphasic, quiet = TRUE)
+mmkin_biphasic_mixed <- mixed(mmkin_biphasic)
nlme_biphasic <- nlme(mmkin_biphasic)
saem_biphasic_m <- saem(mmkin_biphasic, transformations = "mkin", quiet = TRUE)
saem_biphasic_s <- saem(mmkin_biphasic, transformations = "saemix", quiet = TRUE)
diff --git a/tests/testthat/test_saem.R b/tests/testthat/test_saem.R
index 869ca120..aa32d0b5 100644
--- a/tests/testthat/test_saem.R
+++ b/tests/testthat/test_saem.R
@@ -100,9 +100,12 @@ test_that("Parent only models can be fitted with saemix", {
expect_true(all(rel_diff_2 < 0.08))
})
-test_that("Simple models with metabolite can be fitted with saemix", {
-
+test_that("Print methods work", {
expect_known_output(print(sfo_saemix_1, digits = 1), "print_sfo_saemix_1.txt")
+ expect_known_output(print(mmkin_biphasic_mixed, digits = 2), "print_mmkin_biphasic_mixed.txt")
+})
+
+test_that("Saemix results are reproducible", {
test_summary <- summary(saem_biphasic_s)
test_summary$saemixversion <- "Dummy 0.0 for testing"

Contact - Imprint