From 7035cde3a53781721fe15a8893fdf328c789bdd2 Mon Sep 17 00:00:00 2001 From: Johannes Ranke Date: Mon, 7 Mar 2022 12:03:40 +0100 Subject: Remove nlmixr interface for release of mkin 1.1.0 I am postponing my attempts to get the nlmixr interface to CRAN, given some problems with nlmixr using R-devel under Windows, see https://github.com/nlmixrdevelopment/nlmixr/issues/596 and https://github.com/r-hub/rhub/issues/512, which is fixed by the removal of nlmixr from the testsuite. For the tests to be more platform independent, the biphasic mixed effects models test dataset was defined in a way that fitting should be more robust (less ill-defined). --- ...t-for-saem-object-with-mkin-transformations.svg | 4392 ++++++++++---------- tests/testthat/print_sfo_saem_1.txt | 16 +- tests/testthat/setup_script.R | 14 +- tests/testthat/summary_nlmixr_saem_biphasic.txt | 97 - tests/testthat/summary_saem_biphasic_s.txt | 40 +- tests/testthat/test_dmta.R | 66 - tests/testthat/test_mixed.R | 17 +- tests/testthat/test_tffm0.R | 10 - 8 files changed, 2231 insertions(+), 2421 deletions(-) delete mode 100644 tests/testthat/summary_nlmixr_saem_biphasic.txt delete mode 100644 tests/testthat/test_tffm0.R (limited to 'tests/testthat') 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 049992de..dc7c1e17 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 @@ - + @@ -141,209 +141,209 @@ - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -352,384 +352,384 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + @@ -739,34 +739,34 @@ - + - - - - - + + + + + 0 -20 -40 -60 -80 -100 - - - - +20 +40 +60 +80 +100 + + + + - - - --3 --2 --1 + + + +-3 +-2 +-1 0 -1 -2 -3 +1 +2 +3 @@ -780,582 +780,582 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -1363,7 +1363,7 @@ - + @@ -1381,17 +1381,17 @@ 80 100 120 - + - - - - + + + + 0 -10 -20 -30 -40 +10 +20 +30 +40 @@ -1404,530 +1404,533 @@ Residues m1 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -1937,32 +1940,32 @@ - + - - - - + + + + 0 -10 -20 -30 -40 - - - - +10 +20 +30 +40 + + + + - - - --3 --2 --1 + + + +-3 +-2 +-1 0 -1 -2 -3 +1 +2 +3 @@ -1976,515 +1979,518 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/tests/testthat/print_sfo_saem_1.txt b/tests/testthat/print_sfo_saem_1.txt index fc6a2148..a11e1e96 100644 --- a/tests/testthat/print_sfo_saem_1.txt +++ b/tests/testthat/print_sfo_saem_1.txt @@ -10,12 +10,10 @@ Likelihood computed by importance sampling 1311 1315 -649 Fitted parameters: - estimate lower upper -parent_0 1e+02 99.13 1e+02 -k_parent 4e-02 0.03 4e-02 -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 7e-01 -1.09 3e+00 -SD.k_parent 3e-01 0.20 4e-01 + estimate lower upper +parent_0 1e+02 99.13 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.k_parent 3e-01 0.20 4e-01 diff --git a/tests/testthat/setup_script.R b/tests/testthat/setup_script.R index ec96fbc2..10696082 100644 --- a/tests/testthat/setup_script.R +++ b/tests/testthat/setup_script.R @@ -160,8 +160,8 @@ DFOP_SFO <- mkinmod( m1 = mkinsub("SFO"), quiet = TRUE) dfop_sfo_pop <- list(parent_0 = 100, - k_m1 = 0.005, f_parent_to_m1 = 0.5, - k1 = 0.05, k2 = 0.01, g = 0.5) + k_m1 = 0.007, f_parent_to_m1 = 0.5, + k1 = 0.1, k2 = 0.02, g = 0.5) syn_biphasic_parms <- as.matrix(data.frame( k1 = rlnorm(n_biphasic, log(dfop_sfo_pop$k1), log_sd), k2 = rlnorm(n_biphasic, log(dfop_sfo_pop$k2), log_sd), @@ -186,11 +186,12 @@ ds_biphasic <- lapply(ds_biphasic_mean, function(ds) { mmkin_sfo_1 <- mmkin("SFO", ds_sfo, quiet = TRUE, error_model = "tc", cores = n_cores) mmkin_dfop_1 <- mmkin("DFOP", ds_dfop, quiet = TRUE, cores = n_cores) mmkin_biphasic <- mmkin(list("DFOP-SFO" = DFOP_SFO), ds_biphasic, quiet = TRUE, cores = n_cores, + control = list(eval.max = 500, iter.max = 400), error_model = "tc") # nlme dfop_nlme_1 <- nlme(mmkin_dfop_1) -nlme_biphasic <- nlme(mmkin_biphasic) +nlme_biphasic <- suppressWarnings(nlme(mmkin_biphasic)) # saemix sfo_saem_1 <- saem(mmkin_sfo_1, quiet = TRUE, transformations = "saemix") @@ -201,13 +202,6 @@ 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) -# nlmixr saem -tmp <- suppressMessages(capture.output(nlmixr_saem_biphasic <- nlmixr(mmkin_biphasic, est = "saem", - control = nlmixr::saemControl(nBurn = 300, nEm = 100, nmc = 9, print = 0)))) -# The FOCEI fit takes too long... -#tmp <- capture_output(nlmixr_focei_biphasic <- nlmixr(mmkin_biphasic, est = "focei", -# control = nlmixr::foceiControl(print = 0))) - # UBA datasets ds_uba <- lapply(experimental_data_for_UBA_2019[6:10], function(x) subset(x$data[c("name", "time", "value")])) diff --git a/tests/testthat/summary_nlmixr_saem_biphasic.txt b/tests/testthat/summary_nlmixr_saem_biphasic.txt deleted file mode 100644 index 144cbac7..00000000 --- a/tests/testthat/summary_nlmixr_saem_biphasic.txt +++ /dev/null @@ -1,97 +0,0 @@ -nlmixr version used for fitting: 2.0.6 -mkin version used for pre-fitting: Dummy 0.0 for testing -R version used for fitting: Dummy R version for testing -Date of fit: Dummy date for testing -Date of summary: Dummy date for testing - -Equations: -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: -507 observations of 2 variable(s) grouped in 15 datasets - -Degradation model predictions using RxODE - -Fitted in test time 0 s - -Variance model: Two-component variance function - -Mean of starting values for individual parameters: - parent_0 log_k_m1 f_parent_qlogis log_k1 log_k2 - 100.65 -5.38 -0.09 -2.74 -4.53 - g_qlogis - -0.14 - -Mean of starting values for error model parameters: -sigma_low_parent rsd_high_parent sigma_low_m1 rsd_high_m1 - 0.79 0.05 0.79 0.05 - -Fixed degradation parameter values: -None - -Results: - -Likelihood calculated by gauss3_1.6 - AIC BIC logLik - 2400 2468 -1184 - -Optimised parameters: - est. lower upper -parent_0 100.35 99.0 101.7 -log_k_m1 -5.35 -5.5 -5.2 -f_parent_qlogis -0.09 -0.3 0.1 -log_k1 -2.76 -3.0 -2.6 -log_k2 -4.49 -4.6 -4.4 -g_qlogis -0.17 -0.4 0.1 - -Correlation: - pr_0 l__1 f_p_ lg_1 lg_2 -log_k_m1 -0.4 -f_parent_qlogis -0.4 0.4 -log_k1 0.2 -0.2 -0.1 -log_k2 0.0 0.1 0.0 0.3 -g_qlogis 0.1 -0.1 0.0 -0.4 -0.5 - -Random effects (omega): - eta.parent_0 eta.log_k_m1 eta.f_parent_qlogis eta.log_k1 -eta.parent_0 0.08 0.00 0.0 0.00 -eta.log_k_m1 0.00 0.02 0.0 0.00 -eta.f_parent_qlogis 0.00 0.00 0.1 0.00 -eta.log_k1 0.00 0.00 0.0 0.09 -eta.log_k2 0.00 0.00 0.0 0.00 -eta.g_qlogis 0.00 0.00 0.0 0.00 - eta.log_k2 eta.g_qlogis -eta.parent_0 0.00 0.0 -eta.log_k_m1 0.00 0.0 -eta.f_parent_qlogis 0.00 0.0 -eta.log_k1 0.00 0.0 -eta.log_k2 0.03 0.0 -eta.g_qlogis 0.00 0.1 - -Variance model: -sigma_low_parent rsd_high_parent sigma_low_m1 rsd_high_m1 - 1.04 0.05 0.82 0.06 - -Backtransformed parameters: - est. lower upper -parent_0 1e+02 1e+02 1e+02 -k_m1 5e-03 4e-03 6e-03 -f_parent_to_m1 5e-01 4e-01 5e-01 -k1 6e-02 5e-02 8e-02 -k2 1e-02 1e-02 1e-02 -g 5e-01 4e-01 5e-01 - -Resulting formation fractions: - ff -parent_m1 0.5 -parent_sink 0.5 - -Estimated disappearance times: - DT50 DT90 DT50back DT50_k1 DT50_k2 -parent 25 150 45 11 61 -m1 145 483 NA NA NA diff --git a/tests/testthat/summary_saem_biphasic_s.txt b/tests/testthat/summary_saem_biphasic_s.txt index a353d821..6b203991 100644 --- a/tests/testthat/summary_saem_biphasic_s.txt +++ b/tests/testthat/summary_saem_biphasic_s.txt @@ -13,7 +13,7 @@ d_m1/dt = + f_parent_to_m1 * ((k1 * g * exp(-k1 * time) + k2 * (1 - g) exp(-k2 * time))) * parent - k_m1 * m1 Data: -507 observations of 2 variable(s) grouped in 15 datasets +510 observations of 2 variable(s) grouped in 15 datasets Model predictions using solution type analytical @@ -24,7 +24,7 @@ Variance model: Two-component variance function Mean of starting values for individual parameters: parent_0 k_m1 f_parent_to_m1 k1 k2 - 1e+02 5e-03 5e-01 6e-02 1e-02 + 1e+02 7e-03 5e-01 1e-01 2e-02 g 5e-01 @@ -35,37 +35,37 @@ Results: Likelihood computed by importance sampling AIC BIC logLik - 2369 2379 -1170 + 2334 2344 -1153 Optimised parameters: est. lower upper parent_0 1e+02 1e+02 1e+02 -k_m1 5e-03 4e-03 6e-03 +k_m1 7e-03 6e-03 7e-03 f_parent_to_m1 5e-01 4e-01 5e-01 -k1 6e-02 5e-02 7e-02 -k2 1e-02 9e-03 1e-02 -g 5e-01 4e-01 5e-01 +k1 1e-01 9e-02 1e-01 +k2 2e-02 2e-02 3e-02 +g 5e-01 5e-01 5e-01 Correlation: pr_0 k_m1 f___ k1 k2 -k_m1 -0.3 -f_parent_to_m1 -0.3 0.3 -k1 0.1 -0.1 -0.1 +k_m1 -0.2 +f_parent_to_m1 -0.3 0.1 +k1 0.1 0.0 0.0 k2 0.0 0.0 0.0 0.1 -g 0.1 -0.1 0.0 -0.3 -0.3 +g 0.1 -0.1 0.0 -0.2 -0.2 Random effects: est. lower upper -SD.parent_0 0.02 -89.53 89.6 -SD.k_m1 0.20 0.07 0.3 -SD.f_parent_to_m1 0.32 0.20 0.4 -SD.k1 0.38 0.23 0.5 -SD.k2 0.33 0.20 0.5 -SD.g 0.26 0.06 0.5 +SD.parent_0 0.03 -49.24 49.3 +SD.k_m1 0.23 0.13 0.3 +SD.f_parent_to_m1 0.30 0.19 0.4 +SD.k1 0.40 0.25 0.5 +SD.k2 0.34 0.21 0.5 +SD.g 0.21 0.06 0.4 Variance model: est. lower upper -a.1 0.90 0.76 1.03 +a.1 0.93 0.79 1.06 b.1 0.05 0.05 0.06 Resulting formation fractions: @@ -75,5 +75,5 @@ parent_sink 0.5 Estimated disappearance times: DT50 DT90 DT50back DT50_k1 DT50_k2 -parent 26 146 44 12 60 -m1 144 478 NA NA NA +parent 13 73 22 6 32 +m1 105 348 NA NA NA diff --git a/tests/testthat/test_dmta.R b/tests/testthat/test_dmta.R index 2927b711..7f0a3a67 100644 --- a/tests/testthat/test_dmta.R +++ b/tests/testthat/test_dmta.R @@ -32,20 +32,6 @@ test_that("Different backends get consistent results for DFOP tc, dimethenamid d saem_saemix_dfop_tc_mkin <- saem(dmta_dfop_tc, transformations = "mkin") ints_saemix_mkin <- intervals(saem_saemix_dfop_tc_mkin) - # nlmixr saem - saem_nlmixr_dfop_tc <- nlmixr(dmta_dfop_tc, est = "saem", - control = nlmixr::saemControl(nBurn = 300, nEm = 100, nmc = 9, print = 0)) - ints_nlmixr_saem <- intervals(saem_nlmixr_dfop_tc) - - # nlmixr focei - # We get three warnings about nudged etas, the initial optimization and - # gradient problems with initial estimate and covariance - # We need to capture output, otherwise it pops up in testthat output - expect_warning(tmp <- capture_output(focei_nlmixr_dfop_tc <- nlmixr( - dmta_dfop_tc, est = "focei", - control = nlmixr::foceiControl(print = 0), all = TRUE))) - ints_nlmixr_focei <- intervals(focei_nlmixr_dfop_tc) - # Fixed effects ## saemix vs. nlme expect_true(all(ints_saemix$fixed[, "est."] > @@ -59,18 +45,6 @@ test_that("Different backends get consistent results for DFOP tc, dimethenamid d expect_true(all(ints_saemix_mkin$fixed[, "est."] < backtransform_odeparms(ints_nlme$fixed[, "upper"], dmta_dfop$mkinmod))) - ## nlmixr saem vs. nlme - expect_true(all(ints_nlmixr_saem$fixed[, "est."] > - backtransform_odeparms(ints_nlme$fixed[, "lower"], dmta_dfop$mkinmod))) - expect_true(all(ints_nlmixr_saem$fixed[, "est."] < - backtransform_odeparms(ints_nlme$fixed[, "upper"], dmta_dfop$mkinmod))) - - ## nlmixr focei vs. nlme - expect_true(all(ints_nlmixr_focei$fixed[, "est."] > - backtransform_odeparms(ints_nlme$fixed[, "lower"], dmta_dfop$mkinmod))) - expect_true(all(ints_nlmixr_focei$fixed[, "est."] < - backtransform_odeparms(ints_nlme$fixed[, "upper"], dmta_dfop$mkinmod))) - # Random effects ## for saemix with saemix transformations, the comparison would be complicated... ## saemix mkin vs. nlme @@ -79,18 +53,6 @@ test_that("Different backends get consistent results for DFOP tc, dimethenamid d expect_true(all(ints_saemix$fixed[, "est."] < backtransform_odeparms(ints_nlme$fixed[, "upper"], dmta_dfop$mkinmod))) - ## nlmixr saem vs. nlme - expect_true(all(ints_nlmixr_saem$random[, "est."] > - backtransform_odeparms(ints_nlme$reStruct$ds[, "lower"], dmta_dfop$mkinmod))) - expect_true(all(ints_nlmixr_saem$random[, "est."] < - backtransform_odeparms(ints_nlme$reStruct$ds[, "upper"], dmta_dfop$mkinmod))) - - ## nlmixr focei vs. nlme - expect_true(all(ints_nlmixr_focei$random[, "est."] > - backtransform_odeparms(ints_nlme$reStruct$ds[, "lower"], dmta_dfop$mkinmod))) - expect_true(all(ints_nlmixr_focei$random[, "est."] < - backtransform_odeparms(ints_nlme$reStruct$ds[, "upper"], dmta_dfop$mkinmod))) - # Variance function # Some of these tests on error model parameters fail on Travis and Winbuilder skip_on_travis() @@ -106,21 +68,6 @@ test_that("Different backends get consistent results for DFOP tc, dimethenamid d ints_nlme$varStruct[, "lower"])) expect_true(all(ints_saemix_mkin[[3]][, "est."] < ints_nlme$varStruct[, "upper"])) - - # nlmixr saem vs. nlme - expect_true(all(ints_nlmixr_saem[[3]][, "est."] > - ints_nlme$varStruct[, "lower"])) - expect_true(all(ints_nlmixr_saem[[3]][, "est."] < - ints_nlme$varStruct[, "upper"])) - - # nlmixr focei vs. nlme - # We only test for the proportional part (rsd_high), as the - # constant part (sigma_low) obtained with nlmixr/FOCEI is below the lower - # bound of the confidence interval obtained with nlme - expect_true(ints_nlmixr_focei[[3]]["rsd_high", "est."] > - ints_nlme$varStruct["prop", "lower"]) - expect_true(ints_nlmixr_focei[[3]]["rsd_high", "est."] < - ints_nlme$varStruct["prop", "upper"]) }) # Compared to the 2020 paper https://doi.org/10.3390/environments8080071 @@ -148,19 +95,6 @@ test_that("Different backends get consistent results for SFO-SFO3+, dimethenamid "Iteration 5, LME step.*not converge") ints_nlme_mets <- intervals(nlme_sfo_sfo3p_tc, which = "fixed") - # The saem fit with nlmixr takes only about 15 seconds - tmp <- capture.output( - saem_nlmixr_sfo_sfo3p_tc <- nlmixr(dmta_sfo_sfo3p_tc, est = "saem", - control = nlmixr::saemControl(print = 0))) - ints_nlmixr_saem_mets <- intervals(saem_nlmixr_sfo_sfo3p_tc) - - # We need to exclude the ilr transformed formation fractions in these - # tests, as they do not have a one to one relation in the transformations - expect_true(all(ints_nlmixr_saem_mets$fixed[, "est."][-c(6, 7, 8)] > - backtransform_odeparms(ints_nlme_mets$fixed[, "lower"][-c(6, 7, 8)], sfo_sfo3p))) - expect_true(all(ints_nlmixr_saem_mets$fixed[, "est."][-c(6, 7, 8)] < - backtransform_odeparms(ints_nlme_mets$fixed[, "upper"], sfo_sfo3p)[-c(6, 7, 8)])) - skip("Fitting this ODE model with saemix takes about 15 minutes on my system") # As DFOP is overparameterised and leads to instabilities and errors, we # need to use SFO. diff --git a/tests/testthat/test_mixed.R b/tests/testthat/test_mixed.R index ae8743af..6fb06656 100644 --- a/tests/testthat/test_mixed.R +++ b/tests/testthat/test_mixed.R @@ -57,7 +57,7 @@ test_that("saemix results are reproducible for biphasic fits", { # k2 is not fitted well ci_dfop_sfo_s_m <- summary(saem_biphasic_m)$confint_back expect_true(all(ci_dfop_sfo_s_m[no_k2, "lower"] < dfop_sfo_pop[no_k2])) - expect_true(all(ci_dfop_sfo_s_m[, "upper"] > dfop_sfo_pop)) + expect_true(all(ci_dfop_sfo_s_m[no_k1, "upper"] > dfop_sfo_pop[no_k1])) # I tried to only do few iterations in routine tests as this is so slow # but then deSolve fails at some point (presumably at the switch between @@ -73,18 +73,3 @@ test_that("saemix results are reproducible for biphasic fits", { expect_true(all(ci_dfop_sfo_s_d[no_k2, "lower"] < dfop_sfo_pop[no_k2])) expect_true(all(ci_dfop_sfo_s_d[no_k1, "upper"] > dfop_sfo_pop[no_k1])) }) - -test_that("nlmixr results are reproducible for biphasic fits", { - - test_summary <- summary(nlmixr_saem_biphasic) - test_summary$saemixversion <- "Dummy 0.0 for testing" - test_summary$mkinversion <- "Dummy 0.0 for testing" - test_summary$Rversion <- "Dummy R version for testing" - test_summary$date.fit <- "Dummy date for testing" - test_summary$date.summary <- "Dummy date for testing" - test_summary$time <- c(elapsed = "test time 0") - - expect_known_output(print(nlmixr_saem_biphasic, digits = 1), "print_nlmixr_saem_biphasic.txt") - expect_known_output(print(test_summary, digits = 1), "summary_nlmixr_saem_biphasic.txt") -}) - diff --git a/tests/testthat/test_tffm0.R b/tests/testthat/test_tffm0.R deleted file mode 100644 index 82e1ee94..00000000 --- a/tests/testthat/test_tffm0.R +++ /dev/null @@ -1,10 +0,0 @@ -test_that("The formation fraction transformation tffm0 is reversible", { - ff_example <- c( - 0.10983681, 0.09035905, 0.08399383 - ) - ff_example_trans <- tffm0(ff_example) - expect_equal(invtffm0(ff_example_trans), ff_example) - - ff_ex_2_trans <- c(0.5, 0.9, 0.99) - expect_true(sum(invtffm0(ff_ex_2_trans)) < 1) -}) -- cgit v1.2.1