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 --- DESCRIPTION | 4 +- GNUmakefile | 1 + R/intervals.R | 2 + R/plot.mixed.mmkin.R | 5 +- R/saem.R | 9 +- check.log | 2 +- man/intervals.nlmixr.mmkin.Rd | 2 + man/intervals.saem.mmkin.Rd | 2 + test.log | 165 +- ...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 +- vignettes/FOCUS_D.html | 6 +- vignettes/FOCUS_L.html | 36 +- vignettes/mkin.html | 6 +- vignettes/twa.html | 2 +- 19 files changed, 1674 insertions(+), 1520 deletions(-) diff --git a/DESCRIPTION b/DESCRIPTION index d216d6fb..7732e7c6 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -2,7 +2,7 @@ Package: mkin Type: Package Title: Kinetic Evaluation of Chemical Degradation Data Version: 1.1.0 -Date: 2021-10-01 +Date: 2022-02-09 Authors@R: c( person("Johannes", "Ranke", role = c("aut", "cre", "cph"), email = "jranke@uni-bremen.de", @@ -24,7 +24,7 @@ Description: Calculation routines based on the FOCUS Kinetics Report (2006, purpose. Depends: R (>= 2.15.1), parallel Imports: stats, graphics, methods, deSolve, R6, inline (>= 0.3.19), numDeriv, - dplyr, lmtest, pkgbuild, nlme (>= 3.1-151), purrr, saemix, nlmixr + dplyr, lmtest, pkgbuild, nlme (>= 3.1-151), purrr, saemix (>= 3.0), nlmixr Suggests: knitr, rbenchmark, tikzDevice, testthat, rmarkdown, covr, vdiffr, benchmarkme, tibble, stats4 License: GPL diff --git a/GNUmakefile b/GNUmakefile index 39270cb3..5f2b9bda 100644 --- a/GNUmakefile +++ b/GNUmakefile @@ -80,6 +80,7 @@ clean: test: install "$(RBIN)/Rscript" -e 'devtools::test()' 2>&1 | tee test.log + # The following does not have the desired effect with current testthat sed -i -e "s/\r.*\r//" test.log devtest: install diff --git a/R/intervals.R b/R/intervals.R index e2d342f0..8ab2b7ec 100644 --- a/R/intervals.R +++ b/R/intervals.R @@ -10,6 +10,7 @@ nlme::intervals #' @param backtransform In case the model was fitted with mkin transformations, #' should we backtransform the parameters where a one to one correlation #' between transformed and backtransformed parameters exists? +#' @param \dots For compatibility with the generic method #' @return An object with 'intervals.saem.mmkin' and 'intervals.lme' in the #' class attribute #' @export @@ -101,6 +102,7 @@ intervals.saem.mmkin <- function(object, level = 0.95, backtransform = TRUE, ... #' @param level The confidence level. #' @param backtransform Should we backtransform the parameters where a one to #' one correlation between transformed and backtransformed parameters exists? +#' @param \dots For compatibility with the generic method #' @importFrom nlme intervals #' @return An object with 'intervals.saem.mmkin' and 'intervals.lme' in the #' class attribute diff --git a/R/plot.mixed.mmkin.R b/R/plot.mixed.mmkin.R index 1ac62b07..2903a05c 100644 --- a/R/plot.mixed.mmkin.R +++ b/R/plot.mixed.mmkin.R @@ -104,8 +104,9 @@ plot.mixed.mmkin <- function(x, if (inherits(x, "saem.mmkin")) { if (x$transformations == "saemix") backtransform = FALSE - degparms_i <- saemix::psi(x$so) - rownames(degparms_i) <- ds_names + psi <- saemix::psi(x$so) + rownames(psi) <- x$saemix_ds_order + degparms_i <- psi[ds_names, ] degparms_i_names <- setdiff(x$so@results@name.fixed, names(fit_1$errparms)) colnames(degparms_i) <- degparms_i_names residual_type = ifelse(standardized, "standardized", "residual") diff --git a/R/saem.R b/R/saem.R index 2c20f788..a8b9a67d 100644 --- a/R/saem.R +++ b/R/saem.R @@ -158,9 +158,14 @@ saem.mmkin <- function(object, } return_data <- nlme_data(object) + saemix_data_ds <- f_saemix@data@data$ds + mkin_ds_order <- as.character(unique(return_data$ds)) + saemix_ds_order <- unique(saemix_data_ds) + psi <- saemix::psi(f_saemix) + rownames(psi) <- saemix_ds_order return_data$predicted <- f_saemix@model@model( - psi = saemix::psi(f_saemix), + psi = psi[mkin_ds_order, ], id = as.numeric(return_data$ds), xidep = return_data[c("time", "name")]) @@ -184,6 +189,8 @@ saem.mmkin <- function(object, bparms.optim = bparms_optim, bparms.fixed = object[[1]]$bparms.fixed, data = return_data, + mkin_ds_order = mkin_ds_order, + saemix_ds_order = saemix_ds_order, err_mod = object[[1]]$err_mod, date.fit = date(), saemixversion = as.character(utils::packageVersion("saemix")), diff --git a/check.log b/check.log index 5acb6a4d..b911d8a1 100644 --- a/check.log +++ b/check.log @@ -1,5 +1,5 @@ * using log directory ‘/home/jranke/git/mkin/mkin.Rcheck’ -* using R version 4.1.1 (2021-08-10) +* using R version 4.1.2 (2021-11-01) * using platform: x86_64-pc-linux-gnu (64-bit) * using session charset: UTF-8 * using options ‘--no-tests --as-cran’ diff --git a/man/intervals.nlmixr.mmkin.Rd b/man/intervals.nlmixr.mmkin.Rd index b1ab5da4..e6da8901 100644 --- a/man/intervals.nlmixr.mmkin.Rd +++ b/man/intervals.nlmixr.mmkin.Rd @@ -13,6 +13,8 @@ \item{backtransform}{Should we backtransform the parameters where a one to one correlation between transformed and backtransformed parameters exists?} + +\item{\dots}{For compatibility with the generic method} } \value{ An object with 'intervals.saem.mmkin' and 'intervals.lme' in the diff --git a/man/intervals.saem.mmkin.Rd b/man/intervals.saem.mmkin.Rd index 4a41dd1b..adc77b59 100644 --- a/man/intervals.saem.mmkin.Rd +++ b/man/intervals.saem.mmkin.Rd @@ -15,6 +15,8 @@ is available in the saemix object} \item{backtransform}{In case the model was fitted with mkin transformations, should we backtransform the parameters where a one to one correlation between transformed and backtransformed parameters exists?} + +\item{\dots}{For compatibility with the generic method} } \value{ An object with 'intervals.saem.mmkin' and 'intervals.lme' in the diff --git a/test.log b/test.log index 4d5012a0..019305bf 100644 --- a/test.log +++ b/test.log @@ -2,41 +2,190 @@ Loading required package: parallel ℹ Testing mkin ✔ | F W S OK | Context + +⠏ | 0 | AIC +⠏ | 0 | AIC calculation ✔ | 5 | AIC calculation -✔ | 5 | Analytical solutions for coupled models [3.5s] + +⠏ | 0 | analytical +⠏ | 0 | Analytical solutions for coupled models +⠋ | 1 | Analytical solutions for coupled models +⠙ | 2 | Analytical solutions for coupled models +⠹ | 3 | Analytical solutions for coupled models +⠸ | 4 | Analytical solutions for coupled models +⠼ | 5 | Analytical solutions for coupled models +✔ | 5 | Analytical solutions for coupled models [3.4s] + +⠏ | 0 | aw +⠏ | 0 | Calculation of Akaike weights ✔ | 5 | Calculation of Akaike weights + +⠏ | 0 | CAKE_export +⠏ | 0 | Export dataset for reading into CAKE ✔ | 2 | Export dataset for reading into CAKE + +⠏ | 0 | confidence +⠏ | 0 | Confidence intervals and p-values +⠼ | 5 | Confidence intervals and p-values +⠋ | 11 | Confidence intervals and p-values +⠙ | 12 | Confidence intervals and p-values ✔ | 12 | Confidence intervals and p-values [1.0s] -✔ | 14 | Error model fitting [5.0s] + +⠏ | 0 | error_models +⠏ | 0 | Error model fitting +⠹ | 3 | Error model fitting +⠸ | 4 | Error model fitting +⠼ | 5 | Error model fitting +⠴ | 6 | Error model fitting +⠧ | 8 | Error model fitting +⠏ | 10 | Error model fitting +⠙ | 12 | Error model fitting +⠸ | 14 | Error model fitting +✔ | 14 | Error model fitting [4.9s] + +⠏ | 0 | f_time_norm +⠏ | 0 | Time step normalisation ✔ | 5 | Time step normalisation + +⠏ | 0 | FOCUS_chi2_error_level +⠏ | 0 | Calculation of FOCUS chi2 error levels +⠙ | 2 | Calculation of FOCUS chi2 error levels +⠸ | 4 | Calculation of FOCUS chi2 error levels ✔ | 4 | Calculation of FOCUS chi2 error levels [0.6s] + +⠏ | 0 | FOCUS_D_UBA_expertise +⠏ | 0 | Results for FOCUS D established in expertise for UBA (Ranke 2014) +⠋ | 1 | Results for FOCUS D established in expertise for UBA (Ranke 2014) +⠧ | 8 | Results for FOCUS D established in expertise for UBA (Ranke 2014) +⠏ | 10 | Results for FOCUS D established in expertise for UBA (Ranke 2014) ✔ | 14 | Results for FOCUS D established in expertise for UBA (Ranke 2014) [0.8s] + +⠏ | 0 | from_max_mean +⠏ | 0 | Test fitting the decline of metabolites from their maximum +⠹ | 3 | Test fitting the decline of metabolites from their maximum +⠸ | 4 | Test fitting the decline of metabolites from their maximum ✔ | 4 | Test fitting the decline of metabolites from their maximum [0.3s] + +⠏ | 0 | logistic +⠏ | 0 | Fitting the logistic model +⠋ | 1 | Fitting the logistic model ✔ | 1 | Fitting the logistic model [0.2s] -✔ | 1 35 | Nonlinear mixed-effects models [26.8s] + +⠏ | 0 | mixed +⠏ | 0 | Nonlinear mixed-effects models +⠙ | 2 | Nonlinear mixed-effects models +⠹ | 3 | Nonlinear mixed-effects models +⠸ | 4 | Nonlinear mixed-effects models +⠏ | 10 | Nonlinear mixed-effects models +⠙ | 12 | Nonlinear mixed-effects models +⠧ | 18 | Nonlinear mixed-effects models +⠙ | 22 | Nonlinear mixed-effects models +⠹ | 23 | Nonlinear mixed-effects models +✔ | 1 35 | Nonlinear mixed-effects models [26.6s] ──────────────────────────────────────────────────────────────────────────────── Skip (test_mixed.R:161:3): saem results are reproducible for biphasic fits Reason: Fitting with saemix takes around 10 minutes when using deSolve ──────────────────────────────────────────────────────────────────────────────── + +⠏ | 0 | mkinds +⠏ | 0 | Test dataset classes mkinds and mkindsg ✔ | 2 | Test dataset classes mkinds and mkindsg + +⠏ | 0 | mkinfit_errors +⠏ | 0 | Special cases of mkinfit calls +⠇ | 9 | Special cases of mkinfit calls +⠏ | 10 | Special cases of mkinfit calls ✔ | 10 | Special cases of mkinfit calls [0.4s] -✔ | 1 | mkinfit features [0.4s] + +⠏ | 0 | mkinfit +⠏ | 0 | mkinfit features +⠋ | 1 | mkinfit features +✔ | 1 | mkinfit features [0.3s] + +⠏ | 0 | mkinmod +⠏ | 0 | mkinmod model generation and printing +⠧ | 8 | mkinmod model generation and printing ✔ | 8 | mkinmod model generation and printing [0.2s] + +⠏ | 0 | mkinpredict_SFO_SFO +⠏ | 0 | Model predictions with mkinpredict +⠋ | 1 | Model predictions with mkinpredict ✔ | 3 | Model predictions with mkinpredict [0.3s] + +⠏ | 0 | nafta +⠏ | 0 | Evaluations according to 2015 NAFTA guidance +⠙ | 2 | Evaluations according to 2015 NAFTA guidance +⠇ | 9 | Evaluations according to 2015 NAFTA guidance +⠏ | 10 | Evaluations according to 2015 NAFTA guidance ✔ | 16 | Evaluations according to 2015 NAFTA guidance [1.5s] -✔ | 9 | Nonlinear mixed-effects models with nlme [8.2s] + +⠏ | 0 | nlme +⠏ | 0 | Nonlinear mixed-effects models with nlme +⠋ | 1 | Nonlinear mixed-effects models with nlme +⠙ | 2 | Nonlinear mixed-effects models with nlme +⠼ | 5 | Nonlinear mixed-effects models with nlme +⠴ | 6 | Nonlinear mixed-effects models with nlme +⠧ | 8 | Nonlinear mixed-effects models with nlme +⠇ | 9 | Nonlinear mixed-effects models with nlme +✔ | 9 | Nonlinear mixed-effects models with nlme [8.3s] + +⠏ | 0 | nlmixr +⠏ | 0 | plot +⠏ | 0 | Plotting +⠋ | 1 | Plotting +⠇ | 9 | Plotting +⠹ | 13 | Plotting +⠼ | 15 | Plotting ✔ | 16 | Plotting [1.3s] + +⠏ | 0 | residuals +⠏ | 0 | Residuals extracted from mkinfit models ✔ | 4 | Residuals extracted from mkinfit models + +⠏ | 0 | schaefer07_complex_case +⠏ | 0 | Complex test case from Schaefer et al. (2007) Piacenza paper +⠋ | 1 | Complex test case from Schaefer et al. (2007) Piacenza paper ✔ | 2 | Complex test case from Schaefer et al. (2007) Piacenza paper [1.5s] -✔ | 7 | Fitting the SFORB model [3.8s] + +⠏ | 0 | SFORB +⠏ | 0 | Fitting the SFORB model +⠋ | 1 | Fitting the SFORB model +⠼ | 5 | Fitting the SFORB model +✔ | 7 | Fitting the SFORB model [3.9s] + +⠏ | 0 | summary_old_objects +⠏ | 0 | Summaries of old mkinfit objects ✔ | 1 | Summaries of old mkinfit objects + +⠏ | 0 | summary +⠏ | 0 | Summary +⠸ | 4 | Summary ✔ | 4 | Summary [0.1s] + +⠏ | 0 | synthetic_data_for_UBA_2014 +⠏ | 0 | Results for synthetic data established in expertise for UBA (Ranke 2014) +⠋ | 1 | Results for synthetic data established in expertise for UBA (Ranke 2014) +⠹ | 3 | Results for synthetic data established in expertise for UBA (Ranke 2014) ✔ | 4 | Results for synthetic data established in expertise for UBA (Ranke 2014) [2.3s] -✔ | 9 | Hypothesis tests [8.6s] + +⠏ | 0 | tests +⠏ | 0 | Hypothesis tests +⠼ | 5 | Hypothesis tests +⠴ | 6 | Hypothesis tests +⠧ | 8 | Hypothesis tests +⠇ | 9 | Hypothesis tests +✔ | 9 | Hypothesis tests [8.5s] + +⠏ | 0 | twa +⠏ | 0 | Calculation of maximum time weighted average concentrations (TWAs) +⠋ | 1 | Calculation of maximum time weighted average concentrations (TWAs) +⠙ | 2 | Calculation of maximum time weighted average concentrations (TWAs) +⠹ | 3 | Calculation of maximum time weighted average concentrations (TWAs) +⠸ | 4 | Calculation of maximum time weighted average concentrations (TWAs) ✔ | 4 | Calculation of maximum time weighted average concentrations (TWAs) [2.2s] ══ Results ═════════════════════════════════════════════════════════════════════ -Duration: 69.5 s +Duration: 69.0 s ── Skipped tests ────────────────────────────────────────────────────────────── • Fitting with saemix takes around 10 minutes when using deSolve (1) 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 diff --git a/vignettes/FOCUS_D.html b/vignettes/FOCUS_D.html index d9127473..0bec44c5 100644 --- a/vignettes/FOCUS_D.html +++ b/vignettes/FOCUS_D.html @@ -360,7 +360,7 @@ pre code {

Example evaluation of FOCUS Example Dataset D

Johannes Ranke

-

Last change 31 January 2019 (rebuilt 2021-11-17)

+

Last change 31 January 2019 (rebuilt 2022-02-08)

@@ -436,8 +436,8 @@ print(FOCUS_2006_D)
summary(fit)
## mkin version used for fitting:    1.1.0 
 ## R version used for fitting:       4.1.2 
-## Date of fit:     Wed Nov 17 12:15:48 2021 
-## Date of summary: Wed Nov 17 12:15:49 2021 
+## Date of fit:     Tue Feb  8 17:20:25 2022 
+## Date of summary: Tue Feb  8 17:20:26 2022 
 ## 
 ## Equations:
 ## d_parent/dt = - k_parent * parent
diff --git a/vignettes/FOCUS_L.html b/vignettes/FOCUS_L.html
index 96a823cf..4a66985e 100644
--- a/vignettes/FOCUS_L.html
+++ b/vignettes/FOCUS_L.html
@@ -1513,7 +1513,7 @@ div.tocify {
 
 

Example evaluation of FOCUS Laboratory Data L1 to L3

Johannes Ranke

-

Last change 17 November 2016 (rebuilt 2021-11-17)

+

Last change 17 November 2016 (rebuilt 2022-02-08)

@@ -1534,8 +1534,8 @@ FOCUS_2006_L1_mkin <- mkin_wide_to_long(FOCUS_2006_L1)
summary(m.L1.SFO)
## mkin version used for fitting:    1.1.0 
 ## R version used for fitting:       4.1.2 
-## Date of fit:     Wed Nov 17 12:15:51 2021 
-## Date of summary: Wed Nov 17 12:15:51 2021 
+## Date of fit:     Tue Feb  8 17:20:28 2022 
+## Date of summary: Tue Feb  8 17:20:28 2022 
 ## 
 ## Equations:
 ## d_parent/dt = - k_parent * parent
@@ -1635,15 +1635,15 @@ summary(m.L1.SFO)
## doubtful
## mkin version used for fitting:    1.1.0 
 ## R version used for fitting:       4.1.2 
-## Date of fit:     Wed Nov 17 12:15:51 2021 
-## Date of summary: Wed Nov 17 12:15:51 2021 
+## Date of fit:     Tue Feb  8 17:20:28 2022 
+## Date of summary: Tue Feb  8 17:20:28 2022 
 ## 
 ## Equations:
 ## d_parent/dt = - (alpha/beta) * 1/((time/beta) + 1) * parent
 ## 
 ## Model predictions using solution type analytical 
 ## 
-## Fitted using 369 model solutions performed in 0.082 s
+## Fitted using 369 model solutions performed in 0.081 s
 ## 
 ## Error model: Constant variance 
 ## 
@@ -1740,8 +1740,8 @@ plot(m.L2.FOMC, show_residuals = TRUE,
 
summary(m.L2.FOMC, data = FALSE)
## mkin version used for fitting:    1.1.0 
 ## R version used for fitting:       4.1.2 
-## Date of fit:     Wed Nov 17 12:15:52 2021 
-## Date of summary: Wed Nov 17 12:15:52 2021 
+## Date of fit:     Tue Feb  8 17:20:28 2022 
+## Date of summary: Tue Feb  8 17:20:28 2022 
 ## 
 ## Equations:
 ## d_parent/dt = - (alpha/beta) * 1/((time/beta) + 1) * parent
@@ -1818,8 +1818,8 @@ plot(m.L2.DFOP, show_residuals = TRUE, show_errmin = TRUE,
 
summary(m.L2.DFOP, data = FALSE)
## mkin version used for fitting:    1.1.0 
 ## R version used for fitting:       4.1.2 
-## Date of fit:     Wed Nov 17 12:15:52 2021 
-## Date of summary: Wed Nov 17 12:15:52 2021 
+## Date of fit:     Tue Feb  8 17:20:29 2022 
+## Date of summary: Tue Feb  8 17:20:29 2022 
 ## 
 ## Equations:
 ## d_parent/dt = - ((k1 * g * exp(-k1 * time) + k2 * (1 - g) * exp(-k2 *
@@ -1828,7 +1828,7 @@ plot(m.L2.DFOP, show_residuals = TRUE, show_errmin = TRUE,
 ## 
 ## Model predictions using solution type analytical 
 ## 
-## Fitted using 581 model solutions performed in 0.134 s
+## Fitted using 581 model solutions performed in 0.136 s
 ## 
 ## Error model: Constant variance 
 ## 
@@ -1918,8 +1918,8 @@ plot(mm.L3)
summary(mm.L3[["DFOP", 1]])
## mkin version used for fitting:    1.1.0 
 ## R version used for fitting:       4.1.2 
-## Date of fit:     Wed Nov 17 12:15:52 2021 
-## Date of summary: Wed Nov 17 12:15:52 2021 
+## Date of fit:     Tue Feb  8 17:20:29 2022 
+## Date of summary: Tue Feb  8 17:20:29 2022 
 ## 
 ## Equations:
 ## d_parent/dt = - ((k1 * g * exp(-k1 * time) + k2 * (1 - g) * exp(-k2 *
@@ -1928,7 +1928,7 @@ plot(mm.L3)
## ## Model predictions using solution type analytical ## -## Fitted using 376 model solutions performed in 0.08 s +## Fitted using 376 model solutions performed in 0.078 s ## ## Error model: Constant variance ## @@ -2026,8 +2026,8 @@ plot(mm.L4)
summary(mm.L4[["SFO", 1]], data = FALSE)
## mkin version used for fitting:    1.1.0 
 ## R version used for fitting:       4.1.2 
-## Date of fit:     Wed Nov 17 12:15:53 2021 
-## Date of summary: Wed Nov 17 12:15:53 2021 
+## Date of fit:     Tue Feb  8 17:20:29 2022 
+## Date of summary: Tue Feb  8 17:20:30 2022 
 ## 
 ## Equations:
 ## d_parent/dt = - k_parent * parent
@@ -2090,8 +2090,8 @@ plot(mm.L4)
summary(mm.L4[["FOMC", 1]], data = FALSE)
## mkin version used for fitting:    1.1.0 
 ## R version used for fitting:       4.1.2 
-## Date of fit:     Wed Nov 17 12:15:53 2021 
-## Date of summary: Wed Nov 17 12:15:53 2021 
+## Date of fit:     Tue Feb  8 17:20:30 2022 
+## Date of summary: Tue Feb  8 17:20:30 2022 
 ## 
 ## Equations:
 ## d_parent/dt = - (alpha/beta) * 1/((time/beta) + 1) * parent
diff --git a/vignettes/mkin.html b/vignettes/mkin.html
index 58d49112..8a1a7641 100644
--- a/vignettes/mkin.html
+++ b/vignettes/mkin.html
@@ -1591,12 +1591,12 @@ div.tocify {
 
 

Introduction to mkin

Johannes Ranke

-

Last change 15 February 2021 (rebuilt 2021-09-16)

+

Last change 15 February 2021 (rebuilt 2022-02-08)

-

Wissenschaftlicher Berater, Kronacher Str. 12, 79639 Grenzach-Wyhlen, Germany
Privatdozent at the University of Bremen

+

Wissenschaftlicher Berater, Kronacher Str. 12, 79639 Grenzach-Wyhlen, Germany
Privatdozent at the University of Freiburg

Abstract

In the regulatory evaluation of chemical substances like plant protection products (pesticides), biocides and other chemicals, degradation data play an important role. For the evaluation of pesticide degradation experiments, detailed guidance has been developed, based on nonlinear optimisation. The R add-on package mkin implements fitting some of the models recommended in this guidance from within R and calculates some statistical measures for data series within one or more compartments, for parent and metabolites.

@@ -1713,7 +1713,7 @@ plot_sep(f_SFO_SFO_SFO, lpos = c("topright", "bottomright",

Schäfer, D., B. Mikolasch, P. Rainbird, and B. Harvey. 2007. “KinGUI: A New Kinetic Software Tool for Evaluations According to FOCUS Degradation Kinetics.” In Proceedings of the Xiii Symposium Pesticide Chemistry, edited by Del Re A. A. M., Capri E., Fragoulis G., and Trevisan M., 916–23. Piacenza.

-

Soetaert, Karline, and Thomas Petzoldt. 2010. “Inverse Modelling, Sensitivity and Monte Carlo Analysis in R Using Package FME.” Journal of Statistical Software 33 (3): 1–28. https://www.jstatsoft.org/v33/i03/.

+

Soetaert, Karline, and Thomas Petzoldt. 2010. “Inverse Modelling, Sensitivity and Monte Carlo Analysis in R Using Package FME.” Journal of Statistical Software 33 (3): 1–28. https://doi.org/10.18637/jss.v033.i03.

diff --git a/vignettes/twa.html b/vignettes/twa.html index 25a4c396..dc8f685f 100644 --- a/vignettes/twa.html +++ b/vignettes/twa.html @@ -253,7 +253,7 @@ code > span.er { color: #a61717; background-color: #e3d2d2; }

Calculation of time weighted average concentrations with mkin

Johannes Ranke

-

Last change 18 September 2019 (rebuilt 2021-09-16)

+

Last change 18 September 2019 (rebuilt 2022-02-08)

-- cgit v1.2.1