From d8f31d1323998f33d07535f55c81be380d93ca45 Mon Sep 17 00:00:00 2001 From: Johannes Ranke Date: Wed, 9 Feb 2022 12:19:14 +0100 Subject: Adapt saemix interface to saemix 3.0 on CRAN --- ...t-for-saem-object-with-mkin-transformations.svg | 2310 ++++++++++---------- ...for-saem-object-with-saemix-transformations.svg | 580 ++--- tests/testthat/print_sfo_saem_1.txt | 6 +- tests/testthat/setup_script.R | 14 +- tests/testthat/summary_saem_biphasic_s.txt | 38 +- tests/testthat/test_mixed.R | 4 +- 6 files changed, 1471 insertions(+), 1481 deletions(-) (limited to 'tests') diff --git a/tests/testthat/_snaps/plot/mixed-model-fit-for-saem-object-with-mkin-transformations.svg b/tests/testthat/_snaps/plot/mixed-model-fit-for-saem-object-with-mkin-transformations.svg index 6346a383..5a645478 100644 --- a/tests/testthat/_snaps/plot/mixed-model-fit-for-saem-object-with-mkin-transformations.svg +++ b/tests/testthat/_snaps/plot/mixed-model-fit-for-saem-object-with-mkin-transformations.svg @@ -96,7 +96,7 @@ - + @@ -157,7 +157,7 @@ - + @@ -176,7 +176,7 @@ - + @@ -213,7 +213,7 @@ - + @@ -250,7 +250,7 @@ - + @@ -269,7 +269,7 @@ - + @@ -288,7 +288,7 @@ - + @@ -343,7 +343,7 @@ - + @@ -416,7 +416,7 @@ - + @@ -471,7 +471,7 @@ - + @@ -526,7 +526,7 @@ - + @@ -563,7 +563,7 @@ - + @@ -618,7 +618,7 @@ - + @@ -673,7 +673,7 @@ - + @@ -710,7 +710,7 @@ - + @@ -729,7 +729,7 @@ - + @@ -739,30 +739,30 @@ - + - - - - - + + + + + 0 -20 -40 -60 -80 -100 - - - +20 +40 +60 +80 +100 + + + - - --4 --2 + + +-4 +-2 0 -2 -4 +2 +4 @@ -776,582 +776,582 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -1359,7 +1359,7 @@ - + @@ -1416,7 +1416,7 @@ - + @@ -1431,7 +1431,7 @@ - + @@ -1464,7 +1464,7 @@ - + @@ -1497,7 +1497,7 @@ - + @@ -1514,7 +1514,7 @@ - + @@ -1530,7 +1530,7 @@ - + @@ -1579,7 +1579,7 @@ - + @@ -1644,7 +1644,7 @@ - + @@ -1693,7 +1693,7 @@ - + @@ -1742,7 +1742,7 @@ - + @@ -1775,7 +1775,7 @@ - + @@ -1824,7 +1824,7 @@ - + @@ -1873,7 +1873,7 @@ - + @@ -1906,7 +1906,7 @@ - + @@ -1923,7 +1923,7 @@ - + @@ -1933,28 +1933,28 @@ - + - - - - + + + + 0 -10 -20 -30 -40 - - - +10 +20 +30 +40 + + + - - --4 --2 + + +-4 +-2 0 -2 -4 +2 +4 @@ -1968,515 +1968,515 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/tests/testthat/_snaps/plot/mixed-model-fit-for-saem-object-with-saemix-transformations.svg b/tests/testthat/_snaps/plot/mixed-model-fit-for-saem-object-with-saemix-transformations.svg index 13590b9b..b7d3fb63 100644 --- a/tests/testthat/_snaps/plot/mixed-model-fit-for-saem-object-with-saemix-transformations.svg +++ b/tests/testthat/_snaps/plot/mixed-model-fit-for-saem-object-with-saemix-transformations.svg @@ -51,7 +51,7 @@ - + @@ -108,7 +108,7 @@ - + @@ -127,7 +127,7 @@ - + @@ -160,7 +160,7 @@ - + @@ -201,7 +201,7 @@ - + @@ -218,7 +218,7 @@ - + @@ -228,30 +228,30 @@ - + - - - - - + + + + + 0 -20 -40 -60 -80 -100 - - - +20 +40 +60 +80 +100 + + + - - --4 --2 + + +-4 +-2 0 -2 -4 +2 +4 @@ -265,132 +265,132 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -398,7 +398,7 @@ - + @@ -453,7 +453,7 @@ - + @@ -470,7 +470,7 @@ - + @@ -499,7 +499,7 @@ - + @@ -536,7 +536,7 @@ - + @@ -551,7 +551,7 @@ - + @@ -561,30 +561,30 @@ - + - - - - - + + + + + 0 -5 -10 -15 -20 -25 - - - +5 +10 +15 +20 +25 + + + - - --4 --2 + + +-4 +-2 0 -2 -4 +2 +4 @@ -598,118 +598,118 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/tests/testthat/print_sfo_saem_1.txt b/tests/testthat/print_sfo_saem_1.txt index 3fc9ca3b..fc6a2148 100644 --- a/tests/testthat/print_sfo_saem_1.txt +++ b/tests/testthat/print_sfo_saem_1.txt @@ -11,11 +11,11 @@ Likelihood computed by importance sampling Fitted parameters: estimate lower upper -parent_0 1e+02 98.96 1e+02 +parent_0 1e+02 99.13 1e+02 k_parent 4e-02 0.03 4e-02 -Var.parent_0 8e-01 -1.94 3e+00 +Var.parent_0 5e-01 -2.04 3e+00 Var.k_parent 1e-01 0.03 2e-01 a.1 9e-01 0.75 1e+00 b.1 5e-02 0.04 5e-02 -SD.parent_0 9e-01 -0.67 2e+00 +SD.parent_0 7e-01 -1.09 3e+00 SD.k_parent 3e-01 0.20 4e-01 diff --git a/tests/testthat/setup_script.R b/tests/testthat/setup_script.R index cb3713aa..693a2a25 100644 --- a/tests/testthat/setup_script.R +++ b/tests/testthat/setup_script.R @@ -198,18 +198,8 @@ nlme_biphasic <- nlme(mmkin_biphasic) if (saemix_available) { sfo_saem_1 <- saem(mmkin_sfo_1, quiet = TRUE, transformations = "saemix") - # With default control parameters, we do not get good results with mkin - # transformations here - dfop_saemix_1 <- saem(mmkin_dfop_1, quiet = TRUE, transformations = "mkin", - control = list( - displayProgress = FALSE, print = FALSE, save = FALSE, save.graphs = FALSE, - rw.init = 1, nbiter.saemix = c(600, 100)) - ) - dfop_saemix_2 <- saem(mmkin_dfop_1, quiet = TRUE, transformations = "saemix", - control = list( - displayProgress = FALSE, print = FALSE, save = FALSE, save.graphs = FALSE, - rw.init = 0.5, nbiter.saemix = c(600, 100)) - ) + dfop_saemix_1 <- saem(mmkin_dfop_1, quiet = TRUE, transformations = "mkin") + dfop_saemix_2 <- saem(mmkin_dfop_1, quiet = TRUE, transformations = "saemix") 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/summary_saem_biphasic_s.txt b/tests/testthat/summary_saem_biphasic_s.txt index bab4bf98..995e81c8 100644 --- a/tests/testthat/summary_saem_biphasic_s.txt +++ b/tests/testthat/summary_saem_biphasic_s.txt @@ -34,33 +34,33 @@ Results: Likelihood computed by importance sampling AIC BIC logLik - 2679 2689 -1327 + 2681 2690 -1328 Optimised parameters: est. lower upper parent_0 1.0e+02 1.0e+02 1.0e+02 -k_m1 4.8e-03 4.1e-03 5.5e-03 -f_parent_to_m1 4.8e-01 4.3e-01 5.2e-01 -k1 5.9e-02 4.6e-02 7.2e-02 -k2 1.1e-02 9.0e-03 1.3e-02 -g 4.9e-01 4.3e-01 5.4e-01 +k_m1 4.9e-03 4.2e-03 5.6e-03 +f_parent_to_m1 4.8e-01 4.3e-01 5.3e-01 +k1 6.2e-02 4.7e-02 7.6e-02 +k2 1.2e-02 9.6e-03 1.4e-02 +g 4.6e-01 4.1e-01 5.1e-01 Correlation: prnt_0 k_m1 f_p__1 k1 k2 -k_m1 -0.168 -f_parent_to_m1 -0.141 0.379 -k1 0.139 -0.004 -0.024 -k2 0.055 0.154 0.033 0.246 -g -0.078 -0.206 -0.058 -0.435 -0.601 +k_m1 -0.172 +f_parent_to_m1 -0.144 0.383 +k1 0.132 -0.007 -0.024 +k2 0.044 0.138 0.030 0.197 +g -0.067 -0.212 -0.061 -0.404 -0.531 Random effects: est. lower upper -SD.parent_0 1.1986 0.28 2.12 -SD.k_m1 0.0034 -6.85 6.86 -SD.f_parent_to_m1 0.3369 0.21 0.46 -SD.k1 0.3790 0.24 0.52 -SD.k2 0.2666 0.16 0.37 -SD.g 0.0401 -0.67 0.75 +SD.parent_0 1.2032 0.27 2.13 +SD.k_m1 0.0027 -8.31 8.31 +SD.f_parent_to_m1 0.3358 0.21 0.46 +SD.k1 0.4210 0.26 0.58 +SD.k2 0.2800 0.17 0.39 +SD.g 0.0100 -2.72 2.74 Variance model: est. lower upper @@ -73,5 +73,5 @@ parent_sink 0.52 Estimated disappearance times: DT50 DT90 DT50back DT50_k1 DT50_k2 -parent 25 150 45 12 64 -m1 145 483 NA NA NA +parent 25 146 44 11 60 +m1 142 471 NA NA NA diff --git a/tests/testthat/test_mixed.R b/tests/testthat/test_mixed.R index 9c8a84d7..6ac93295 100644 --- a/tests/testthat/test_mixed.R +++ b/tests/testthat/test_mixed.R @@ -66,9 +66,9 @@ test_that("Parent fits using saemix are correctly implemented", { expect_true(all(rel_diff_mmkin[c("parent_0", "k1")] < 0.20)) expect_true(all(rel_diff_mmkin_tested[c("parent_0", "k1", "k2")] < 0.20)) - # We get < 30% deviations with transformations made in mkin + # We get < 15% deviations with transformations made in mkin rel_diff_1 <- (s_dfop_s1$confint_back[, "est."] - dfop_pop) / dfop_pop - expect_true(all(rel_diff_1 < 0.5)) + expect_true(all(rel_diff_1 < 0.15)) # We get < 20% deviations with transformations made in saemix rel_diff_2 <- (s_dfop_s2$confint_back[, "est."] - dfop_pop) / dfop_pop -- cgit v1.2.1