From 0c18f5de9b2f948d0b5e22a3b3deed16d64d8006 Mon Sep 17 00:00:00 2001 From: Johannes Ranke Date: Tue, 1 Nov 2022 10:39:29 +0100 Subject: Fix illparms tests --- R/illparms.R | 2 +- log/test.log | 57 ++++++++----------------------------- man/illparms.Rd | 2 +- tests/testthat/test_mhmkin.R | 2 +- tests/testthat/test_saemix_parent.R | 6 ++-- 5 files changed, 18 insertions(+), 51 deletions(-) diff --git a/R/illparms.R b/R/illparms.R index 003c6db1..b2d510dc 100644 --- a/R/illparms.R +++ b/R/illparms.R @@ -23,7 +23,7 @@ #' @return For [mkinfit] or [saem] objects, a character vector of parameter #' names. For [mmkin] or [mhmkin] objects, a matrix like object of class #' 'illparms.mmkin' or 'illparms.mhmkin'. -#' @note All objects have printing methods. For the single fits, printing +#' @note All return objects have printing methods. For the single fits, printing #' does not output anything in the case no ill-defined parameters are found. #' @export illparms <- function(object, ...) diff --git a/log/test.log b/log/test.log index 7152c3fe..ab7402b9 100644 --- a/log/test.log +++ b/log/test.log @@ -5,27 +5,18 @@ ✔ | 5 | Calculation of Akaike weights ✔ | 3 | Export dataset for reading into CAKE ✔ | 12 | Confidence intervals and p-values [1.0s] -✔ | 1 12 | Dimethenamid data from 2018 [31.6s] +✔ | 1 12 | Dimethenamid data from 2018 [31.2s] ──────────────────────────────────────────────────────────────────────────────── Skip (test_dmta.R:98:3): Different backends get consistent results for SFO-SFO3+, dimethenamid data Reason: Fitting this ODE model with saemix takes about 15 minutes on my system ──────────────────────────────────────────────────────────────────────────────── -✔ | 14 | Error model fitting [4.8s] +✔ | 14 | Error model fitting [4.9s] ✔ | 5 | Time step normalisation ✔ | 4 | Calculation of FOCUS chi2 error levels [0.6s] ✔ | 14 | Results for FOCUS D established in expertise for UBA (Ranke 2014) [0.8s] ✔ | 4 | Test fitting the decline of metabolites from their maximum [0.3s] ✔ | 1 | Fitting the logistic model [0.2s] -✖ | 1 7 | Batch fitting and diagnosing hierarchical kinetic models [14.4s] -──────────────────────────────────────────────────────────────────────────────── -Failure (test_mhmkin.R:27:3): Multiple hierarchical kinetic models can be fitted and diagnosed -illparms(hfit_sfo_tc) not equal to character(0). -Attributes: < Modes: list, NULL > -Attributes: < Lengths: 1, 0 > -Attributes: < names for target but not for current > -Attributes: < current is not list-like > -target is illparms.saem.mmkin, current is character -──────────────────────────────────────────────────────────────────────────────── +✔ | 8 | Batch fitting and diagnosing hierarchical kinetic models [14.2s] ✔ | 1 12 | Nonlinear mixed-effects models [0.3s] ──────────────────────────────────────────────────────────────────────────────── Skip (test_mixed.R:74:3): saemix results are reproducible for biphasic fits @@ -36,37 +27,13 @@ Reason: Fitting with saemix takes around 10 minutes when using deSolve ✔ | 3 | mkinfit features [0.7s] ✔ | 8 | mkinmod model generation and printing [0.2s] ✔ | 3 | Model predictions with mkinpredict [0.3s] -✔ | 7 | Multistart method for saem.mmkin models [35.7s] -✔ | 16 | Evaluations according to 2015 NAFTA guidance [2.3s] -✔ | 9 | Nonlinear mixed-effects models with nlme [8.6s] -✔ | 16 | Plotting [10.1s] +✔ | 7 | Multistart method for saem.mmkin models [35.3s] +✔ | 16 | Evaluations according to 2015 NAFTA guidance [2.4s] +✔ | 9 | Nonlinear mixed-effects models with nlme [8.8s] +✔ | 16 | Plotting [9.9s] ✔ | 4 | Residuals extracted from mkinfit models -✖ | 3 1 34 | saemix parent models [70.9s] +✔ | 1 37 | saemix parent models [70.3s] ──────────────────────────────────────────────────────────────────────────────── -Failure (test_saemix_parent.R:12:3): Parent fits using saemix are correctly implemented -illparms(sfo_saem_1) not equal to "sd(parent_0)". -Attributes: < Modes: list, NULL > -Attributes: < Lengths: 1, 0 > -Attributes: < names for target but not for current > -Attributes: < current is not list-like > -target is illparms.saem.mmkin, current is character - -Failure (test_saemix_parent.R:14:3): Parent fits using saemix are correctly implemented -illparms(sfo_saem_1_reduced) not equal to character(0). -Attributes: < Modes: list, NULL > -Attributes: < Lengths: 1, 0 > -Attributes: < names for target but not for current > -Attributes: < current is not list-like > -target is illparms.saem.mmkin, current is character - -Failure (test_saemix_parent.R:25:3): Parent fits using saemix are correctly implemented -illparms(sfo_saem_1_mkin) not equal to "sd(parent_0)". -Attributes: < Modes: list, NULL > -Attributes: < Lengths: 1, 0 > -Attributes: < names for target but not for current > -Attributes: < current is not list-like > -target is illparms.saem.mmkin, current is character - Skip (test_saemix_parent.R:153:3): We can also use mkin solution methods for saem Reason: This still takes almost 2.5 minutes although we do not solve ODEs ──────────────────────────────────────────────────────────────────────────────── @@ -75,16 +42,16 @@ Reason: This still takes almost 2.5 minutes although we do not solve ODEs ✔ | 7 | Fitting the SFORB model [3.7s] ✔ | 1 | Summaries of old mkinfit objects ✔ | 5 | Summary [0.2s] -✔ | 4 | Results for synthetic data established in expertise for UBA (Ranke 2014) [2.1s] +✔ | 4 | Results for synthetic data established in expertise for UBA (Ranke 2014) [2.2s] ✔ | 9 | Hypothesis tests [8.0s] -✔ | 4 | Calculation of maximum time weighted average concentrations (TWAs) [2.3s] +✔ | 4 | Calculation of maximum time weighted average concentrations (TWAs) [2.2s] ══ Results ═════════════════════════════════════════════════════════════════════ -Duration: 204.9 s +Duration: 203.2 s ── Skipped tests ────────────────────────────────────────────────────────────── • Fitting this ODE model with saemix takes about 15 minutes on my system (1) • Fitting with saemix takes around 10 minutes when using deSolve (1) • This still takes almost 2.5 minutes although we do not solve ODEs (1) -[ FAIL 4 | WARN 0 | SKIP 3 | PASS 259 ] +[ FAIL 0 | WARN 0 | SKIP 3 | PASS 263 ] diff --git a/man/illparms.Rd b/man/illparms.Rd index ebc3185a..98ac7aa3 100644 --- a/man/illparms.Rd +++ b/man/illparms.Rd @@ -59,7 +59,7 @@ the confidence intervals for the error model parameters include zero. } \note{ -All objects have printing methods. For the single fits, printing +All return objects have printing methods. For the single fits, printing does not output anything in the case no ill-defined parameters are found. } \examples{ diff --git a/tests/testthat/test_mhmkin.R b/tests/testthat/test_mhmkin.R index 72b81fec..9fd29c50 100644 --- a/tests/testthat/test_mhmkin.R +++ b/tests/testthat/test_mhmkin.R @@ -24,7 +24,7 @@ test_that("Multiple hierarchical kinetic models can be fitted and diagnosed", { hfit_sfo_tc <- update(hfits[["SFO", "tc"]], covariance.model = diag(c(0, 1))) - expect_equal(illparms(hfit_sfo_tc), character(0)) + expect_equal(as.character(illparms(hfit_sfo_tc)), character(0)) expect_silent(print(illparms(hfit_sfo_tc))) test_summary <- summary(hfit_sfo_tc) diff --git a/tests/testthat/test_saemix_parent.R b/tests/testthat/test_saemix_parent.R index e7574b01..79c5fa69 100644 --- a/tests/testthat/test_saemix_parent.R +++ b/tests/testthat/test_saemix_parent.R @@ -9,9 +9,9 @@ test_that("Parent fits using saemix are correctly implemented", { # mmkin_sfo_1 was generated in the setup script # We did not introduce variance of parent_0 in the data generation # This is correctly detected - expect_equal(illparms(sfo_saem_1), "sd(parent_0)") + expect_equal(as.character(illparms(sfo_saem_1)), "sd(parent_0)") # So we have also done a fit without this variance - expect_equal(illparms(sfo_saem_1_reduced), character(0)) + expect_equal(as.character(illparms(sfo_saem_1_reduced)), character(0)) expect_silent(print(illparms(sfo_saem_1_reduced))) # We cannot currently do the fit with completely fixed initial values @@ -22,7 +22,7 @@ test_that("Parent fits using saemix are correctly implemented", { expect_error(update(mmkin_sfo_1, models = c("SFOOO")), "Please supply models.*") sfo_saem_1_mkin <- saem(mmkin_sfo_1, quiet = TRUE, transformations = "mkin") - expect_equal(illparms(sfo_saem_1_mkin), "sd(parent_0)") + expect_equal(as.character(illparms(sfo_saem_1_mkin)), "sd(parent_0)") sfo_saem_1_reduced_mkin <- update(sfo_saem_1_mkin, no_random_effect = "parent_0") # The endpoints obtained do not depend on the transformation -- cgit v1.2.1