From c58c14078f6a30c22863b7b9730f4afc39db4577 Mon Sep 17 00:00:00 2001 From: Johannes Ranke Date: Thu, 10 Dec 2020 09:24:35 +0100 Subject: Add a test for saemix with deSolve But skip the test as it takes too long to always run --- test.log | 25 ++++++++++++++++--------- tests/testthat/setup_script.R | 7 ++++--- tests/testthat/test_mixed.R | 17 ++++++++++++----- 3 files changed, 32 insertions(+), 17 deletions(-) diff --git a/test.log b/test.log index 13fa7e70..186ec590 100644 --- a/test.log +++ b/test.log @@ -6,7 +6,7 @@ Testing mkin ✔ | 2 | Export dataset for reading into CAKE ✔ | 14 | Results for FOCUS D established in expertise for UBA (Ranke 2014) [1.0 s] ✔ | 4 | Calculation of FOCUS chi2 error levels [0.5 s] -✔ | 7 | Fitting the SFORB model [3.7 s] +✔ | 7 | Fitting the SFORB model [3.6 s] ✔ | 5 | Analytical solutions for coupled models [3.3 s] ✔ | 5 | Calculation of Akaike weights ✔ | 14 | Confidence intervals and p-values [1.2 s] @@ -14,24 +14,31 @@ Testing mkin ✔ | 3 | Time step normalisation ✔ | 4 | Test fitting the decline of metabolites from their maximum [0.3 s] ✔ | 1 | Fitting the logistic model [0.2 s] -✔ | 31 | Nonlinear mixed effects models [27.4 s] +✔ | 33 1 | Nonlinear mixed effects models [27.8 s] +──────────────────────────────────────────────────────────────────────────────── +Skip (test_mixed.R:137:3): saem results are reproducible for biphasic fits +Reason: Fitting with saemix takes around 10 minutes when using deSolve +──────────────────────────────────────────────────────────────────────────────── ✔ | 2 | Test dataset classes mkinds and mkindsg ✔ | 1 | mkinfit features [0.3 s] ✔ | 12 | Special cases of mkinfit calls [0.8 s] -✔ | 8 | mkinmod model generation and printing [0.2 s] +✔ | 8 | mkinmod model generation and printing [0.3 s] ✔ | 3 | Model predictions with mkinpredict [0.4 s] -✔ | 16 | Evaluations according to 2015 NAFTA guidance [1.6 s] +✔ | 16 | Evaluations according to 2015 NAFTA guidance [1.7 s] ✔ | 9 | Nonlinear mixed-effects models [7.9 s] ✔ | 16 | Plotting [1.9 s] ✔ | 4 | Residuals extracted from mkinfit models -✔ | 2 | Complex test case from Schaefer et al. (2007) Piacenza paper [1.5 s] +✔ | 2 | Complex test case from Schaefer et al. (2007) Piacenza paper [1.6 s] ✔ | 4 | Summary [0.1 s] ✔ | 1 | Summaries of old mkinfit objects ✔ | 4 | Results for synthetic data established in expertise for UBA (Ranke 2014) [2.3 s] -✔ | 9 | Hypothesis tests [7.5 s] -✔ | 4 | Calculation of maximum time weighted average concentrations (TWAs) [2.3 s] +✔ | 9 | Hypothesis tests [7.3 s] +✔ | 4 | Calculation of maximum time weighted average concentrations (TWAs) [2.4 s] ══ Results ═════════════════════════════════════════════════════════════════════ -Duration: 69.5 s +Duration: 69.7 s -[ FAIL 0 | WARN 0 | SKIP 0 | PASS 204 ] +── Skipped tests ────────────────────────────────────────────────────────────── +● Fitting with saemix takes around 10 minutes when using deSolve (1) + +[ FAIL 0 | WARN 0 | SKIP 1 | PASS 206 ] diff --git a/tests/testthat/setup_script.R b/tests/testthat/setup_script.R index 4a343bc5..cfdc9277 100644 --- a/tests/testthat/setup_script.R +++ b/tests/testthat/setup_script.R @@ -34,9 +34,10 @@ f_1_mkin_notrans <- mkinfit("SFO", FOCUS_2006_A, quiet = TRUE, # mmkin object of parent fits for tests models <- c("SFO", "FOMC", "DFOP", "HS") -fits <- mmkin(models, - list(FOCUS_A = FOCUS_2006_A, FOCUS_C = FOCUS_2006_C, FOCUS_D = FOCUS_2006_D), - quiet = TRUE, cores = n_cores) +fits <- suppressWarnings( # FOCUS A FOMC was, it seems, in testthat output + mmkin(models, + list(FOCUS_A = FOCUS_2006_A, FOCUS_C = FOCUS_2006_C, FOCUS_D = FOCUS_2006_D), + quiet = TRUE, cores = n_cores)) # One metabolite SFO_SFO <- mkinmod(parent = mkinsub("SFO", to = "m1"), diff --git a/tests/testthat/test_mixed.R b/tests/testthat/test_mixed.R index 7798be8a..05632c6f 100644 --- a/tests/testthat/test_mixed.R +++ b/tests/testthat/test_mixed.R @@ -122,17 +122,24 @@ test_that("saem results are reproducible for biphasic fits", { expect_known_output(print(test_summary, digits = 2), "summary_saem_biphasic_s.txt") dfop_sfo_pop <- as.numeric(dfop_sfo_pop) + no_k1 <- c(1, 2, 3, 5, 6) + no_k2 <- c(1, 2, 3, 4, 6) + ci_dfop_sfo_s_s <- summary(saem_biphasic_s)$confint_back expect_true(all(ci_dfop_sfo_s_s[, "lower"] < dfop_sfo_pop)) expect_true(all(ci_dfop_sfo_s_s[, "upper"] > dfop_sfo_pop)) - # The following does not work, as k1 and k2 are not fitted well + # k1 and k2 are not fitted well ci_dfop_sfo_s_m <- summary(saem_biphasic_m)$confint_back - # expect_true(all(ci_dfop_sfo_s_m[, "lower"] < dfop_sfo_pop)) - # expect_true(all(ci_dfop_sfo_s_m[, "upper"] > dfop_sfo_pop)) + expect_true(all(ci_dfop_sfo_s_m[no_k2, "lower"] < dfop_sfo_pop[no_k2])) + expect_true(all(ci_dfop_sfo_s_m[no_k1, "upper"] > dfop_sfo_pop[no_k1])) - # Somehow this does not work at the moment. But it took forever (~ 10 min) anyways... - #saem_biphasic_2 <- saem(mmkin_biphasic, solution_type = "deSolve", quiet = TRUE) + skip("Fitting with saemix takes around 10 minutes when using deSolve") + saem_biphasic_2 <- saem(mmkin_biphasic, solution_type = "deSolve", quiet = TRUE) + # As with the analytical solution, k1 and k2 are not fitted well + ci_dfop_sfo_s_d <- summary(saem_biphasic_2)$confint_back + 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])) }) -- cgit v1.2.1