From e5d1df9a9b1f0951d7dfbaf24eee4294470b73e2 Mon Sep 17 00:00:00 2001 From: Johannes Ranke Date: Thu, 17 Nov 2022 14:54:20 +0100 Subject: Complete update of online docs for v1.2.0 --- NEWS.md | 2 +- _pkgdown.yml | 4 +- custom_lsoda_call.patch | 1587 ++++++++++++++++++++ custom_lsoda_call_edited.patch | 116 ++ docs/404.html | 12 +- docs/articles/FOCUS_D.html | 390 ++--- docs/articles/FOCUS_L.html | 236 +-- .../figure-html/unnamed-chunk-6-1.png | Bin 36120 -> 36101 bytes docs/articles/index.html | 16 +- docs/articles/mkin.html | 72 +- .../mkin_files/figure-html/unnamed-chunk-2-1.png | Bin 90169 -> 90167 bytes docs/articles/twa.html | 16 +- docs/articles/web_only/FOCUS_Z.html | 368 ++--- .../figure-html/FOCUS_2006_Z_fits_10-1.png | Bin 105896 -> 105896 bytes .../figure-html/FOCUS_2006_Z_fits_11-1.png | Bin 104797 -> 104793 bytes .../figure-html/FOCUS_2006_Z_fits_11a-1.png | Bin 75232 -> 75230 bytes .../figure-html/FOCUS_2006_Z_fits_11b-1.png | Bin 36302 -> 36314 bytes .../figure-html/FOCUS_2006_Z_fits_5-1.png | Bin 80380 -> 80373 bytes .../figure-html/FOCUS_2006_Z_fits_6-1.png | Bin 105229 -> 105210 bytes .../figure-html/FOCUS_2006_Z_fits_9-1.png | Bin 88797 -> 88801 bytes docs/articles/web_only/NAFTA_examples.html | 1498 +++++++++--------- .../NAFTA_examples_files/figure-html/p10-1.png | Bin 79762 -> 79758 bytes .../NAFTA_examples_files/figure-html/p15a-1.png | Bin 76938 -> 76925 bytes .../NAFTA_examples_files/figure-html/p15b-1.png | Bin 78977 -> 78968 bytes .../NAFTA_examples_files/figure-html/p5b-1.png | Bin 80721 -> 80721 bytes .../NAFTA_examples_files/figure-html/p6-1.png | Bin 83052 -> 83052 bytes .../NAFTA_examples_files/figure-html/p7-1.png | Bin 102570 -> 102568 bytes docs/articles/web_only/benchmarks.html | 67 +- docs/articles/web_only/compiled_models.html | 32 +- docs/articles/web_only/dimethenamid_2018.html | 158 +- docs/articles/web_only/multistart.html | 200 +++ .../accessible-code-block-0.0.1/empty-anchor.js | 15 + .../figure-html/unnamed-chunk-3-1.png | Bin 0 -> 60747 bytes .../figure-html/unnamed-chunk-4-1.png | Bin 0 -> 58448 bytes .../figure-html/unnamed-chunk-5-1.png | Bin 0 -> 21847 bytes .../figure-html/unnamed-chunk-6-1.png | Bin 0 -> 50597 bytes docs/articles/web_only/saem_benchmarks.html | 417 +++++ .../accessible-code-block-0.0.1/empty-anchor.js | 15 + docs/authors.html | 16 +- docs/index.html | 12 +- docs/news/index.html | 27 +- docs/pkgdown.yml | 4 +- docs/reference/AIC.mmkin.html | 85 +- docs/reference/CAKE_export.html | 73 +- docs/reference/D24_2014.html | 40 +- docs/reference/DFOP.solution.html | 35 +- docs/reference/Extract.mmkin.html | 55 +- docs/reference/FOCUS_2006_DFOP_ref_A_to_B.html | 18 +- docs/reference/FOCUS_2006_FOMC_ref_A_to_F.html | 18 +- docs/reference/FOCUS_2006_HS_ref_A_to_F.html | 18 +- docs/reference/FOCUS_2006_SFO_ref_A_to_F.html | 18 +- docs/reference/FOCUS_2006_datasets.html | 28 +- docs/reference/FOMC.solution.html | 37 +- docs/reference/HS.solution.html | 35 +- docs/reference/IORE.solution.html | 55 +- docs/reference/NAFTA_SOP_2015.html | 24 +- docs/reference/NAFTA_SOP_Attachment.html | 22 +- docs/reference/Rplot001.png | Bin 1011 -> 14083 bytes docs/reference/Rplot002.png | Bin 17010 -> 13699 bytes docs/reference/Rplot003.png | Bin 49705 -> 49894 bytes docs/reference/Rplot004.png | Bin 58906 -> 59077 bytes docs/reference/Rplot005.png | Bin 22787 -> 19451 bytes docs/reference/Rplot006.png | Bin 24269 -> 24295 bytes docs/reference/SFO.solution.html | 31 +- docs/reference/SFORB.solution.html | 35 +- docs/reference/add_err.html | 139 +- docs/reference/anova.saem.mmkin.html | 168 +++ docs/reference/aw.html | 59 +- docs/reference/confint.mkinfit.html | 261 ++-- docs/reference/create_deg_func.html | 73 +- docs/reference/dimethenamid_2018-1.png | Bin 248255 -> 251312 bytes docs/reference/dimethenamid_2018.html | 234 +-- docs/reference/endpoints.html | 60 +- docs/reference/experimental_data_for_UBA-1.png | Bin 102928 -> 102904 bytes docs/reference/experimental_data_for_UBA.html | 90 +- docs/reference/f_time_norm_focus.html | 89 +- docs/reference/focus_soil_moisture.html | 18 +- docs/reference/get_deg_func.html | 20 +- docs/reference/illparms.html | 26 +- docs/reference/ilr.html | 69 +- docs/reference/index.html | 68 +- docs/reference/intervals.saem.mmkin.html | 29 +- docs/reference/llhist.html | 151 ++ docs/reference/loftest-3.png | Bin 76869 -> 76871 bytes docs/reference/loftest-5.png | Bin 73212 -> 73212 bytes docs/reference/loftest.html | 121 +- docs/reference/logLik.mkinfit.html | 51 +- docs/reference/logLik.saem.mmkin.html | 138 ++ docs/reference/logistic.solution.html | 111 +- docs/reference/lrtest.mkinfit.html | 61 +- docs/reference/max_twa_parent.html | 65 +- docs/reference/mccall81_245T.html | 100 +- docs/reference/mean_degparms.html | 41 +- docs/reference/mhmkin.html | 43 +- docs/reference/mixed-1.png | Bin 217349 -> 215088 bytes docs/reference/mixed.html | 123 +- docs/reference/mkin_long_to_wide.html | 31 +- docs/reference/mkin_wide_to_long.html | 31 +- docs/reference/mkinds.html | 14 +- docs/reference/mkindsg.html | 14 +- docs/reference/mkinerrmin.html | 51 +- docs/reference/mkinerrplot-1.png | Bin 41276 -> 41273 bytes docs/reference/mkinerrplot.html | 83 +- docs/reference/mkinfit.html | 39 +- docs/reference/mkinmod.html | 188 ++- docs/reference/mkinparplot-1.png | Bin 26003 -> 25998 bytes docs/reference/mkinparplot.html | 41 +- docs/reference/mkinplot.html | 23 +- docs/reference/mkinpredict.html | 283 ++-- docs/reference/mkinresplot.html | 83 +- docs/reference/mmkin-1.png | Bin 111900 -> 111900 bytes docs/reference/mmkin-2.png | Bin 108732 -> 108747 bytes docs/reference/mmkin-3.png | Bin 96805 -> 96798 bytes docs/reference/mmkin-4.png | Bin 67450 -> 67454 bytes docs/reference/mmkin-5.png | Bin 65338 -> 65333 bytes docs/reference/mmkin.html | 171 ++- docs/reference/multistart-1.png | Bin 0 -> 61330 bytes docs/reference/multistart-2.png | Bin 0 -> 56780 bytes docs/reference/multistart.html | 243 +++ docs/reference/nafta.html | 47 +- docs/reference/nlme-1.png | Bin 68895 -> 67988 bytes docs/reference/nlme-2.png | Bin 92521 -> 91395 bytes docs/reference/nlme.html | 137 +- docs/reference/nlme.mmkin.html | 259 ++-- docs/reference/nobs.mkinfit.html | 25 +- docs/reference/parms.html | 122 +- docs/reference/parplot.html | 175 +++ docs/reference/plot.mixed.mmkin-2.png | Bin 173316 -> 173322 bytes docs/reference/plot.mixed.mmkin-3.png | Bin 172514 -> 172513 bytes docs/reference/plot.mixed.mmkin-4.png | Bin 175535 -> 175586 bytes docs/reference/plot.mixed.mmkin.html | 176 ++- docs/reference/plot.mkinfit-2.png | Bin 73190 -> 73194 bytes docs/reference/plot.mkinfit-5.png | Bin 67142 -> 67141 bytes docs/reference/plot.mkinfit-7.png | Bin 74322 -> 74323 bytes docs/reference/plot.mkinfit.html | 205 ++- docs/reference/plot.mmkin-2.png | Bin 50031 -> 50033 bytes docs/reference/plot.mmkin-3.png | Bin 46363 -> 46365 bytes docs/reference/plot.mmkin-4.png | Bin 33400 -> 33401 bytes docs/reference/plot.mmkin-5.png | Bin 58200 -> 58203 bytes docs/reference/plot.mmkin.html | 113 +- docs/reference/plot.nafta.html | 29 +- docs/reference/read_spreadsheet.html | 179 +++ docs/reference/reexports.html | 14 +- docs/reference/residuals.mkinfit.html | 29 +- docs/reference/saem-1.png | Bin 46419 -> 53991 bytes docs/reference/saem-2.png | Bin 49282 -> 49254 bytes docs/reference/saem-3.png | Bin 128227 -> 127024 bytes docs/reference/saem-4.png | Bin 171244 -> 173266 bytes docs/reference/saem.html | 612 ++++---- docs/reference/schaefer07_complex_case.html | 44 +- docs/reference/set_nd_nq.html | 261 ++++ docs/reference/sigma_twocomp.html | 63 +- docs/reference/status.html | 174 +++ docs/reference/summary.mkinfit.html | 31 +- docs/reference/summary.mmkin.html | 26 +- docs/reference/summary.nlme.mmkin.html | 255 ++-- docs/reference/summary.saem.mmkin.html | 494 +++--- docs/reference/synthetic_data_for_UBA_2014-1.png | Bin 67450 -> 67454 bytes docs/reference/synthetic_data_for_UBA_2014.html | 258 ++-- docs/reference/test_data_from_UBA_2014.html | 75 +- docs/reference/tex_listing.html | 143 ++ docs/reference/transform_odeparms.html | 169 ++- docs/reference/update.mkinfit.html | 41 +- docs/sitemap.xml | 33 + vignettes/web_only/mkin_benchmarks.rda | Bin 1586 -> 1592 bytes vignettes/web_only/saem_benchmarks.rda | Bin 359 -> 353 bytes 166 files changed, 9615 insertions(+), 4184 deletions(-) create mode 100644 custom_lsoda_call.patch create mode 100644 custom_lsoda_call_edited.patch create mode 100644 docs/articles/web_only/multistart.html create mode 100644 docs/articles/web_only/multistart_files/accessible-code-block-0.0.1/empty-anchor.js create mode 100644 docs/articles/web_only/multistart_files/figure-html/unnamed-chunk-3-1.png create mode 100644 docs/articles/web_only/multistart_files/figure-html/unnamed-chunk-4-1.png create mode 100644 docs/articles/web_only/multistart_files/figure-html/unnamed-chunk-5-1.png create mode 100644 docs/articles/web_only/multistart_files/figure-html/unnamed-chunk-6-1.png create mode 100644 docs/articles/web_only/saem_benchmarks.html create mode 100644 docs/articles/web_only/saem_benchmarks_files/accessible-code-block-0.0.1/empty-anchor.js create mode 100644 docs/reference/anova.saem.mmkin.html create mode 100644 docs/reference/llhist.html create mode 100644 docs/reference/logLik.saem.mmkin.html create mode 100644 docs/reference/multistart-1.png create mode 100644 docs/reference/multistart-2.png create mode 100644 docs/reference/multistart.html create mode 100644 docs/reference/parplot.html create mode 100644 docs/reference/read_spreadsheet.html create mode 100644 docs/reference/set_nd_nq.html create mode 100644 docs/reference/status.html create mode 100644 docs/reference/tex_listing.html diff --git a/NEWS.md b/NEWS.md index 22d50710..cdb8a951 100644 --- a/NEWS.md +++ b/NEWS.md @@ -1,4 +1,4 @@ -# mkin 1.2.0 (unreleased) +# mkin 1.2.0 (2022-11-17) - 'R/saem.R': 'logLik', 'update' and 'anova' methods for 'saem.mmkin' objects. diff --git a/_pkgdown.yml b/_pkgdown.yml index bb1ad052..8aa44ed4 100644 --- a/_pkgdown.yml +++ b/_pkgdown.yml @@ -1,8 +1,8 @@ url: https://pkgdown.jrwb.de/mkin development: - mode: devel - version_label: info + mode: release + version_label: default template: bootswatch: spacelab diff --git a/custom_lsoda_call.patch b/custom_lsoda_call.patch new file mode 100644 index 00000000..d91a22c7 --- /dev/null +++ b/custom_lsoda_call.patch @@ -0,0 +1,1587 @@ +diff --git a/DESCRIPTION b/DESCRIPTION +index de0fab8..a006a44 100644 +--- a/DESCRIPTION ++++ b/DESCRIPTION +@@ -1,8 +1,8 @@ + Package: mkin + Type: Package + Title: Kinetic Evaluation of Chemical Degradation Data +-Version: 1.2.0 +-Date: 2022-11-16 ++Version: 1.3.0 ++Date: 2022-11-15 + Authors@R: c( + person("Johannes", "Ranke", role = c("aut", "cre", "cph"), + email = "johannes.ranke@jrwb.de", +@@ -22,8 +22,8 @@ Description: Calculation routines based on the FOCUS Kinetics Report (2006, + Ranke et al. (2021) . Please note that no + warranty is implied for correctness of results or fitness for a particular + purpose. +-Depends: R (>= 2.15.1), +-Imports: stats, graphics, methods, parallel, deSolve, R6, inline (>= 0.3.19), ++Depends: R (>= 2.15.1), deSolve ++Imports: stats, graphics, methods, parallel, R6, inline (>= 0.3.19), + numDeriv, lmtest, pkgbuild, nlme (>= 3.1-151), saemix (>= 3.1), rlang, vctrs + Suggests: knitr, rbenchmark, tikzDevice, testthat, rmarkdown, covr, vdiffr, + benchmarkme, tibble, stats4, readxl +diff --git a/NAMESPACE b/NAMESPACE +index 107ffc5..4a41acc 100644 +--- a/NAMESPACE ++++ b/NAMESPACE +@@ -147,7 +147,6 @@ export(status) + export(tex_listing) + export(transform_odeparms) + export(which.best) +-import(deSolve) + import(graphics) + import(nlme) + importFrom(R6,R6Class) +diff --git a/NEWS.md b/NEWS.md +index 22d5071..846c7c5 100644 +--- a/NEWS.md ++++ b/NEWS.md +@@ -1,11 +1,5 @@ + # mkin 1.2.0 (unreleased) + +-- 'R/saem.R': 'logLik', 'update' and 'anova' methods for 'saem.mmkin' objects. +- +-- 'R/saem.R': Automatic estimation of start parameters for random effects for the case of mkin transformations, nicely improving convergence and reducing problems with iterative ODE solutions. +- +-- 'R/status.R': New generic to show status information for fit array objects with methods for 'mmkin', 'mhmkin' and 'multistart' objects. +- + - 'R/mhmkin.R': New method for performing multiple hierarchical mkin fits in one function call, optionally in parallel. + + - 'R/mhmkin.R': 'anova.mhmkin' for conveniently comparing the resulting fits. +@@ -14,6 +8,12 @@ + + - 'R/multistart.R': New method for testing multiple start parameters for hierarchical model fits, with function 'llhist' and new generic 'parplot' for diagnostics, and new generics 'which.best' and 'best' for extracting the fit with the highest likelihood + ++- 'R/saem.R': 'logLik', 'update' and 'anova' methods for 'saem.mmkin' objects. ++ ++- 'R/saem.R': Automatic estimation of start parameters for random effects for the case of mkin transformations, nicely improving convergence and reducing problems with iterative ODE solutions. ++ ++- 'R/status.R': New generic to show status information for fit array objects with methods for 'mmkin', 'mhmkin' and 'multistart' objects. ++ + - 'R/summary.mmkin.R': Summary method for mmkin objects. + + - 'R/saem.R': Implement and test saemix transformations for FOMC and HS. Also, error out if saemix transformations are requested but not supported. +diff --git a/R/mkinfit.R b/R/mkinfit.R +index 693778f..0d9246d 100644 +--- a/R/mkinfit.R ++++ b/R/mkinfit.R +@@ -500,6 +500,15 @@ mkinfit <- function(mkinmod, observed, + } + } + ++ # Get native symbol before iterations info for speed ++ call_lsoda <- getNativeSymbolInfo("call_lsoda", PACKAGE = "deSolve") ++ if (solution_type == "deSolve" & use_compiled[1] != FALSE) { ++ mkinmod$diffs_address <- getNativeSymbolInfo("diffs", ++ PACKAGE = mkinmod$dll_info[["name"]])$address ++ mkinmod$initpar_address <- getNativeSymbolInfo("initpar", ++ PACKAGE = mkinmod$dll_info[["name"]])$address ++ } ++ + # Get the error model and the algorithm for fitting + err_mod <- match.arg(error_model) + error_model_algorithm = match.arg(error_model_algorithm) +@@ -610,7 +619,8 @@ mkinfit <- function(mkinmod, observed, + solution_type = solution_type, + use_compiled = use_compiled, + method.ode = method.ode, +- atol = atol, rtol = rtol, ...) ++ atol = atol, rtol = rtol, ++ call_lsoda = call_lsoda, ...) + + observed_index <- cbind(as.character(observed$time), as.character(observed$name)) + observed$predicted <- out[observed_index] +@@ -892,7 +902,10 @@ mkinfit <- function(mkinmod, observed, + fit$calls <- calls + fit$time <- fit_time + +- # We also need the model and a model name for summary and plotting ++ # We also need the model and a model name for summary and plotting, ++ # but without address info that will become invalid ++ mkinmod$diffs_address <- NULL ++ mkinmod$initpar_address <- NULL + fit$mkinmod <- mkinmod + fit$mkinmod$name <- mkinmod_name + fit$obs_vars <- obs_vars +diff --git a/R/mkinmod.R b/R/mkinmod.R +index d8740ae..b1fb57c 100644 +--- a/R/mkinmod.R ++++ b/R/mkinmod.R +@@ -45,7 +45,9 @@ + #' @param dll_dir Directory where an DLL object, if generated internally by + #' [inline::cfunction()], should be saved. The DLL will only be stored in a + #' permanent location for use in future sessions, if 'dll_dir' and 'name' +-#' are specified. ++#' are specified. This is helpful if fit objects are cached e.g. by knitr, ++#' as the cache remains functional across sessions if the DLL is stored in ++#' a user defined location. + #' @param unload If a DLL from the target location in 'dll_dir' is already + #' loaded, should that be unloaded first? + #' @param overwrite If a file exists at the target DLL location in 'dll_dir', +diff --git a/R/mkinpredict.R b/R/mkinpredict.R +index 0dc9cf5..11a3b35 100644 +--- a/R/mkinpredict.R ++++ b/R/mkinpredict.R +@@ -19,26 +19,24 @@ + #' @param solution_type The method that should be used for producing the + #' predictions. This should generally be "analytical" if there is only one + #' observed variable, and usually "deSolve" in the case of several observed +-#' variables. The third possibility "eigen" is faster but not applicable to +-#' some models e.g. using FOMC for the parent compound. ++#' variables. The third possibility "eigen" is fast in comparison to uncompiled ++#' ODE models, but not applicable to some models, e.g. using FOMC for the ++#' parent compound. + #' @param method.ode The solution method passed via [mkinpredict] to [ode]] in +-#' case the solution type is "deSolve". The default "lsoda" is performant, but +-#' sometimes fails to converge. ++#' case the solution type is "deSolve" and we are not using compiled code. + #' @param use_compiled If set to \code{FALSE}, no compiled version of the + #' [mkinmod] model is used, even if is present. +-#' @param atol Absolute error tolerance, passed to [ode]. Default is 1e-8, +-#' lower than in [lsoda]. +-#' @param rtol Absolute error tolerance, passed to [ode]. Default is 1e-10, +-#' much lower than in [lsoda]. +-#' @param maxsteps Maximum number of steps, passed to [ode]. ++#' @param atol Absolute error tolerance, passed to the ode solver. ++#' @param rtol Absolute error tolerance, passed to the ode solver. ++#' @param maxsteps Maximum number of steps, passed to the ode solver. + #' @param map_output Boolean to specify if the output should list values for + #' the observed variables (default) or for all state variables (if set to + #' FALSE). Setting this to FALSE has no effect for analytical solutions, + #' as these always return mapped output. + #' @param na_stop Should it be an error if [ode] returns NaN values ++#' @param call_lsoda The address of the compiled function "call_lsoda" + #' @param \dots Further arguments passed to the ode solver in case such a + #' solver is used. +-#' @import deSolve + #' @return A matrix with the numeric solution in wide format + #' @author Johannes Ranke + #' @examples +@@ -116,9 +114,10 @@ mkinpredict.mkinmod <- function(x, + outtimes = seq(0, 120, by = 0.1), + solution_type = "deSolve", + use_compiled = "auto", +- method.ode = "lsoda", atol = 1e-8, rtol = 1e-10, maxsteps = 20000, ++ method.ode = "lsoda", atol = 1e-8, rtol = 1e-10, maxsteps = 20000L, + map_output = TRUE, + na_stop = TRUE, ++ call_lsoda = NULL, + ...) + { + +@@ -173,20 +172,80 @@ mkinpredict.mkinmod <- function(x, + if (solution_type == "deSolve") { + if (!is.null(x$cf) & use_compiled[1] != FALSE) { + +- out <- deSolve::ode( +- y = odeini, +- times = outtimes, +- func = "diffs", +- initfunc = "initpar", +- dllname = if (is.null(x$dll_info)) inline::getDynLib(x$cf)[["name"]] +- else x$dll_info[["name"]], +- parms = odeparms[x$parms], # Order matters when using compiled models +- method = method.ode, +- atol = atol, +- rtol = rtol, +- maxsteps = maxsteps, +- ... ++# out <- deSolve::ode( ++# y = odeini, ++# times = outtimes, ++# func = "diffs", ++# initfunc = "initpar", ++# dllname = x$dll_info[["name"]], ++# parms = odeparms[x$parms], # Order matters when using compiled models ++# method = method.ode, ++# atol = atol, ++# rtol = rtol, ++# maxsteps = maxsteps, ++# ... ++# ) ++# ++ # Prepare call to "call_lsoda" ++ # Simplified code from deSolve::lsoda() adapted to our use case ++ if (is.null(call_lsoda)) { ++ call_lsoda <- getNativeSymbolInfo("call_lsoda", PACKAGE = "deSolve") ++ } ++ if (is.null(x$diffs_address)) { ++ x$diffs_address <- getNativeSymbolInfo("diffs", ++ PACKAGE = x$dll_info[["name"]])$address ++ x$initpar_address <- getNativeSymbolInfo("initpar", ++ PACKAGE = x$dll_info[["name"]])$address ++ } ++ rwork <- vector("double", 20) ++ rwork[] <- 0. ++ rwork[6] <- max(abs(diff(outtimes))) ++ ++ iwork <- vector("integer", 20) ++ iwork[] <- 0 ++ iwork[6] <- maxsteps ++ ++ n <- length(odeini) ++ lmat <- n^2 + 2 # from deSolve::lsoda(), for Jacobian type full, internal (2) ++ # hard-coded default values of lsoda(): ++ maxordn <- 12L ++ maxords <- 5L ++ lrn <- 20 + n * (maxordn + 1) + 3 * n # length in case non-stiff method ++ lrs <- 20 + n * (maxords + 1) + 3 * n + lmat # length in case stiff method ++ lrw <- max(lrn, lrs) # actual length: max of both ++ liw <- 20 + n ++ ++ on.exit(.C("unlock_solver", PACKAGE = "deSolve")) ++ ++ out_raw <- .Call(call_lsoda, ++ as.double(odeini), # y ++ as.double(outtimes), # times ++ x$diffs_address, # derivfunc ++ as.double(odeparms[x$parms]), # parms ++ rtol, atol, ++ NULL, NULL, # rho, tcrit ++ NULL, # jacfunc ++ x$initpar_address, # initfunc ++ NULL, # eventfunc ++ 0L, # verbose ++ 1L, # iTask ++ as.double(rwork), # rWork ++ as.integer(iwork), # iWork ++ 2L, # jT full Jacobian calculated internally ++ 0L, # nOut ++ as.integer(lrw), # lRw ++ as.integer(liw), # lIw ++ 1L, # Solver ++ NULL, # rootfunc ++ 0L, as.double(0), 0L, # nRoot, Rpar, Ipar ++ 0L, # Type ++ list(fmat = 0L, tmat = 0L, imat = 0L, ModelForc = NULL), # flist ++ list(), # elist ++ list(islag = 0L) # elag + ) ++ ++ out <- t(out_raw) ++ colnames(out) <- c("time", mod_vars) + } else { + mkindiff <- function(t, state, parms) { + +diff --git a/R/nlme.mmkin.R b/R/nlme.mmkin.R +index 09cb84b..e193e5e 100644 +--- a/R/nlme.mmkin.R ++++ b/R/nlme.mmkin.R +@@ -186,10 +186,24 @@ nlme.mmkin <- function(model, data = "auto", + thisCall[["control"]] <- control + } + ++ # Provide the address of call_lsoda to the fitting function ++ call_lsoda <- getNativeSymbolInfo("call_lsoda", PACKAGE = "deSolve") ++ if (model[[1]]$solution_type == "deSolve" & !is.null(model[[1]]$mkinmod$cf)) { ++ # The mkinmod stored in the first fit will be used by nlme ++ model[[1]]$mkinmod$diffs_address <- getNativeSymbolInfo("diffs", ++ PACKAGE = model[[1]]$mkinmod$dll_info[["name"]])$address ++ model[[1]]$mkinmod$initpar_address <- getNativeSymbolInfo("initpar", ++ PACKAGE = model[[1]]$mkinmod$dll_info[["name"]])$address ++ } ++ + fit_time <- system.time(val <- do.call("nlme.formula", thisCall)) + val$time <- fit_time + + val$mkinmod <- model[[1]]$mkinmod ++ # Don't return addresses that will become invalid ++ val$mkinmod$diffs_address <- NULL ++ val$mkinmod$initpar_address <- NULL ++ + val$data <- thisCall[["data"]] + val$mmkin <- model + if (is.list(start)) val$mean_dp_start <- start$fixed +diff --git a/R/read_spreadsheet.R b/R/read_spreadsheet.R +index 7ad09c3..a20af6d 100644 +--- a/R/read_spreadsheet.R ++++ b/R/read_spreadsheet.R +@@ -37,7 +37,7 @@ + #' and moisture normalisation factors in the sheet 'Datasets'? + #' @export + read_spreadsheet <- function(path, valid_datasets = "all", +- parent_only = FALSE, normalize = TRUE) ++ parent_only = TRUE, normalize = TRUE) + { + if (!requireNamespace("readxl", quietly = TRUE)) + stop("Please install the readxl package to use this function") +diff --git a/R/saem.R b/R/saem.R +index 696ea0e..5b8021d 100644 +--- a/R/saem.R ++++ b/R/saem.R +@@ -120,12 +120,12 @@ utils::globalVariables(c("predicted", "std")) + #' summary(f_saem_dfop_sfo, data = TRUE) + #' + #' # The following takes about 6 minutes +-#' #f_saem_dfop_sfo_deSolve <- saem(f_mmkin["DFOP-SFO", ], solution_type = "deSolve", +-#' # control = list(nbiter.saemix = c(200, 80), nbdisplay = 10)) ++#' f_saem_dfop_sfo_deSolve <- saem(f_mmkin["DFOP-SFO", ], solution_type = "deSolve", ++#' nbiter.saemix = c(200, 80)) + #' +-#' #saemix::compare.saemix(list( +-#' # f_saem_dfop_sfo$so, +-#' # f_saem_dfop_sfo_deSolve$so)) ++#' #anova( ++#' # f_saem_dfop_sfo, ++#' # f_saem_dfop_sfo_deSolve)) + #' + #' # If the model supports it, we can also use eigenvalue based solutions, which + #' # take a similar amount of time +@@ -580,6 +580,15 @@ saemix_model <- function(object, solution_type = "auto", + transform_rates <- object[[1]]$transform_rates + transform_fractions <- object[[1]]$transform_fractions + ++ # Get native symbol info for speed ++ call_lsoda <- getNativeSymbolInfo("call_lsoda", PACKAGE = "deSolve") ++ if (solution_type == "deSolve" & !is.null(mkin_model$cf)) { ++ mkin_model$diffs_address <- getNativeSymbolInfo("diffs", ++ PACKAGE = mkin_model$dll_info[["name"]])$address ++ mkin_model$initpar_address <- getNativeSymbolInfo("initpar", ++ PACKAGE = mkin_model$dll_info[["name"]])$address ++ } ++ + # Define the model function + model_function <- function(psi, id, xidep) { + +@@ -613,7 +622,8 @@ saemix_model <- function(object, solution_type = "auto", + odeparms = odeparms, odeini = odeini, + solution_type = solution_type, + outtimes = sort(unique(i_time)), +- na_stop = FALSE ++ na_stop = FALSE, ++ call_lsoda = call_lsoda + ) + + out_index <- cbind(as.character(i_time), as.character(i_name)) +diff --git a/docs/dev/articles/mkin.html b/docs/dev/articles/mkin.html +index 27e532a..6bfb63b 100644 +--- a/docs/dev/articles/mkin.html ++++ b/docs/dev/articles/mkin.html +@@ -34,7 +34,7 @@ + + + mkin +- 1.2.0 ++ 1.1.0 + + + +@@ -44,7 +44,7 @@ + Functions and data + + +
  • +- Example evaluations of dimethenamid data from 2018 with nonlinear mixed-effects models +-
  • +-
  • +- Short demo of the multistart method ++ Example evaluation of FOCUS Example Dataset Z +
  • +
  • + Performance benefit by using compiled model definitions in mkin +
  • +-
  • +- Example evaluation of FOCUS Example Dataset Z +-
  • +
  • + Calculation of time weighted average concentrations with mkin +
  • +@@ -78,10 +72,7 @@ + Example evaluation of NAFTA SOP Attachment examples + +
  • +- Benchmark timings for mkin +-
  • +-
  • +- Benchmark timings for saem.mmkin ++ Some benchmark timings +
  • + + +@@ -112,7 +103,7 @@ +

    Introduction to mkin

    +

    Johannes Ranke

    + +-

    Last change 15 February 2021 (rebuilt 2022-11-16)

    ++

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

    + + Source: vignettes/mkin.rmd + +@@ -127,34 +118,34 @@ + +

    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.

    +
    +-library("mkin", quietly = TRUE)
    +-# Define the kinetic model
    +-m_SFO_SFO_SFO <- mkinmod(parent = mkinsub("SFO", "M1"),
    +-                         M1 = mkinsub("SFO", "M2"),
    +-                         M2 = mkinsub("SFO"),
    +-                         use_of_ff = "max", quiet = TRUE)
    +-
    +-
    +-# Produce model predictions using some arbitrary parameters
    +-sampling_times = c(0, 1, 3, 7, 14, 28, 60, 90, 120)
    +-d_SFO_SFO_SFO <- mkinpredict(m_SFO_SFO_SFO,
    +-  c(k_parent = 0.03,
    +-    f_parent_to_M1 = 0.5, k_M1 = log(2)/100,
    +-    f_M1_to_M2 = 0.9, k_M2 = log(2)/50),
    +-  c(parent = 100, M1 = 0, M2 = 0),
    +-  sampling_times)
    +-
    +-# Generate a dataset by adding normally distributed errors with
    +-# standard deviation 3, for two replicates at each sampling time
    +-d_SFO_SFO_SFO_err <- add_err(d_SFO_SFO_SFO, reps = 2,
    +-                             sdfunc = function(x) 3,
    +-                             n = 1, seed = 123456789 )
    +-
    +-# Fit the model to the dataset
    +-f_SFO_SFO_SFO <- mkinfit(m_SFO_SFO_SFO, d_SFO_SFO_SFO_err[[1]], quiet = TRUE)
    +-
    +-# Plot the results separately for parent and metabolites
    +-plot_sep(f_SFO_SFO_SFO, lpos = c("topright", "bottomright", "bottomright"))
    ++library("mkin", quietly = TRUE) ++# Define the kinetic model ++m_SFO_SFO_SFO <- mkinmod(parent = mkinsub("SFO", "M1"), ++ M1 = mkinsub("SFO", "M2"), ++ M2 = mkinsub("SFO"), ++ use_of_ff = "max", quiet = TRUE) ++ ++ ++# Produce model predictions using some arbitrary parameters ++sampling_times = c(0, 1, 3, 7, 14, 28, 60, 90, 120) ++d_SFO_SFO_SFO <- mkinpredict(m_SFO_SFO_SFO, ++ c(k_parent = 0.03, ++ f_parent_to_M1 = 0.5, k_M1 = log(2)/100, ++ f_M1_to_M2 = 0.9, k_M2 = log(2)/50), ++ c(parent = 100, M1 = 0, M2 = 0), ++ sampling_times) ++ ++# Generate a dataset by adding normally distributed errors with ++# standard deviation 3, for two replicates at each sampling time ++d_SFO_SFO_SFO_err <- add_err(d_SFO_SFO_SFO, reps = 2, ++ sdfunc = function(x) 3, ++ n = 1, seed = 123456789 ) ++ ++# Fit the model to the dataset ++f_SFO_SFO_SFO <- mkinfit(m_SFO_SFO_SFO, d_SFO_SFO_SFO_err[[1]], quiet = TRUE) ++ ++# Plot the results separately for parent and metabolites ++plot_sep(f_SFO_SFO_SFO, lpos = c("topright", "bottomright", "bottomright")) +

    + +
    +@@ -233,10 +224,10 @@ +

    Ranke, J. 2021. ‘mkin‘: Kinetic Evaluation of Chemical Degradation Data. https://CRAN.R-project.org/package=mkin.

    +
    +
    +-

    Ranke, J., and R. Lehmann. 2012. “Parameter Reliability in Kinetic Evaluation of Environmental Metabolism Data - Assessment and the Influence of Model Specification.” In SETAC World 20-24 May. Berlin. https://jrwb.de/posters/Poster_SETAC_2012_Kinetic_parameter_uncertainty_model_parameterization_Lehmann_Ranke.pdf.

    ++

    Ranke, J., and R. Lehmann. 2012. “Parameter Reliability in Kinetic Evaluation of Environmental Metabolism Data - Assessment and the Influence of Model Specification.” In SETAC World 20-24 May. Berlin.

    +
    +
    +-

    ———. 2015. “To T-Test or Not to T-Test, That Is the Question.” In XV Symposium on Pesticide Chemistry 2-4 September 2015. Piacenza. https://jrwb.de/posters/piacenza_2015.pdf.

    ++

    ———. 2015. “To T-Test or Not to T-Test, That Is the Question.” In XV Symposium on Pesticide Chemistry 2-4 September 2015. Piacenza. http://chem.uft.uni-bremen.de/ranke/posters/piacenza_2015.pdf.

    +
    +
    +

    Ranke, Johannes, and Stefan Meinecke. 2019. “Error Models for the Kinetic Evaluation of Chemical Degradation Data.” Environments 6 (12). https://doi.org/10.3390/environments6120124.

    +@@ -271,7 +262,7 @@ + +
    +

    +-

    Site built with pkgdown 2.0.6.

    ++

    Site built with pkgdown 2.0.2.

    +
    + + +diff --git a/docs/dev/articles/web_only/saem_benchmarks.html b/docs/dev/articles/web_only/saem_benchmarks.html +index afff038..e54bc38 100644 +--- a/docs/dev/articles/web_only/saem_benchmarks.html ++++ b/docs/dev/articles/web_only/saem_benchmarks.html +@@ -112,7 +112,7 @@ +

    Benchmark timings for saem.mmkin

    +

    Johannes Ranke

    + +-

    Last change 14 November 2022 (rebuilt 2022-11-16)

    ++

    Last change 14 November 2022 (rebuilt 2022-11-15)

    + + Source: vignettes/web_only/saem_benchmarks.rmd + +@@ -309,10 +309,10 @@ + Linux + 1.2.0 + 3.2 +-2.156 +-4.647 +-4.296 +-4.951 ++2.11 ++4.632 ++4.264 ++4.93 + + +

    Two-component error fits for SFO, DFOP, SFORB and HS.

    +@@ -332,10 +332,10 @@ + Linux + 1.2.0 + 3.2 +-5.645 +-7.415 +-7.848 +-7.967 ++5.602 ++7.373 ++7.815 ++7.831 + + +
    +@@ -357,8 +357,8 @@ + Linux + 1.2.0 + 3.2 +-24.182 +-783.932 ++24.014 ++749.699 + + + +@@ -379,7 +379,7 @@ + Linux + 1.2.0 + 3.2 +-1322.5 ++1249.834 + + + +diff --git a/docs/dev/news/index.html b/docs/dev/news/index.html +index 3353922..8448ebc 100644 +--- a/docs/dev/news/index.html ++++ b/docs/dev/news/index.html +@@ -89,13 +89,13 @@ + +
    + +-
    • ‘R/saem.R’: ‘logLik’, ‘update’ and ‘anova’ methods for ‘saem.mmkin’ objects.

    • +-
    • ‘R/saem.R’: Automatic estimation of start parameters for random effects for the case of mkin transformations, nicely improving convergence and reducing problems with iterative ODE solutions.

    • +-
    • ‘R/status.R’: New generic to show status information for fit array objects with methods for ‘mmkin’, ‘mhmkin’ and ‘multistart’ objects.

    • +-
    • ‘R/mhmkin.R’: New method for performing multiple hierarchical mkin fits in one function call, optionally in parallel.

    • ++
      • ‘R/mhmkin.R’: New method for performing multiple hierarchical mkin fits in one function call, optionally in parallel.

      • +
      • ‘R/mhmkin.R’: ‘anova.mhmkin’ for conveniently comparing the resulting fits.

      • +
      • ‘R/illparms.R’: New generic to show ill-defined parameters with methods for ‘mkinfit’, ‘mmkin’, ‘saem.mmkin’ and ‘mhmkin’ objects.

      • +
      • ‘R/multistart.R’: New method for testing multiple start parameters for hierarchical model fits, with function ‘llhist’ and new generic ‘parplot’ for diagnostics, and new generics ‘which.best’ and ‘best’ for extracting the fit with the highest likelihood

      • ++
      • ‘R/saem.R’: ‘logLik’, ‘update’ and ‘anova’ methods for ‘saem.mmkin’ objects.

      • ++
      • ‘R/saem.R’: Automatic estimation of start parameters for random effects for the case of mkin transformations, nicely improving convergence and reducing problems with iterative ODE solutions.

      • ++
      • ‘R/status.R’: New generic to show status information for fit array objects with methods for ‘mmkin’, ‘mhmkin’ and ‘multistart’ objects.

      • +
      • ‘R/summary.mmkin.R’: Summary method for mmkin objects.

      • +
      • ‘R/saem.R’: Implement and test saemix transformations for FOMC and HS. Also, error out if saemix transformations are requested but not supported.

      • +
      • ‘R/read_spreadsheet.R’: Conveniently read in data from a spreadsheet file.

      • +diff --git a/docs/dev/pkgdown.yml b/docs/dev/pkgdown.yml +index 44bd60f..e0c11a8 100644 +--- a/docs/dev/pkgdown.yml ++++ b/docs/dev/pkgdown.yml +@@ -13,7 +13,7 @@ articles: + dimethenamid_2018: web_only/dimethenamid_2018.html + multistart: web_only/multistart.html + saem_benchmarks: web_only/saem_benchmarks.html +-last_built: 2022-11-16T14:17Z ++last_built: 2022-11-14T23:45Z + urls: + reference: https://pkgdown.jrwb.de/mkin/reference + article: https://pkgdown.jrwb.de/mkin/articles +diff --git a/docs/dev/reference/mkinmod.html b/docs/dev/reference/mkinmod.html +index d0e192e..5d362f7 100644 +--- a/docs/dev/reference/mkinmod.html ++++ b/docs/dev/reference/mkinmod.html +@@ -21,7 +21,7 @@ components."> + + + + + + + + + + + +
        +
        + + + + +
        +
        + + + + +

        The dimethenamid data from 2018 from seven soils is used as example data in this vignette.

        +
        +library(mkin)
        +dmta_ds <- lapply(1:7, function(i) {
        +  ds_i <- dimethenamid_2018$ds[[i]]$data
        +  ds_i[ds_i$name == "DMTAP", "name"] <-  "DMTA"
        +  ds_i$time <- ds_i$time * dimethenamid_2018$f_time_norm[i]
        +  ds_i
        +})
        +names(dmta_ds) <- sapply(dimethenamid_2018$ds, function(ds) ds$title)
        +dmta_ds[["Elliot"]] <- rbind(dmta_ds[["Elliot 1"]], dmta_ds[["Elliot 2"]])
        +dmta_ds[["Elliot 1"]] <- dmta_ds[["Elliot 2"]] <- NULL
        +

        First, we check the DFOP model with the two-component error model and random effects for all degradation parameters.

        +
        +f_mmkin <- mmkin("DFOP", dmta_ds, error_model = "tc", cores = 7, quiet = TRUE)
        +f_saem_full <- saem(f_mmkin)
        +illparms(f_saem_full)
        +
        ## [1] "sd(log_k2)"
        +

        We see that not all variability parameters are identifiable. The illparms function tells us that the confidence interval for the standard deviation of ‘log_k2’ includes zero. We check this assessment using multiple runs with different starting values.

        +
        +f_saem_full_multi <- multistart(f_saem_full, n = 16, cores = 16)
        +parplot(f_saem_full_multi)
        +

        +

        This confirms that the variance of k2 is the most problematic parameter, so we reduce the parameter distribution model by removing the intersoil variability for k2.

        +
        +f_saem_reduced <- update(f_saem_full, no_random_effect = "log_k2")
        +illparms(f_saem_reduced)
        +f_saem_reduced_multi <- multistart(f_saem_reduced, n = 16, cores = 16)
        +parplot(f_saem_reduced_multi, lpos = "topright")
        +

        +

        The results confirm that all remaining parameters can be determined with sufficient certainty.

        +

        We can also analyse the log-likelihoods obtained in the multiple runs:

        +
        +llhist(f_saem_reduced_multi)
        +

        +

        The parameter histograms can be further improved by excluding the result with the low likelihood.

        +
        +parplot(f_saem_reduced_multi, lpos = "topright", llmin = -326, ylim = c(0.5, 2))
        +

        +

        We can use the anova method to compare the models, including a likelihood ratio test if the models are nested.

        +
        +anova(f_saem_full, best(f_saem_reduced_multi), test = TRUE)
        +
        ## Data: 155 observations of 1 variable(s) grouped in 6 datasets
        +## 
        +##                            npar    AIC    BIC     Lik Chisq Df Pr(>Chisq)
        +## best(f_saem_reduced_multi)    9 663.69 661.82 -322.85                    
        +## f_saem_full                  10 669.77 667.69 -324.89     0  1          1
        +

        While AIC and BIC are lower for the reduced model, the likelihood ratio test does not indicate a significant difference between the fits.

        +
        + + + +
        + + + +
        + +
        +

        +

        Site built with pkgdown 2.0.6.

        +
        + +
        +
        + + + + + + + + diff --git a/docs/articles/web_only/multistart_files/accessible-code-block-0.0.1/empty-anchor.js b/docs/articles/web_only/multistart_files/accessible-code-block-0.0.1/empty-anchor.js new file mode 100644 index 00000000..ca349fd6 --- /dev/null +++ b/docs/articles/web_only/multistart_files/accessible-code-block-0.0.1/empty-anchor.js @@ -0,0 +1,15 @@ +// Hide empty tag within highlighted CodeBlock for screen reader accessibility (see https://github.com/jgm/pandoc/issues/6352#issuecomment-626106786) --> +// v0.0.1 +// Written by JooYoung Seo (jooyoung@psu.edu) and Atsushi Yasumoto on June 1st, 2020. + +document.addEventListener('DOMContentLoaded', function() { + const codeList = document.getElementsByClassName("sourceCode"); + for (var i = 0; i < codeList.length; i++) { + var linkList = codeList[i].getElementsByTagName('a'); + for (var j = 0; j < linkList.length; j++) { + if (linkList[j].innerHTML === "") { + linkList[j].setAttribute('aria-hidden', 'true'); + } + } + } +}); diff --git a/docs/articles/web_only/multistart_files/figure-html/unnamed-chunk-3-1.png b/docs/articles/web_only/multistart_files/figure-html/unnamed-chunk-3-1.png new file mode 100644 index 00000000..28991ae8 Binary files /dev/null and b/docs/articles/web_only/multistart_files/figure-html/unnamed-chunk-3-1.png differ diff --git a/docs/articles/web_only/multistart_files/figure-html/unnamed-chunk-4-1.png b/docs/articles/web_only/multistart_files/figure-html/unnamed-chunk-4-1.png new file mode 100644 index 00000000..56147ae2 Binary files /dev/null and b/docs/articles/web_only/multistart_files/figure-html/unnamed-chunk-4-1.png differ diff --git a/docs/articles/web_only/multistart_files/figure-html/unnamed-chunk-5-1.png b/docs/articles/web_only/multistart_files/figure-html/unnamed-chunk-5-1.png new file mode 100644 index 00000000..7ce108a2 Binary files /dev/null and b/docs/articles/web_only/multistart_files/figure-html/unnamed-chunk-5-1.png differ diff --git a/docs/articles/web_only/multistart_files/figure-html/unnamed-chunk-6-1.png b/docs/articles/web_only/multistart_files/figure-html/unnamed-chunk-6-1.png new file mode 100644 index 00000000..00ccbaa8 Binary files /dev/null and b/docs/articles/web_only/multistart_files/figure-html/unnamed-chunk-6-1.png differ diff --git a/docs/articles/web_only/saem_benchmarks.html b/docs/articles/web_only/saem_benchmarks.html new file mode 100644 index 00000000..523d028c --- /dev/null +++ b/docs/articles/web_only/saem_benchmarks.html @@ -0,0 +1,417 @@ + + + + + + + +Benchmark timings for saem.mmkin • mkin + + + + + + + + + + + + +
        +
        + + + + +
        +
        + + + + +

        Each system is characterized by operating system type, CPU type, mkin version, saemix version and R version. A compiler was available, so if no analytical solution was available, compiled ODE models are used.

        +

        Every fit is only performed once, so the accuracy of the benchmarks is limited.

        +

        For the initial mmkin fits, we use all available cores.

        +
        +n_cores <- parallel::detectCores()
        +
        +

        Test data +

        +

        Please refer to the vignette dimethenamid_2018 for an explanation of the following preprocessing.

        +
        +dmta_ds <- lapply(1:7, function(i) {
        +  ds_i <- dimethenamid_2018$ds[[i]]$data
        +  ds_i[ds_i$name == "DMTAP", "name"] <-  "DMTA"
        +  ds_i$time <- ds_i$time * dimethenamid_2018$f_time_norm[i]
        +  ds_i
        +})
        +names(dmta_ds) <- sapply(dimethenamid_2018$ds, function(ds) ds$title)
        +dmta_ds[["Elliot"]] <- rbind(dmta_ds[["Elliot 1"]], dmta_ds[["Elliot 2"]])
        +dmta_ds[["Elliot 1"]] <- NULL
        +dmta_ds[["Elliot 2"]] <- NULL
        +
        +
        +

        Test cases +

        +
        +

        Parent only +

        +
        +parent_mods <- c("SFO", "DFOP", "SFORB", "HS")
        +parent_sep_const <- mmkin(parent_mods, dmta_ds, quiet = TRUE, cores = n_cores)
        +parent_sep_tc <- update(parent_sep_const, error_model = "tc")
        +
        +t1 <- system.time(sfo_const <- saem(parent_sep_const["SFO", ]))[["elapsed"]]
        +t2 <- system.time(dfop_const <- saem(parent_sep_const["DFOP", ]))[["elapsed"]]
        +t3 <- system.time(sforb_const <- saem(parent_sep_const["SFORB", ]))[["elapsed"]]
        +t4 <- system.time(hs_const <- saem(parent_sep_const["HS", ]))[["elapsed"]]
        +t5 <- system.time(sfo_tc <- saem(parent_sep_tc["SFO", ]))[["elapsed"]]
        +t6 <- system.time(dfop_tc <- saem(parent_sep_tc["DFOP", ]))[["elapsed"]]
        +t7 <- system.time(sforb_tc <- saem(parent_sep_tc["SFORB", ]))[["elapsed"]]
        +t8 <- system.time(hs_tc <- saem(parent_sep_tc["HS", ]))[["elapsed"]]
        +
        +anova(
        +  sfo_const, dfop_const, sforb_const, hs_const,
        +  sfo_tc, dfop_tc, sforb_tc, hs_tc) |> kable(, digits = 1)
        + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
        nparAICBICLik
        sfo_const5796.3795.3-393.2
        sfo_tc6798.3797.1-393.2
        dfop_const9709.4707.5-345.7
        sforb_const9710.0708.1-346.0
        hs_const9713.7711.8-347.8
        dfop_tc10669.8667.7-324.9
        sforb_tc10662.8660.7-321.4
        hs_tc10667.3665.2-323.6
        +

        The above model comparison suggests to use the SFORB model with two-component error. For comparison, we keep the DFOP model with two-component error, as it competes with SFORB for biphasic curves.

        +
        +illparms(dfop_tc)
        +
        ## [1] "sd(log_k2)"
        +
        +illparms(sforb_tc)
        +
        ## [1] "sd(log_k_DMTA_bound_free)"
        +

        For these two models, random effects for the transformed parameters k2 and k_DMTA_bound_free could not be quantified.

        +
        +
        +

        One metabolite +

        +

        We remove parameters that were found to be ill-defined in the parent only fits.

        +
        +one_met_mods <- list(
        +  DFOP_SFO = mkinmod(
        +    DMTA = mkinsub("DFOP", "M23"),
        +    M23 = mkinsub("SFO")),
        +  SFORB_SFO = mkinmod(
        +    DMTA = mkinsub("SFORB", "M23"),
        +    M23 = mkinsub("SFO")))
        +
        +one_met_sep_const <- mmkin(one_met_mods, dmta_ds, error_model = "const",
        +  cores = n_cores, quiet = TRUE)
        +one_met_sep_tc <- mmkin(one_met_mods, dmta_ds, error_model = "tc",
        +  cores = n_cores, quiet = TRUE)
        +
        +t9 <- system.time(dfop_sfo_tc <- saem(one_met_sep_tc["DFOP_SFO", ],
        +    no_random_effect = "log_k2"))[["elapsed"]]
        +t10 <- system.time(sforb_sfo_tc <- saem(one_met_sep_tc["SFORB_SFO", ],
        +    no_random_effect = "log_k_DMTA_bound_free"))[["elapsed"]]
        +
        +
        +

        Three metabolites +

        +

        For the case of three metabolites, we only keep the SFORB model in order to limit the time for compiling this vignette, and as fitting in parallel may disturb the benchmark. Again, we do not include random effects that were ill-defined in previous fits of subsets of the degradation model.

        +
        +illparms(sforb_sfo_tc)
        +
        +three_met_mods <- list(
        +  SFORB_SFO3_plus = mkinmod(
        +    DMTA = mkinsub("SFORB", c("M23", "M27", "M31")),
        +    M23 = mkinsub("SFO"),
        +    M27 = mkinsub("SFO"),
        +    M31 = mkinsub("SFO", "M27", sink = FALSE)))
        +
        +three_met_sep_tc <- mmkin(three_met_mods, dmta_ds, error_model = "tc",
        +  cores = n_cores, quiet = TRUE)
        +
        +t11 <- system.time(sforb_sfo3_plus_const <- saem(three_met_sep_tc["SFORB_SFO3_plus", ],
        +    no_random_effect = "log_k_DMTA_bound_free"))[["elapsed"]]
        +
        +
        +
        +

        Results +

        +

        Benchmarks for all available error models are shown. They are intended for improving mkin, not for comparing CPUs or operating systems. All trademarks belong to their respective owners.

        +
        +

        Parent only +

        +

        Constant variance for SFO, DFOP, SFORB and HS.

        + + + + + + + + + + + + + + + + + + + + + +
        CPUOSmkinsaemixt1t2t3t4
        Ryzen 7 1700Linux1.2.03.22.144.6264.3284.998
        +

        Two-component error fits for SFO, DFOP, SFORB and HS.

        + + + + + + + + + + + + + + + + + + + + + +
        CPUOSmkinsaemixt5t6t7t8
        Ryzen 7 1700Linux1.2.03.25.6787.44187.98
        +
        +
        +

        One metabolite +

        +

        Two-component error for DFOP-SFO and SFORB-SFO.

        + + + + + + + + + + + + + + + + + +
        CPUOSmkinsaemixt9t10
        Ryzen 7 1700Linux1.2.03.224.465800.266
        +
        +
        +

        Three metabolites +

        +

        Two-component error for SFORB-SFO3-plus

        + + + + + + + + + + + + + + + +
        CPUOSmkinsaemixt11
        Ryzen 7 1700Linux1.2.03.21289.198
        +
        +
        +
        + + + +
        + + + +
        + +
        +

        +

        Site built with pkgdown 2.0.6.

        +
        + +
        +
        + + + + + + + + diff --git a/docs/articles/web_only/saem_benchmarks_files/accessible-code-block-0.0.1/empty-anchor.js b/docs/articles/web_only/saem_benchmarks_files/accessible-code-block-0.0.1/empty-anchor.js new file mode 100644 index 00000000..ca349fd6 --- /dev/null +++ b/docs/articles/web_only/saem_benchmarks_files/accessible-code-block-0.0.1/empty-anchor.js @@ -0,0 +1,15 @@ +// Hide empty tag within highlighted CodeBlock for screen reader accessibility (see https://github.com/jgm/pandoc/issues/6352#issuecomment-626106786) --> +// v0.0.1 +// Written by JooYoung Seo (jooyoung@psu.edu) and Atsushi Yasumoto on June 1st, 2020. + +document.addEventListener('DOMContentLoaded', function() { + const codeList = document.getElementsByClassName("sourceCode"); + for (var i = 0; i < codeList.length; i++) { + var linkList = codeList[i].getElementsByTagName('a'); + for (var j = 0; j < linkList.length; j++) { + if (linkList[j].innerHTML === "") { + linkList[j].setAttribute('aria-hidden', 'true'); + } + } + } +}); diff --git a/docs/authors.html b/docs/authors.html index ab436c86..6560ab17 100644 --- a/docs/authors.html +++ b/docs/authors.html @@ -17,7 +17,7 @@ mkin - 1.1.2 + 1.2.0
    @@ -44,11 +44,14 @@ Example evaluations of dimethenamid data from 2018 with nonlinear mixed-effects models
  • - Example evaluation of FOCUS Example Dataset Z + Short demo of the multistart method
  • Performance benefit by using compiled model definitions in mkin
  • +
  • + Example evaluation of FOCUS Example Dataset Z +
  • Calculation of time weighted average concentrations with mkin
  • @@ -56,7 +59,10 @@ Example evaluation of NAFTA SOP Attachment examples
  • - Some benchmark timings + Benchmark timings for mkin +
  • +
  • + Benchmark timings for saem.mmkin
  • @@ -109,13 +115,13 @@

    Ranke J (2022). mkin: Kinetic Evaluation of Chemical Degradation Data. -R package version 1.1.2, https://pkgdown.jrwb.de/mkin/. +R package version 1.2.0, https://pkgdown.jrwb.de/mkin/.

    @Manual{,
       title = {mkin: Kinetic Evaluation of Chemical Degradation Data},
       author = {Johannes Ranke},
       year = {2022},
    -  note = {R package version 1.1.2},
    +  note = {R package version 1.2.0},
       url = {https://pkgdown.jrwb.de/mkin/},
     }
    diff --git a/docs/index.html b/docs/index.html index 67e1702a..9048bc38 100644 --- a/docs/index.html +++ b/docs/index.html @@ -44,7 +44,7 @@ mkin - 1.1.2 + 1.2.0 @@ -73,11 +73,14 @@ Example evaluations of dimethenamid data from 2018 with nonlinear mixed-effects models
  • - Example evaluation of FOCUS Example Dataset Z + Short demo of the multistart method
  • Performance benefit by using compiled model definitions in mkin
  • +
  • + Example evaluation of FOCUS Example Dataset Z +
  • Calculation of time weighted average concentrations with mkin
  • @@ -85,7 +88,10 @@ Example evaluation of NAFTA SOP Attachment examples
  • - Some benchmark timings + Benchmark timings for mkin +
  • +
  • + Benchmark timings for saem.mmkin
  • diff --git a/docs/news/index.html b/docs/news/index.html index faaab288..90768141 100644 --- a/docs/news/index.html +++ b/docs/news/index.html @@ -17,7 +17,7 @@ mkin - 1.1.2 + 1.2.0 @@ -44,11 +44,14 @@ Example evaluations of dimethenamid data from 2018 with nonlinear mixed-effects models
  • - Example evaluation of FOCUS Example Dataset Z + Short demo of the multistart method
  • Performance benefit by using compiled model definitions in mkin
  • +
  • + Example evaluation of FOCUS Example Dataset Z +
  • Calculation of time weighted average concentrations with mkin
  • @@ -56,7 +59,10 @@ Example evaluation of NAFTA SOP Attachment examples
  • - Some benchmark timings + Benchmark timings for mkin +
  • +
  • + Benchmark timings for saem.mmkin
  • @@ -82,13 +88,18 @@
    - -
    • ‘R/mhmkin.R’: New method for performing multiple hierarchical mkin fits in one function call, optionally in parallel.

    • -
    • ‘R/saem.R’: Implement and test saemix transformations for FOMC and HS. Also, error out if saemix transformations are requested but not supported.

    • -
    • ‘R/saem.R’: ‘logLik’ and ‘update’ methods for ‘saem.mmkin’ objects.

    • -
    • ‘R/convergence.R’: New generic to show convergence information with methods for ‘mmkin’ and ‘mhmkin’ objects.

    • + +
      • ‘R/saem.R’: ‘logLik’, ‘update’ and ‘anova’ methods for ‘saem.mmkin’ objects.

      • +
      • ‘R/saem.R’: Automatic estimation of start parameters for random effects for the case of mkin transformations, nicely improving convergence and reducing problems with iterative ODE solutions.

      • +
      • ‘R/status.R’: New generic to show status information for fit array objects with methods for ‘mmkin’, ‘mhmkin’ and ‘multistart’ objects.

      • +
      • ‘R/mhmkin.R’: New method for performing multiple hierarchical mkin fits in one function call, optionally in parallel.

      • +
      • ‘R/mhmkin.R’: ‘anova.mhmkin’ for conveniently comparing the resulting fits.

      • ‘R/illparms.R’: New generic to show ill-defined parameters with methods for ‘mkinfit’, ‘mmkin’, ‘saem.mmkin’ and ‘mhmkin’ objects.

      • +
      • ‘R/multistart.R’: New method for testing multiple start parameters for hierarchical model fits, with function ‘llhist’ and new generic ‘parplot’ for diagnostics, and new generics ‘which.best’ and ‘best’ for extracting the fit with the highest likelihood

      • ‘R/summary.mmkin.R’: Summary method for mmkin objects.

      • +
      • ‘R/saem.R’: Implement and test saemix transformations for FOMC and HS. Also, error out if saemix transformations are requested but not supported.

      • +
      • ‘R/read_spreadsheet.R’: Conveniently read in data from a spreadsheet file.

      • +
      • ‘R/tex_listings.R’: Conveniently include summaries of fit objects in R markdown documents that are compiled to LaTeX.

    diff --git a/docs/pkgdown.yml b/docs/pkgdown.yml index 7db87468..14c22439 100644 --- a/docs/pkgdown.yml +++ b/docs/pkgdown.yml @@ -11,7 +11,9 @@ articles: benchmarks: web_only/benchmarks.html compiled_models: web_only/compiled_models.html dimethenamid_2018: web_only/dimethenamid_2018.html -last_built: 2022-08-10T13:56Z + multistart: web_only/multistart.html + saem_benchmarks: web_only/saem_benchmarks.html +last_built: 2022-11-17T13:56Z urls: reference: https://pkgdown.jrwb.de/mkin/reference article: https://pkgdown.jrwb.de/mkin/articles diff --git a/docs/reference/AIC.mmkin.html b/docs/reference/AIC.mmkin.html index c46824e6..48e3b7e2 100644 --- a/docs/reference/AIC.mmkin.html +++ b/docs/reference/AIC.mmkin.html @@ -18,7 +18,7 @@ same dataset."> + + +
    +
    + + + +
    +
    + + +
    +

    Generate an anova object. The method to calculate the BIC is that from the +saemix package. As in other prominent anova methods, models are sorted by +number of parameters, and the tests (if requested) are always relative to +the model on the previous line.

    +
    + +
    +
    # S3 method for saem.mmkin
    +anova(
    +  object,
    +  ...,
    +  method = c("is", "lin", "gq"),
    +  test = FALSE,
    +  model.names = NULL
    +)
    +
    + +
    +

    Arguments

    +
    object
    +

    An saem.mmkin object

    + + +
    ...
    +

    further such objects

    + + +
    method
    +

    Method for likelihood calculation: "is" (importance sampling), +"lin" (linear approximation), or "gq" (Gaussian quadrature). Passed +to saemix::logLik.SaemixObject

    + + +
    test
    +

    Should a likelihood ratio test be performed? If TRUE, +the alternative models are tested against the first model. Should +only be done for nested models.

    + + +
    model.names
    +

    Optional character vector of model names

    + +
    +
    +

    Value

    + + +

    an "anova" data frame; the traditional (S3) result of anova()

    +
    + +
    + +
    + + +
    + +
    +

    Site built with pkgdown 2.0.6.

    +
    + +
    + + + + + + + + diff --git a/docs/reference/aw.html b/docs/reference/aw.html index 1694d5f7..c1e1b4ed 100644 --- a/docs/reference/aw.html +++ b/docs/reference/aw.html @@ -19,7 +19,7 @@ by Burnham and Anderson (2004)."> + + +
    +
    + + + +
    +
    + + +
    +

    Produces a histogram of log-likelihoods. In addition, the likelihood of the +original fit is shown as a red vertical line.

    +
    + +
    +
    llhist(object, breaks = "Sturges", lpos = "topleft", main = "", ...)
    +
    + +
    +

    Arguments

    +
    object
    +

    The multistart object

    + + +
    breaks
    +

    Passed to hist

    + + +
    lpos
    +

    Positioning of the legend.

    + + +
    main
    +

    Title of the plot

    + + +
    ...
    +

    Passed to hist

    + +
    +
    +

    See also

    + +
    + +
    + +
    + + +
    + +
    +

    Site built with pkgdown 2.0.6.

    +
    + +
    + + + + + + + + diff --git a/docs/reference/loftest-3.png b/docs/reference/loftest-3.png index a1a65a61..d897c363 100644 Binary files a/docs/reference/loftest-3.png and b/docs/reference/loftest-3.png differ diff --git a/docs/reference/loftest-5.png b/docs/reference/loftest-5.png index c441f2ed..0847bbec 100644 Binary files a/docs/reference/loftest-5.png and b/docs/reference/loftest-5.png differ diff --git a/docs/reference/loftest.html b/docs/reference/loftest.html index ee9b37e4..254b568f 100644 --- a/docs/reference/loftest.html +++ b/docs/reference/loftest.html @@ -20,7 +20,7 @@ lrtest.default from the lmtest package."> + + +
    +
    + + + +
    +
    + + +
    +

    logLik method for saem.mmkin objects

    +
    + +
    +
    # S3 method for saem.mmkin
    +logLik(object, ..., method = c("is", "lin", "gq"))
    +
    + +
    +

    Arguments

    +
    object
    +

    The fitted saem.mmkin object

    + + +
    ...
    +

    Passed to saemix::logLik.SaemixObject

    + + +
    method
    +

    Passed to saemix::logLik.SaemixObject

    + +
    + +
    + +
    + + +
    + +
    +

    Site built with pkgdown 2.0.6.

    +
    + +
    + + + + + + + + diff --git a/docs/reference/logistic.solution.html b/docs/reference/logistic.solution.html index b09d3a69..a63b1b1b 100644 --- a/docs/reference/logistic.solution.html +++ b/docs/reference/logistic.solution.html @@ -18,7 +18,7 @@ an increasing rate constant, supposedly caused by microbial growth"> mkin - 1.1.0 + 1.2.0
    @@ -48,11 +48,14 @@ and can be expressed by fixing the parameters of the other.">Example evaluations of dimethenamid data from 2018 with nonlinear mixed-effects models
  • - Example evaluation of FOCUS Example Dataset Z + Short demo of the multistart method
  • Performance benefit by using compiled model definitions in mkin
  • +
  • + Example evaluation of FOCUS Example Dataset Z +
  • Calculation of time weighted average concentrations with mkin
  • @@ -60,7 +63,10 @@ and can be expressed by fixing the parameters of the other.">Example evaluation of NAFTA SOP Attachment examples
  • - Some benchmark timings + Benchmark timings for mkin +
  • +
  • + Benchmark timings for saem.mmkin
  • @@ -95,11 +101,11 @@ and can be expressed by fixing the parameters of the other.

    -
    # S3 method for mkinfit
    -lrtest(object, object_2 = NULL, ...)
    -
    -# S3 method for mmkin
    -lrtest(object, ...)
    +
    # S3 method for mkinfit
    +lrtest(object, object_2 = NULL, ...)
    +
    +# S3 method for mmkin
    +lrtest(object, ...)
    @@ -107,11 +113,16 @@ and can be expressed by fixing the parameters of the other.

    object

    An mkinfit object, or an mmkin column object containing two fits to the same data.

    + +
    object_2

    Optionally, another mkinfit object fitted to the same data.

    + +
    ...

    Argument to mkinfit, passed to update.mkinfit for creating the alternative fitted object.

    +

    Details

    @@ -125,11 +136,11 @@ lower number of fitted parameters (null hypothesis).

    Examples

    -
    # \dontrun{
    -test_data <- subset(synthetic_data_for_UBA_2014[[12]]$data, name == "parent")
    -sfo_fit <- mkinfit("SFO", test_data, quiet = TRUE)
    -dfop_fit <- mkinfit("DFOP", test_data, quiet = TRUE)
    -lrtest(dfop_fit, sfo_fit)
    +    
    # \dontrun{
    +test_data <- subset(synthetic_data_for_UBA_2014[[12]]$data, name == "parent")
    +sfo_fit <- mkinfit("SFO", test_data, quiet = TRUE)
    +dfop_fit <- mkinfit("DFOP", test_data, quiet = TRUE)
    +lrtest(dfop_fit, sfo_fit)
     #> Likelihood ratio test
     #> 
     #> Model 1: DFOP with error model const
    @@ -139,7 +150,7 @@ lower number of fitted parameters (null hypothesis).

    #> 2 3 -63.954 -2 43.002 4.594e-10 *** #> --- #> Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1 -lrtest(sfo_fit, dfop_fit) +lrtest(sfo_fit, dfop_fit) #> Likelihood ratio test #> #> Model 1: DFOP with error model const @@ -149,14 +160,14 @@ lower number of fitted parameters (null hypothesis).

    #> 2 3 -63.954 -2 43.002 4.594e-10 *** #> --- #> Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1 - -# The following two examples are commented out as they fail during -# generation of the static help pages by pkgdown -#lrtest(dfop_fit, error_model = "tc") -#lrtest(dfop_fit, fixed_parms = c(k2 = 0)) - -# However, this equivalent syntax also works for static help pages -lrtest(dfop_fit, update(dfop_fit, error_model = "tc")) + +# The following two examples are commented out as they fail during +# generation of the static help pages by pkgdown +#lrtest(dfop_fit, error_model = "tc") +#lrtest(dfop_fit, fixed_parms = c(k2 = 0)) + +# However, this equivalent syntax also works for static help pages +lrtest(dfop_fit, update(dfop_fit, error_model = "tc")) #> Likelihood ratio test #> #> Model 1: DFOP with error model tc @@ -166,7 +177,7 @@ lower number of fitted parameters (null hypothesis).

    #> 2 5 -42.453 -1 15.731 7.302e-05 *** #> --- #> Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1 -lrtest(dfop_fit, update(dfop_fit, fixed_parms = c(k2 = 0))) +lrtest(dfop_fit, update(dfop_fit, fixed_parms = c(k2 = 0))) #> Likelihood ratio test #> #> Model 1: DFOP with error model const @@ -176,7 +187,7 @@ lower number of fitted parameters (null hypothesis).

    #> 2 4 -57.340 -1 29.776 4.851e-08 *** #> --- #> Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1 -# } +# }
    @@ -191,7 +202,7 @@ lower number of fitted parameters (null hypothesis).

    -

    Site built with pkgdown 2.0.3.

    +

    Site built with pkgdown 2.0.6.

    diff --git a/docs/reference/max_twa_parent.html b/docs/reference/max_twa_parent.html index 69da881b..3c8e1662 100644 --- a/docs/reference/max_twa_parent.html +++ b/docs/reference/max_twa_parent.html @@ -23,7 +23,7 @@ soil section of the FOCUS guidance."> + + +
    +
    + + + +
    +
    + + +
    +

    The purpose of this method is to check if a certain algorithm for fitting +nonlinear hierarchical models (also known as nonlinear mixed-effects models) +will reliably yield results that are sufficiently similar to each other, if +started with a certain range of reasonable starting parameters. It is +inspired by the article on practical identifiabiliy in the frame of nonlinear +mixed-effects models by Duchesne et al (2021).

    +
    + +
    +
    multistart(
    +  object,
    +  n = 50,
    +  cores = if (Sys.info()["sysname"] == "Windows") 1 else parallel::detectCores(),
    +  cluster = NULL,
    +  ...
    +)
    +
    +# S3 method for saem.mmkin
    +multistart(object, n = 50, cores = 1, cluster = NULL, ...)
    +
    +# S3 method for multistart
    +print(x, ...)
    +
    +best(object, ...)
    +
    +# S3 method for default
    +best(object, ...)
    +
    +which.best(object, ...)
    +
    +# S3 method for default
    +which.best(object, ...)
    +
    + +
    +

    Arguments

    +
    object
    +

    The fit object to work with

    + + +
    n
    +

    How many different combinations of starting parameters should be +used?

    + + +
    cores
    +

    How many fits should be run in parallel (only on posix platforms)?

    + + +
    cluster
    +

    A cluster as returned by parallel::makeCluster to be used +for parallel execution.

    + + +
    ...
    +

    Passed to the update function.

    + + +
    x
    +

    The multistart object to print

    + +
    +
    +

    Value

    + + +

    A list of saem.mmkin objects, with class attributes +'multistart.saem.mmkin' and 'multistart'.

    + + +

    The object with the highest likelihood

    + + +

    The index of the object with the highest likelihood

    +
    +
    +

    References

    +

    Duchesne R, Guillemin A, Gandrillon O, Crauste F. Practical +identifiability in the frame of nonlinear mixed effects models: the example +of the in vitro erythropoiesis. BMC Bioinformatics. 2021 Oct 4;22(1):478. +doi: 10.1186/s12859-021-04373-4.

    +
    +
    +

    See also

    + +
    + +
    +

    Examples

    +
    # \dontrun{
    +library(mkin)
    +dmta_ds <- lapply(1:7, function(i) {
    +  ds_i <- dimethenamid_2018$ds[[i]]$data
    +  ds_i[ds_i$name == "DMTAP", "name"] <-  "DMTA"
    +  ds_i$time <- ds_i$time * dimethenamid_2018$f_time_norm[i]
    +  ds_i
    +})
    +names(dmta_ds) <- sapply(dimethenamid_2018$ds, function(ds) ds$title)
    +dmta_ds[["Elliot"]] <- rbind(dmta_ds[["Elliot 1"]], dmta_ds[["Elliot 2"]])
    +dmta_ds[["Elliot 1"]] <- dmta_ds[["Elliot 2"]] <- NULL
    +
    +f_mmkin <- mmkin("DFOP", dmta_ds, error_model = "tc", cores = 7, quiet = TRUE)
    +f_saem_full <- saem(f_mmkin)
    +f_saem_full_multi <- multistart(f_saem_full, n = 16, cores = 16)
    +parplot(f_saem_full_multi, lpos = "topleft")
    +
    +illparms(f_saem_full)
    +#> [1] "sd(log_k2)"
    +
    +f_saem_reduced <- update(f_saem_full, no_random_effect = "log_k2")
    +illparms(f_saem_reduced)
    +# On Windows, we need to create a cluster first. When working with
    +# such a cluster, we need to export the mmkin object to the cluster
    +# nodes, as it is referred to when updating the saem object on the nodes.
    +library(parallel)
    +cl <- makePSOCKcluster(12)
    +f_saem_reduced_multi <- multistart(f_saem_reduced, n = 16, cluster = cl)
    +parplot(f_saem_reduced_multi, lpos = "topright")
    +
    +stopCluster(cl)
    +# }
    +
    +
    +
    + +
    + + +
    + +
    +

    Site built with pkgdown 2.0.6.

    +
    + +
    + + + + + + + + diff --git a/docs/reference/nafta.html b/docs/reference/nafta.html index 1d22b617..5906db4c 100644 --- a/docs/reference/nafta.html +++ b/docs/reference/nafta.html @@ -21,7 +21,7 @@ order of increasing model complexity, i.e. SFO, then IORE, and finally DFOP."> mkin - 1.1.0 + 1.2.0 @@ -48,11 +48,14 @@ order of increasing model complexity, i.e. SFO, then IORE, and finally DFOP.">Example evaluations of dimethenamid data from 2018 with nonlinear mixed-effects models
  • - Example evaluation of FOCUS Example Dataset Z + Short demo of the multistart method
  • Performance benefit by using compiled model definitions in mkin
  • +
  • + Example evaluation of FOCUS Example Dataset Z +
  • Calculation of time weighted average concentrations with mkin
  • @@ -60,7 +63,10 @@ order of increasing model complexity, i.e. SFO, then IORE, and finally DFOP.">Example evaluation of NAFTA SOP Attachment examples
  • - Some benchmark timings + Benchmark timings for mkin +
  • +
  • + Benchmark timings for saem.mmkin
  • @@ -95,10 +101,10 @@ order of increasing model complexity, i.e. SFO, then IORE, and finally DFOP.

    -
    nafta(ds, title = NA, quiet = FALSE, ...)
    -
    -# S3 method for nafta
    -print(x, quiet = TRUE, digits = 3, ...)
    +
    nafta(ds, title = NA, quiet = FALSE, ...)
    +
    +# S3 method for nafta
    +print(x, quiet = TRUE, digits = 3, ...)
    @@ -120,22 +126,35 @@ Degradation time values specified by the time argument, one column called "name" with the grouping of the observed values, and finally one column of observed values called "value".

    + +
    title

    Optional title of the dataset

    + +
    quiet

    Should the evaluation text be shown?

    + +
    ...

    Further arguments passed to mmkin (not for the printing method).

    + +
    x

    An nafta object.

    + +
    digits

    Number of digits to be used for printing parameters and dissipation times.

    +

    Value

    -

    An list of class nafta. The list element named "mmkin" is the + + +

    An list of class nafta. The list element named "mmkin" is the mmkin object containing the fits of the three models. The list element named "title" contains the title of the dataset used. The list element "data" contains the dataset used in the fits.

    @@ -147,13 +166,13 @@ list element "data" contains the dataset used in the fits.

    Examples

    -
    
    -  nafta_evaluation <- nafta(NAFTA_SOP_Appendix_D, cores = 1)
    +    
    
    +  nafta_evaluation <- nafta(NAFTA_SOP_Appendix_D, cores = 1)
     #> The SFO model is rejected as S_SFO is equal or higher than the critical value S_c
     #> The representative half-life of the IORE model is longer than the one corresponding
     #> to the terminal degradation rate found with the DFOP model.
     #> The representative half-life obtained from the DFOP model may be used
    -  print(nafta_evaluation)
    +  print(nafta_evaluation)
     #> Sums of squares:
     #>       SFO      IORE      DFOP 
     #> 1378.6832  615.7730  517.8836 
    @@ -192,9 +211,9 @@ list element "data" contains the dataset used in the fits.

    #> #> Representative half-life: #> [1] 841.41 - plot(nafta_evaluation) + plot(nafta_evaluation) - +
    @@ -209,7 +228,7 @@ list element "data" contains the dataset used in the fits.

    -

    Site built with pkgdown 2.0.3.

    +

    Site built with pkgdown 2.0.6.

    diff --git a/docs/reference/nlme-1.png b/docs/reference/nlme-1.png index 0b6cb78d..f4d04e1d 100644 Binary files a/docs/reference/nlme-1.png and b/docs/reference/nlme-1.png differ diff --git a/docs/reference/nlme-2.png b/docs/reference/nlme-2.png index ef152270..d9512f41 100644 Binary files a/docs/reference/nlme-2.png and b/docs/reference/nlme-2.png differ diff --git a/docs/reference/nlme.html b/docs/reference/nlme.html index ff8de9f3..83576e56 100644 --- a/docs/reference/nlme.html +++ b/docs/reference/nlme.html @@ -20,7 +20,7 @@ datasets. They are used internally by the nlme.mmkin() method."> mkin - 1.1.0 + 1.2.0 @@ -47,11 +47,14 @@ datasets. They are used internally by the nlme.mmkin() method."> Example evaluations of dimethenamid data from 2018 with nonlinear mixed-effects models
  • - Example evaluation of FOCUS Example Dataset Z + Short demo of the multistart method
  • Performance benefit by using compiled model definitions in mkin
  • +
  • + Example evaluation of FOCUS Example Dataset Z +
  • Calculation of time weighted average concentrations with mkin
  • @@ -59,7 +62,10 @@ datasets. They are used internally by the nlme.mmkin() method."> Example evaluation of NAFTA SOP Attachment examples
  • - Some benchmark timings + Benchmark timings for mkin +
  • +
  • + Benchmark timings for saem.mmkin
  • @@ -93,20 +99,25 @@ datasets. They are used internally by the nlme.m
    -
    nlme_function(object)
    -
    -nlme_data(object)
    +
    nlme_function(object)
    +
    +nlme_data(object)

    Arguments

    object

    An mmkin row object containing several fits of the same model to different datasets

    +

    Value

    -

    A function that can be used with nlme -A groupedData object

    + + +

    A function that can be used with nlme

    + + +

    A groupedData object

    See also

    @@ -115,78 +126,78 @@ A

    Examples

    -
    sampling_times = c(0, 1, 3, 7, 14, 28, 60, 90, 120)
    -m_SFO <- mkinmod(parent = mkinsub("SFO"))
    -d_SFO_1 <- mkinpredict(m_SFO,
    -  c(k_parent = 0.1),
    -  c(parent = 98), sampling_times)
    -d_SFO_1_long <- mkin_wide_to_long(d_SFO_1, time = "time")
    -d_SFO_2 <- mkinpredict(m_SFO,
    -  c(k_parent = 0.05),
    -  c(parent = 102), sampling_times)
    -d_SFO_2_long <- mkin_wide_to_long(d_SFO_2, time = "time")
    -d_SFO_3 <- mkinpredict(m_SFO,
    -  c(k_parent = 0.02),
    -  c(parent = 103), sampling_times)
    -d_SFO_3_long <- mkin_wide_to_long(d_SFO_3, time = "time")
    -
    -d1 <- add_err(d_SFO_1, function(value) 3, n = 1)
    -d2 <- add_err(d_SFO_2, function(value) 2, n = 1)
    -d3 <- add_err(d_SFO_3, function(value) 4, n = 1)
    -ds <- c(d1 = d1, d2 = d2, d3 = d3)
    -
    -f <- mmkin("SFO", ds, cores = 1, quiet = TRUE)
    -mean_dp <- mean_degparms(f)
    -grouped_data <- nlme_data(f)
    -nlme_f <- nlme_function(f)
    -# These assignments are necessary for these objects to be
    -# visible to nlme and augPred when evaluation is done by
    -# pkgdown to generate the html docs.
    -assign("nlme_f", nlme_f, globalenv())
    -assign("grouped_data", grouped_data, globalenv())
    -
    -library(nlme)
    -m_nlme <- nlme(value ~ nlme_f(name, time, parent_0, log_k_parent_sink),
    -  data = grouped_data,
    -  fixed = parent_0 + log_k_parent_sink ~ 1,
    -  random = pdDiag(parent_0 + log_k_parent_sink ~ 1),
    -  start = mean_dp)
    -summary(m_nlme)
    +    
    sampling_times = c(0, 1, 3, 7, 14, 28, 60, 90, 120)
    +m_SFO <- mkinmod(parent = mkinsub("SFO"))
    +d_SFO_1 <- mkinpredict(m_SFO,
    +  c(k_parent = 0.1),
    +  c(parent = 98), sampling_times)
    +d_SFO_1_long <- mkin_wide_to_long(d_SFO_1, time = "time")
    +d_SFO_2 <- mkinpredict(m_SFO,
    +  c(k_parent = 0.05),
    +  c(parent = 102), sampling_times)
    +d_SFO_2_long <- mkin_wide_to_long(d_SFO_2, time = "time")
    +d_SFO_3 <- mkinpredict(m_SFO,
    +  c(k_parent = 0.02),
    +  c(parent = 103), sampling_times)
    +d_SFO_3_long <- mkin_wide_to_long(d_SFO_3, time = "time")
    +
    +d1 <- add_err(d_SFO_1, function(value) 3, n = 1)
    +d2 <- add_err(d_SFO_2, function(value) 2, n = 1)
    +d3 <- add_err(d_SFO_3, function(value) 4, n = 1)
    +ds <- c(d1 = d1, d2 = d2, d3 = d3)
    +
    +f <- mmkin("SFO", ds, cores = 1, quiet = TRUE)
    +mean_dp <- mean_degparms(f)
    +grouped_data <- nlme_data(f)
    +nlme_f <- nlme_function(f)
    +# These assignments are necessary for these objects to be
    +# visible to nlme and augPred when evaluation is done by
    +# pkgdown to generate the html docs.
    +assign("nlme_f", nlme_f, globalenv())
    +assign("grouped_data", grouped_data, globalenv())
    +
    +library(nlme)
    +m_nlme <- nlme(value ~ nlme_f(name, time, parent_0, log_k_parent_sink),
    +  data = grouped_data,
    +  fixed = parent_0 + log_k_parent_sink ~ 1,
    +  random = pdDiag(parent_0 + log_k_parent_sink ~ 1),
    +  start = mean_dp)
    +summary(m_nlme)
     #> Nonlinear mixed-effects model fit by maximum likelihood
     #>   Model: value ~ nlme_f(name, time, parent_0, log_k_parent_sink) 
     #>   Data: grouped_data 
     #>        AIC      BIC    logLik
    -#>   300.6824 310.2426 -145.3412
    +#>   266.6428 275.8935 -128.3214
     #> 
     #> Random effects:
     #>  Formula: list(parent_0 ~ 1, log_k_parent_sink ~ 1)
     #>  Level: ds
     #>  Structure: Diagonal
    -#>         parent_0 log_k_parent_sink Residual
    -#> StdDev: 1.697361         0.6801209 3.666073
    +#>            parent_0 log_k_parent_sink Residual
    +#> StdDev: 0.000368491         0.7058039 3.065183
     #> 
     #> Fixed effects:  parent_0 + log_k_parent_sink ~ 1 
    -#>                       Value Std.Error DF  t-value p-value
    -#> parent_0          100.99378 1.3890416 46 72.70753       0
    -#> log_k_parent_sink  -3.07521 0.4018589 46 -7.65246       0
    +#>                       Value Std.Error DF   t-value p-value
    +#> parent_0          101.18323 0.7900461 43 128.07257       0
    +#> log_k_parent_sink  -3.08708 0.4171755 43  -7.39995       0
     #>  Correlation: 
     #>                   prnt_0
    -#> log_k_parent_sink 0.027 
    +#> log_k_parent_sink 0.031 
     #> 
     #> Standardized Within-Group Residuals:
    -#>        Min         Q1        Med         Q3        Max 
    -#> -1.9942823 -0.5622565  0.1791579  0.7165038  2.0704781 
    +#>         Min          Q1         Med          Q3         Max 
    +#> -2.38427070 -0.52059848  0.03593021  0.39987268  2.73188969 
     #> 
    -#> Number of Observations: 50
    +#> Number of Observations: 47
     #> Number of Groups: 3 
    -plot(augPred(m_nlme, level = 0:1), layout = c(3, 1))
    +plot(augPred(m_nlme, level = 0:1), layout = c(3, 1))
     
    -# augPred does not work on fits with more than one state
    -# variable
    -#
    -# The procedure is greatly simplified by the nlme.mmkin function
    -f_nlme <- nlme(f)
    -plot(f_nlme)
    +# augPred does not work on fits with more than one state
    +# variable
    +#
    +# The procedure is greatly simplified by the nlme.mmkin function
    +f_nlme <- nlme(f)
    +plot(f_nlme)
     
     
    @@ -202,7 +213,7 @@ A -

    Site built with pkgdown 2.0.3.

    +

    Site built with pkgdown 2.0.6.

    diff --git a/docs/reference/nlme.mmkin.html b/docs/reference/nlme.mmkin.html index c8bd28e9..1e294eaf 100644 --- a/docs/reference/nlme.mmkin.html +++ b/docs/reference/nlme.mmkin.html @@ -19,7 +19,7 @@ have been obtained by fitting the same model to a list of datasets.">Extract model parameters from mkinfit models — parms • mkinExtract model parameters — parms • mkin @@ -19,7 +19,7 @@ considering the error structure that was assumed for the fit.">< mkin - 1.1.0 + 1.2.0 @@ -46,11 +46,14 @@ considering the error structure that was assumed for the fit.">< Example evaluations of dimethenamid data from 2018 with nonlinear mixed-effects models
  • - Example evaluation of FOCUS Example Dataset Z + Short demo of the multistart method
  • Performance benefit by using compiled model definitions in mkin
  • +
  • + Example evaluation of FOCUS Example Dataset Z +
  • Calculation of time weighted average concentrations with mkin
  • @@ -58,7 +61,10 @@ considering the error structure that was assumed for the fit.">< Example evaluation of NAFTA SOP Attachment examples
  • - Some benchmark timings + Benchmark timings for mkin +
  • +
  • + Benchmark timings for saem.mmkin
  • @@ -79,69 +85,91 @@ considering the error structure that was assumed for the fit."><
    -

    This function always returns degradation model parameters as well as error -model parameters, in order to avoid working with a fitted model without -considering the error structure that was assumed for the fit.

    +

    This function returns degradation model parameters as well as error +model parameters per default, in order to avoid working with a fitted model +without considering the error structure that was assumed for the fit.

    -
    parms(object, ...)
    -
    -# S3 method for mkinfit
    -parms(object, transformed = FALSE, ...)
    -
    -# S3 method for mmkin
    -parms(object, transformed = FALSE, ...)
    +
    parms(object, ...)
    +
    +# S3 method for mkinfit
    +parms(object, transformed = FALSE, errparms = TRUE, ...)
    +
    +# S3 method for mmkin
    +parms(object, transformed = FALSE, errparms = TRUE, ...)
    +
    +# S3 method for multistart
    +parms(object, exclude_failed = TRUE, ...)

    Arguments

    object
    -

    A fitted model object. Methods are implemented for -mkinfit() objects and for mmkin() objects.

    +

    A fitted model object.

    + +
    ...

    Not used

    + +
    transformed
    -

    Should the parameters be returned -as used internally during the optimisation?

    +

    Should the parameters be returned as used internally +during the optimisation?

    + + +
    errparms
    +

    Should the error model parameters be returned +in addition to the degradation parameters?

    + + +
    exclude_failed
    +

    For multistart objects, should rows for failed fits +be removed from the returned parameter matrix?

    +

    Value

    -

    For mkinfit objects, a numeric vector of fitted model parameters. -For mmkin row objects, a matrix with the parameters with a -row for each dataset. If the mmkin object has more than one row, a list of -such matrices is returned.

    + + +

    Depending on the object, a numeric vector of fitted model parameters, +a matrix (e.g. for mmkin row objects), or a list of matrices (e.g. for +mmkin objects with more than one row).

    +
    +
    +

    See also

    +

    Examples

    -
    # mkinfit objects
    -fit <- mkinfit("SFO", FOCUS_2006_C, quiet = TRUE)
    -parms(fit)
    +    
    # mkinfit objects
    +fit <- mkinfit("SFO", FOCUS_2006_C, quiet = TRUE)
    +parms(fit)
     #>   parent_0   k_parent      sigma 
     #> 82.4921598  0.3060633  4.6730124 
    -parms(fit, transformed = TRUE)
    +parms(fit, transformed = TRUE)
     #>     parent_0 log_k_parent        sigma 
     #>    82.492160    -1.183963     4.673012 
    -
    -# mmkin objects
    -ds <- lapply(experimental_data_for_UBA_2019[6:10],
    - function(x) subset(x$data[c("name", "time", "value")]))
    -names(ds) <- paste("Dataset", 6:10)
    -# \dontrun{
    -fits <- mmkin(c("SFO", "FOMC", "DFOP"), ds, quiet = TRUE, cores = 1)
    -parms(fits["SFO", ])
    +
    +# mmkin objects
    +ds <- lapply(experimental_data_for_UBA_2019[6:10],
    + function(x) subset(x$data[c("name", "time", "value")]))
    +names(ds) <- paste("Dataset", 6:10)
    +# \dontrun{
    +fits <- mmkin(c("SFO", "FOMC", "DFOP"), ds, quiet = TRUE, cores = 1)
    +parms(fits["SFO", ])
     #>            Dataset 6    Dataset 7  Dataset 8  Dataset 9  Dataset 10
     #> parent_0 88.52275400 82.666781678 86.8547308 91.7779306 82.14809450
     #> k_parent  0.05794659  0.009647805  0.2102974  0.1232258  0.00720421
     #> sigma     5.15274487  7.040168584  3.6769645  6.4669234  6.50457673
    -parms(fits[, 2])
    +parms(fits[, 2])
     #> $SFO
     #>             Dataset 7
     #> parent_0 82.666781678
    @@ -157,13 +185,13 @@ such matrices is returned.

    #> #> $DFOP #> Dataset 7 -#> parent_0 91.058971599 +#> parent_0 91.058971589 #> k1 0.044946770 #> k2 0.002868336 -#> g 0.526942414 +#> g 0.526942415 #> sigma 2.221302196 #> -parms(fits) +parms(fits) #> $SFO #> Dataset 6 Dataset 7 Dataset 8 Dataset 9 Dataset 10 #> parent_0 88.52275400 82.666781678 86.8547308 91.7779306 82.14809450 @@ -179,13 +207,13 @@ such matrices is returned.

    #> #> $DFOP #> Dataset 6 Dataset 7 Dataset 8 Dataset 9 Dataset 10 -#> parent_0 96.55213663 91.058971599 90.34509493 98.14858821 94.311323732 +#> parent_0 96.55213663 91.058971589 90.34509493 98.14858820 94.311323734 #> k1 0.21954588 0.044946770 0.41232288 0.31697588 0.080663857 #> k2 0.02957934 0.002868336 0.07581766 0.03260384 0.003425417 -#> g 0.44845068 0.526942414 0.66091967 0.65322767 0.342652880 +#> g 0.44845068 0.526942415 0.66091967 0.65322767 0.342652880 #> sigma 1.35690468 2.221302196 1.34169076 2.87159846 1.942067831 #> -parms(fits, transformed = TRUE) +parms(fits, transformed = TRUE) #> $SFO #> Dataset 6 Dataset 7 Dataset 8 Dataset 9 Dataset 10 #> parent_0 88.522754 82.666782 86.854731 91.777931 82.148094 @@ -207,7 +235,7 @@ such matrices is returned.

    #> g_qlogis -0.2069326 0.1078741 0.6673953 0.6332573 -0.6514943 #> sigma 1.3569047 2.2213022 1.3416908 2.8715985 1.9420678 #> -# } +# }
    @@ -222,7 +250,7 @@ such matrices is returned.

    -

    Site built with pkgdown 2.0.3.

    +

    Site built with pkgdown 2.0.6.

    diff --git a/docs/reference/parplot.html b/docs/reference/parplot.html new file mode 100644 index 00000000..f4f3c811 --- /dev/null +++ b/docs/reference/parplot.html @@ -0,0 +1,175 @@ + +Plot parameter variability of multistart objects — parplot • mkin + + +
    +
    + + + +
    +
    + + +
    +

    Produces a boxplot with all parameters from the multiple runs, scaled +either by the parameters of the run with the highest likelihood, +or by their medians as proposed in the paper by Duchesne et al. (2021).

    +
    + +
    +
    parplot(object, ...)
    +
    +# S3 method for multistart.saem.mmkin
    +parplot(
    +  object,
    +  llmin = -Inf,
    +  scale = c("best", "median"),
    +  lpos = "bottomleft",
    +  main = "",
    +  ...
    +)
    +
    + +
    +

    Arguments

    +
    object
    +

    The multistart object

    + + +
    ...
    +

    Passed to boxplot

    + + +
    llmin
    +

    The minimum likelihood of objects to be shown

    + + +
    scale
    +

    By default, scale parameters using the best available fit. +If 'median', parameters are scaled using the median parameters from all fits.

    + + +
    lpos
    +

    Positioning of the legend.

    + + +
    main
    +

    Title of the plot

    + +
    +
    +

    References

    +

    Duchesne R, Guillemin A, Gandrillon O, Crauste F. Practical +identifiability in the frame of nonlinear mixed effects models: the example +of the in vitro erythropoiesis. BMC Bioinformatics. 2021 Oct 4;22(1):478. +doi: 10.1186/s12859-021-04373-4.

    +
    +
    +

    See also

    + +
    + +
    + +
    + + +
    + +
    +

    Site built with pkgdown 2.0.6.

    +
    + +
    + + + + + + + + diff --git a/docs/reference/plot.mixed.mmkin-2.png b/docs/reference/plot.mixed.mmkin-2.png index b35f28d6..8678c166 100644 Binary files a/docs/reference/plot.mixed.mmkin-2.png and b/docs/reference/plot.mixed.mmkin-2.png differ diff --git a/docs/reference/plot.mixed.mmkin-3.png b/docs/reference/plot.mixed.mmkin-3.png index c981538f..9bd01852 100644 Binary files a/docs/reference/plot.mixed.mmkin-3.png and b/docs/reference/plot.mixed.mmkin-3.png differ diff --git a/docs/reference/plot.mixed.mmkin-4.png b/docs/reference/plot.mixed.mmkin-4.png index ccbe5861..a849aaee 100644 Binary files a/docs/reference/plot.mixed.mmkin-4.png and b/docs/reference/plot.mixed.mmkin-4.png differ diff --git a/docs/reference/plot.mixed.mmkin.html b/docs/reference/plot.mixed.mmkin.html index 2af2328d..b1083204 100644 --- a/docs/reference/plot.mixed.mmkin.html +++ b/docs/reference/plot.mixed.mmkin.html @@ -17,7 +17,7 @@ mkin - 1.1.0 + 1.2.0 @@ -44,11 +44,14 @@ Example evaluations of dimethenamid data from 2018 with nonlinear mixed-effects models
  • - Example evaluation of FOCUS Example Dataset Z + Short demo of the multistart method
  • Performance benefit by using compiled model definitions in mkin
  • +
  • + Example evaluation of FOCUS Example Dataset Z +
  • Calculation of time weighted average concentrations with mkin
  • @@ -56,7 +59,10 @@ Example evaluation of NAFTA SOP Attachment examples
  • - Some benchmark timings + Benchmark timings for mkin +
  • +
  • + Benchmark timings for saem.mmkin
  • @@ -87,94 +93,146 @@
    -
    # S3 method for mixed.mmkin
    -plot(
    -  x,
    -  i = 1:ncol(x$mmkin),
    -  obs_vars = names(x$mkinmod$map),
    -  standardized = TRUE,
    -  xlab = "Time",
    -  xlim = range(x$data$time),
    -  resplot = c("predicted", "time"),
    -  pred_over = NULL,
    -  test_log_parms = FALSE,
    -  conf.level = 0.6,
    -  default_log_parms = NA,
    -  ymax = "auto",
    -  maxabs = "auto",
    -  ncol.legend = ifelse(length(i) <= 3, length(i) + 1, ifelse(length(i) <= 8, 3, 4)),
    -  nrow.legend = ceiling((length(i) + 1)/ncol.legend),
    -  rel.height.legend = 0.02 + 0.07 * nrow.legend,
    -  rel.height.bottom = 1.1,
    -  pch_ds = 1:length(i),
    -  col_ds = pch_ds + 1,
    -  lty_ds = col_ds,
    -  frame = TRUE,
    -  ...
    -)
    +
    # S3 method for mixed.mmkin
    +plot(
    +  x,
    +  i = 1:ncol(x$mmkin),
    +  obs_vars = names(x$mkinmod$map),
    +  standardized = TRUE,
    +  xlab = "Time",
    +  xlim = range(x$data$time),
    +  resplot = c("predicted", "time"),
    +  pop_curve = "auto",
    +  pred_over = NULL,
    +  test_log_parms = FALSE,
    +  conf.level = 0.6,
    +  default_log_parms = NA,
    +  ymax = "auto",
    +  maxabs = "auto",
    +  ncol.legend = ifelse(length(i) <= 3, length(i) + 1, ifelse(length(i) <= 8, 3, 4)),
    +  nrow.legend = ceiling((length(i) + 1)/ncol.legend),
    +  rel.height.legend = 0.02 + 0.07 * nrow.legend,
    +  rel.height.bottom = 1.1,
    +  pch_ds = 1:length(i),
    +  col_ds = pch_ds + 1,
    +  lty_ds = col_ds,
    +  frame = TRUE,
    +  ...
    +)

    Arguments

    x

    An object of class mixed.mmkin, saem.mmkin or nlme.mmkin

    + +
    i

    A numeric index to select datasets for which to plot the individual predictions, in case plots get too large

    + +
    obs_vars

    A character vector of names of the observed variables for which the data and the model should be plotted. Defauls to all observed variables in the model.

    + +
    standardized

    Should the residuals be standardized? Only takes effect if resplot = "time".

    + +
    xlab

    Label for the x axis.

    + +
    xlim

    Plot range in x direction.

    + +
    resplot

    Should the residuals plotted against time or against predicted values?

    + + +
    pop_curve
    +

    Per default, a population curve is drawn in case +population parameters are fitted by the model, e.g. for saem objects. +In case there is a covariate model, no population curve is currently shown.

    + +
    pred_over

    Named list of alternative predictions as obtained from mkinpredict with a compatible mkinmod.

    + +
    test_log_parms

    Passed to mean_degparms in the case of an mixed.mmkin object

    + +
    conf.level

    Passed to mean_degparms in the case of an mixed.mmkin object

    + +
    default_log_parms

    Passed to mean_degparms in the case of an mixed.mmkin object

    + +
    ymax

    Vector of maximum y axis values

    + +
    maxabs

    Maximum absolute value of the residuals. This is used for the scaling of the y axis and defaults to "auto".

    + +
    ncol.legend

    Number of columns to use in the legend

    + +
    nrow.legend

    Number of rows to use in the legend

    + +
    rel.height.legend

    The relative height of the legend shown on top

    + +
    rel.height.bottom

    The relative height of the bottom plot row

    + +
    pch_ds

    Symbols to be used for plotting the data.

    + +
    col_ds

    Colors used for plotting the observed data and the corresponding model prediction lines for the different datasets.

    + +
    lty_ds

    Line types to be used for the model predictions.

    + +
    frame

    Should a frame be drawn around the plots?

    + +
    ...

    Further arguments passed to plot.

    +

    Value

    -

    The function is called for its side effect.

    + + +

    The function is called for its side effect.

    Author

    @@ -183,41 +241,41 @@ corresponding model prediction lines for the different datasets.

    Examples

    -
    ds <- lapply(experimental_data_for_UBA_2019[6:10],
    - function(x) x$data[c("name", "time", "value")])
    -names(ds) <- paste0("ds ", 6:10)
    -dfop_sfo <- mkinmod(parent = mkinsub("DFOP", "A1"),
    -  A1 = mkinsub("SFO"), quiet = TRUE)
    -# \dontrun{
    -f <- mmkin(list("DFOP-SFO" = dfop_sfo), ds, quiet = TRUE)
    -plot(f[, 3:4], standardized = TRUE)
    +    
    ds <- lapply(experimental_data_for_UBA_2019[6:10],
    + function(x) x$data[c("name", "time", "value")])
    +names(ds) <- paste0("ds ", 6:10)
    +dfop_sfo <- mkinmod(parent = mkinsub("DFOP", "A1"),
    +  A1 = mkinsub("SFO"), quiet = TRUE)
    +# \dontrun{
    +f <- mmkin(list("DFOP-SFO" = dfop_sfo), ds, quiet = TRUE)
    +plot(f[, 3:4], standardized = TRUE)
     
    -
    -# For this fit we need to increase pnlsMaxiter, and we increase the
    -# tolerance in order to speed up the fit for this example evaluation
    -# It still takes 20 seconds to run
    -f_nlme <- nlme(f, control = list(pnlsMaxIter = 120, tolerance = 1e-3))
    -plot(f_nlme)
    +
    +# For this fit we need to increase pnlsMaxiter, and we increase the
    +# tolerance in order to speed up the fit for this example evaluation
    +# It still takes 20 seconds to run
    +f_nlme <- nlme(f, control = list(pnlsMaxIter = 120, tolerance = 1e-3))
    +plot(f_nlme)
     
    -
    -f_saem <- saem(f, transformations = "saemix")
    -plot(f_saem)
    +
    +f_saem <- saem(f, transformations = "saemix")
    +plot(f_saem)
     
    -
    -f_obs <- mmkin(list("DFOP-SFO" = dfop_sfo), ds, quiet = TRUE, error_model = "obs")
    -f_nlmix <- nlmix(f_obs)
    +
    +f_obs <- mmkin(list("DFOP-SFO" = dfop_sfo), ds, quiet = TRUE, error_model = "obs")
    +f_nlmix <- nlmix(f_obs)
     #> Error in nlmix(f_obs): could not find function "nlmix"
    -plot(f_nlmix)
    +plot(f_nlmix)
     #> Error in plot(f_nlmix): object 'f_nlmix' not found
    -
    -# We can overlay the two variants if we generate predictions
    -pred_nlme <- mkinpredict(dfop_sfo,
    -  f_nlme$bparms.optim[-1],
    -  c(parent = f_nlme$bparms.optim[[1]], A1 = 0),
    -  seq(0, 180, by = 0.2))
    -plot(f_saem, pred_over = list(nlme = pred_nlme))
    +
    +# We can overlay the two variants if we generate predictions
    +pred_nlme <- mkinpredict(dfop_sfo,
    +  f_nlme$bparms.optim[-1],
    +  c(parent = f_nlme$bparms.optim[[1]], A1 = 0),
    +  seq(0, 180, by = 0.2))
    +plot(f_saem, pred_over = list(nlme = pred_nlme))
     
    -# }
    +# }
     
    @@ -232,7 +290,7 @@ corresponding model prediction lines for the different datasets.

    -

    Site built with pkgdown 2.0.3.

    +

    Site built with pkgdown 2.0.6.

    diff --git a/docs/reference/plot.mkinfit-2.png b/docs/reference/plot.mkinfit-2.png index 39098648..cef94cb8 100644 Binary files a/docs/reference/plot.mkinfit-2.png and b/docs/reference/plot.mkinfit-2.png differ diff --git a/docs/reference/plot.mkinfit-5.png b/docs/reference/plot.mkinfit-5.png index 3545b8d8..f90b3f54 100644 Binary files a/docs/reference/plot.mkinfit-5.png and b/docs/reference/plot.mkinfit-5.png differ diff --git a/docs/reference/plot.mkinfit-7.png b/docs/reference/plot.mkinfit-7.png index daf43033..3e5d828e 100644 Binary files a/docs/reference/plot.mkinfit-7.png and b/docs/reference/plot.mkinfit-7.png differ diff --git a/docs/reference/plot.mkinfit.html b/docs/reference/plot.mkinfit.html index 23cf27b5..cf96990e 100644 --- a/docs/reference/plot.mkinfit.html +++ b/docs/reference/plot.mkinfit.html @@ -19,7 +19,7 @@ observed data together with the solution of the fitted model.">< mkin - 1.1.0 + 1.2.0 @@ -46,11 +46,14 @@ observed data together with the solution of the fitted model.">< Example evaluations of dimethenamid data from 2018 with nonlinear mixed-effects models
  • - Example evaluation of FOCUS Example Dataset Z + Short demo of the multistart method
  • Performance benefit by using compiled model definitions in mkin
  • +
  • + Example evaluation of FOCUS Example Dataset Z +
  • Calculation of time weighted average concentrations with mkin
  • @@ -58,7 +61,10 @@ observed data together with the solution of the fitted model.">< Example evaluation of NAFTA SOP Attachment examples
  • - Some benchmark timings + Benchmark timings for mkin +
  • +
  • + Benchmark timings for saem.mmkin
  • @@ -91,50 +97,50 @@ observed data together with the solution of the fitted model.

    -
    # S3 method for mkinfit
    -plot(
    -  x,
    -  fit = x,
    -  obs_vars = names(fit$mkinmod$map),
    -  xlab = "Time",
    -  ylab = "Residue",
    -  xlim = range(fit$data$time),
    -  ylim = "default",
    -  col_obs = 1:length(obs_vars),
    -  pch_obs = col_obs,
    -  lty_obs = rep(1, length(obs_vars)),
    -  add = FALSE,
    -  legend = !add,
    -  show_residuals = FALSE,
    -  show_errplot = FALSE,
    -  maxabs = "auto",
    -  sep_obs = FALSE,
    -  rel.height.middle = 0.9,
    -  row_layout = FALSE,
    -  lpos = "topright",
    -  inset = c(0.05, 0.05),
    -  show_errmin = FALSE,
    -  errmin_digits = 3,
    -  frame = TRUE,
    -  ...
    -)
    -
    -plot_sep(
    -  fit,
    -  show_errmin = TRUE,
    -  show_residuals = ifelse(identical(fit$err_mod, "const"), TRUE, "standardized"),
    -  ...
    -)
    -
    -plot_res(
    -  fit,
    -  sep_obs = FALSE,
    -  show_errmin = sep_obs,
    -  standardized = ifelse(identical(fit$err_mod, "const"), FALSE, TRUE),
    -  ...
    -)
    -
    -plot_err(fit, sep_obs = FALSE, show_errmin = sep_obs, ...)
    +
    # S3 method for mkinfit
    +plot(
    +  x,
    +  fit = x,
    +  obs_vars = names(fit$mkinmod$map),
    +  xlab = "Time",
    +  ylab = "Residue",
    +  xlim = range(fit$data$time),
    +  ylim = "default",
    +  col_obs = 1:length(obs_vars),
    +  pch_obs = col_obs,
    +  lty_obs = rep(1, length(obs_vars)),
    +  add = FALSE,
    +  legend = !add,
    +  show_residuals = FALSE,
    +  show_errplot = FALSE,
    +  maxabs = "auto",
    +  sep_obs = FALSE,
    +  rel.height.middle = 0.9,
    +  row_layout = FALSE,
    +  lpos = "topright",
    +  inset = c(0.05, 0.05),
    +  show_errmin = FALSE,
    +  errmin_digits = 3,
    +  frame = TRUE,
    +  ...
    +)
    +
    +plot_sep(
    +  fit,
    +  show_errmin = TRUE,
    +  show_residuals = ifelse(identical(fit$err_mod, "const"), TRUE, "standardized"),
    +  ...
    +)
    +
    +plot_res(
    +  fit,
    +  sep_obs = FALSE,
    +  show_errmin = sep_obs,
    +  standardized = ifelse(identical(fit$err_mod, "const"), FALSE, TRUE),
    +  ...
    +)
    +
    +plot_err(fit, sep_obs = FALSE, show_errmin = sep_obs, ...)
    @@ -142,32 +148,56 @@ observed data together with the solution of the fitted model.

    x

    Alias for fit introduced for compatibility with the generic S3 method.

    + +
    fit

    An object of class mkinfit.

    + +
    obs_vars

    A character vector of names of the observed variables for which the data and the model should be plotted. Defauls to all observed variables in the model.

    + +
    xlab

    Label for the x axis.

    + +
    ylab

    Label for the y axis.

    + +
    xlim

    Plot range in x direction.

    + +
    ylim

    Plot range in y direction. If given as a list, plot ranges for the different plot rows can be given for row layout.

    + +
    col_obs

    Colors used for plotting the observed data and the corresponding model prediction lines.

    + +
    pch_obs

    Symbols to be used for plotting the data.

    + +
    lty_obs

    Line types to be used for the model predictions.

    + +
    add

    Should the plot be added to an existing plot?

    + +
    legend

    Should a legend be added to the plot?

    + +
    show_residuals

    Should residuals be shown? If only one plot of the fits is shown, the residual plot is in the lower third of the plot. @@ -175,47 +205,74 @@ Otherwise, i.e. if "sep_obs" is given, the residual plots will be located to the right of the plots of the fitted curves. If this is set to 'standardized', a plot of the residuals divided by the standard deviation given by the fitted error model will be shown.

    + +
    show_errplot

    Should squared residuals and the error model be shown? If only one plot of the fits is shown, this plot is in the lower third of the plot. Otherwise, i.e. if "sep_obs" is given, the residual plots will be located to the right of the plots of the fitted curves.

    + +
    maxabs

    Maximum absolute value of the residuals. This is used for the scaling of the y axis and defaults to "auto".

    + +
    sep_obs

    Should the observed variables be shown in separate subplots? If yes, residual plots requested by "show_residuals" will be shown next to, not below the plot of the fits.

    + +
    rel.height.middle

    The relative height of the middle plot, if more than two rows of plots are shown.

    + +
    row_layout

    Should we use a row layout where the residual plot or the error model plot is shown to the right?

    + +
    lpos

    Position(s) of the legend(s). Passed to legend as the first argument. If not length one, this should be of the same length as the obs_var argument.

    + +
    inset

    Passed to legend if applicable.

    + +
    show_errmin

    Should the FOCUS chi2 error value be shown in the upper margin of the plot?

    + +
    errmin_digits

    The number of significant digits for rounding the FOCUS chi2 error percentage.

    + +
    frame

    Should a frame be drawn around the plots?

    + +
    ...

    Further arguments passed to plot.

    + +
    standardized

    When calling 'plot_res', should the residuals be standardized in the residual plot?

    +

    Value

    -

    The function is called for its side effect.

    + + +

    The function is called for its side effect.

    Details

    @@ -230,41 +287,41 @@ latex is being used for the formatting of the chi2 error level, if

    Examples

    -
    
    -# One parent compound, one metabolite, both single first order, path from
    -# parent to sink included
    -# \dontrun{
    -SFO_SFO <- mkinmod(parent = mkinsub("SFO", "m1", full = "Parent"),
    -                   m1 = mkinsub("SFO", full = "Metabolite M1" ))
    +    
    
    +# One parent compound, one metabolite, both single first order, path from
    +# parent to sink included
    +# \dontrun{
    +SFO_SFO <- mkinmod(parent = mkinsub("SFO", "m1", full = "Parent"),
    +                   m1 = mkinsub("SFO", full = "Metabolite M1" ))
     #> Temporary DLL for differentials generated and loaded
    -fit <- mkinfit(SFO_SFO, FOCUS_2006_D, quiet = TRUE)
    +fit <- mkinfit(SFO_SFO, FOCUS_2006_D, quiet = TRUE)
     #> Warning: Observations with value of zero were removed from the data
    -fit <- mkinfit(SFO_SFO, FOCUS_2006_D, quiet = TRUE, error_model = "tc")
    +fit <- mkinfit(SFO_SFO, FOCUS_2006_D, quiet = TRUE, error_model = "tc")
     #> Warning: Observations with value of zero were removed from the data
    -plot(fit)
    +plot(fit)
     
    -plot_res(fit)
    +plot_res(fit)
     
    -plot_res(fit, standardized = FALSE)
    +plot_res(fit, standardized = FALSE)
     
    -plot_err(fit)
    +plot_err(fit)
     
    -
    -# Show the observed variables separately, with residuals
    -plot(fit, sep_obs = TRUE, show_residuals = TRUE, lpos = c("topright", "bottomright"),
    -     show_errmin = TRUE)
    +
    +# Show the observed variables separately, with residuals
    +plot(fit, sep_obs = TRUE, show_residuals = TRUE, lpos = c("topright", "bottomright"),
    +     show_errmin = TRUE)
     
    -
    -# The same can be obtained with less typing, using the convenience function plot_sep
    -plot_sep(fit, lpos = c("topright", "bottomright"))
    +
    +# The same can be obtained with less typing, using the convenience function plot_sep
    +plot_sep(fit, lpos = c("topright", "bottomright"))
     
    -
    -# Show the observed variables separately, with the error model
    -plot(fit, sep_obs = TRUE, show_errplot = TRUE, lpos = c("topright", "bottomright"),
    -     show_errmin = TRUE)
    +
    +# Show the observed variables separately, with the error model
    +plot(fit, sep_obs = TRUE, show_errplot = TRUE, lpos = c("topright", "bottomright"),
    +     show_errmin = TRUE)
     
    -# }
    -
    +# }
    +
     
    @@ -279,7 +336,7 @@ latex is being used for the formatting of the chi2 error level, if
    -

    Site built with pkgdown 2.0.3.

    +

    Site built with pkgdown 2.0.6.

    diff --git a/docs/reference/plot.mmkin-2.png b/docs/reference/plot.mmkin-2.png index f5768c40..7af84edf 100644 Binary files a/docs/reference/plot.mmkin-2.png and b/docs/reference/plot.mmkin-2.png differ diff --git a/docs/reference/plot.mmkin-3.png b/docs/reference/plot.mmkin-3.png index c3f77d3d..56bfac50 100644 Binary files a/docs/reference/plot.mmkin-3.png and b/docs/reference/plot.mmkin-3.png differ diff --git a/docs/reference/plot.mmkin-4.png b/docs/reference/plot.mmkin-4.png index 29439156..5da05f40 100644 Binary files a/docs/reference/plot.mmkin-4.png and b/docs/reference/plot.mmkin-4.png differ diff --git a/docs/reference/plot.mmkin-5.png b/docs/reference/plot.mmkin-5.png index 89a111b0..3ec224f4 100644 Binary files a/docs/reference/plot.mmkin-5.png and b/docs/reference/plot.mmkin-5.png differ diff --git a/docs/reference/plot.mmkin.html b/docs/reference/plot.mmkin.html index 3dd0203b..30d0406e 100644 --- a/docs/reference/plot.mmkin.html +++ b/docs/reference/plot.mmkin.html @@ -21,7 +21,7 @@ the fit of at least one model to the same dataset is shown."> mkin - 1.1.0 + 1.2.0 @@ -48,11 +48,14 @@ the fit of at least one model to the same dataset is shown.">Example evaluations of dimethenamid data from 2018 with nonlinear mixed-effects models
  • - Example evaluation of FOCUS Example Dataset Z + Short demo of the multistart method
  • Performance benefit by using compiled model definitions in mkin
  • +
  • + Example evaluation of FOCUS Example Dataset Z +
  • Calculation of time weighted average concentrations with mkin
  • @@ -60,7 +63,10 @@ the fit of at least one model to the same dataset is shown.">Example evaluation of NAFTA SOP Attachment examples
  • - Some benchmark timings + Benchmark timings for mkin +
  • +
  • + Benchmark timings for saem.mmkin
  • @@ -94,22 +100,22 @@ the fit of at least one model to the same dataset is shown.

    -
    # S3 method for mmkin
    -plot(
    -  x,
    -  main = "auto",
    -  legends = 1,
    -  resplot = c("time", "errmod"),
    -  ylab = "Residue",
    -  standardized = FALSE,
    -  show_errmin = TRUE,
    -  errmin_var = "All data",
    -  errmin_digits = 3,
    -  cex = 0.7,
    -  rel.height.middle = 0.9,
    -  ymax = "auto",
    -  ...
    -)
    +
    # S3 method for mmkin
    +plot(
    +  x,
    +  main = "auto",
    +  legends = 1,
    +  resplot = c("time", "errmod"),
    +  ylab = "Residue",
    +  standardized = FALSE,
    +  show_errmin = TRUE,
    +  errmin_var = "All data",
    +  errmin_digits = 3,
    +  cex = 0.7,
    +  rel.height.middle = 0.9,
    +  ymax = "auto",
    +  ...
    +)
    @@ -117,43 +123,70 @@ the fit of at least one model to the same dataset is shown.

    x

    An object of class mmkin, with either one row or one column.

    + +
    main

    The main title placed on the outer margin of the plot.

    + +
    legends

    An index for the fits for which legends should be shown.

    + +
    resplot

    Should the residuals plotted against time, using mkinresplot, or as squared residuals against predicted values, with the error model, using mkinerrplot.

    + +
    ylab

    Label for the y axis.

    + +
    standardized

    Should the residuals be standardized? This option is passed to mkinresplot, it only takes effect if resplot = "time".

    + +
    show_errmin

    Should the chi2 error level be shown on top of the plots to the left?

    + +
    errmin_var

    The variable for which the FOCUS chi2 error value should be shown.

    + +
    errmin_digits

    The number of significant digits for rounding the FOCUS chi2 error percentage.

    + +
    cex

    Passed to the plot functions and mtext.

    + +
    rel.height.middle

    The relative height of the middle plot, if more than two rows of plots are shown.

    + +
    ymax

    Maximum y axis value for plot.mkinfit.

    + +
    ...

    Further arguments passed to plot.mkinfit and mkinresplot.

    +

    Value

    -

    The function is called for its side effect.

    + + +

    The function is called for its side effect.

    Details

    @@ -167,32 +200,32 @@ latex is being used for the formatting of the chi2 error level.

    Examples

    -
    
    -  # \dontrun{
    -  # Only use one core not to offend CRAN checks
    -  fits <- mmkin(c("FOMC", "HS"),
    -                list("FOCUS B" = FOCUS_2006_B, "FOCUS C" = FOCUS_2006_C), # named list for titles
    -                cores = 1, quiet = TRUE, error_model = "tc")
    +    
    
    +  # \dontrun{
    +  # Only use one core not to offend CRAN checks
    +  fits <- mmkin(c("FOMC", "HS"),
    +                list("FOCUS B" = FOCUS_2006_B, "FOCUS C" = FOCUS_2006_C), # named list for titles
    +                cores = 1, quiet = TRUE, error_model = "tc")
     #> Warning: Optimisation did not converge:
     #> iteration limit reached without convergence (10)
    -  plot(fits[, "FOCUS C"])
    +  plot(fits[, "FOCUS C"])
     
    -  plot(fits["FOMC", ])
    +  plot(fits["FOMC", ])
     
    -  plot(fits["FOMC", ], show_errmin = FALSE)
    +  plot(fits["FOMC", ], show_errmin = FALSE)
     
    -
    -  # We can also plot a single fit, if we like the way plot.mmkin works, but then the plot
    -  # height should be smaller than the plot width (this is not possible for the html pages
    -  # generated by pkgdown, as far as I know).
    -  plot(fits["FOMC", "FOCUS C"]) # same as plot(fits[1, 2])
    +
    +  # We can also plot a single fit, if we like the way plot.mmkin works, but then the plot
    +  # height should be smaller than the plot width (this is not possible for the html pages
    +  # generated by pkgdown, as far as I know).
    +  plot(fits["FOMC", "FOCUS C"]) # same as plot(fits[1, 2])
     
    -
    -  # Show the error models
    -  plot(fits["FOMC", ], resplot = "errmod")
    +
    +  # Show the error models
    +  plot(fits["FOMC", ], resplot = "errmod")
     
    -  # }
    -
    +  # }
    +
     
    @@ -207,7 +240,7 @@ latex is being used for the formatting of the chi2 error level.

    -

    Site built with pkgdown 2.0.3.

    +

    Site built with pkgdown 2.0.6.

    diff --git a/docs/reference/plot.nafta.html b/docs/reference/plot.nafta.html index af65d8eb..a7939f90 100644 --- a/docs/reference/plot.nafta.html +++ b/docs/reference/plot.nafta.html @@ -18,7 +18,7 @@ function (SFO, then IORE, then DFOP)."> + + +
    +
    + + + +
    +
    + + +
    +

    This function imports one dataset from each sheet of a spreadsheet file. +These sheets are selected based on the contents of a sheet 'Datasets', with +a column called 'Dataset Number', containing numbers identifying the dataset +sheets to be read in. In the second column there must be a grouping +variable, which will often be named 'Soil'. Optionally, time normalization +factors can be given in columns named 'Temperature' and 'Moisture'.

    +
    + +
    +
    read_spreadsheet(
    +  path,
    +  valid_datasets = "all",
    +  parent_only = FALSE,
    +  normalize = TRUE
    +)
    +
    + +
    +

    Arguments

    +
    path
    +

    Absolute or relative path to the spreadsheet file

    + + +
    valid_datasets
    +

    Optional numeric index of the valid datasets, default is +to use all datasets

    + + +
    parent_only
    +

    Should only the parent data be used?

    + + +
    normalize
    +

    Should the time scale be normalized using temperature +and moisture normalisation factors in the sheet 'Datasets'?

    + +
    +
    +

    Details

    +

    There must be a sheet 'Compounds', with columns 'Name' and 'Acronym'. +The first row read after the header read in from this sheet is assumed +to contain name and acronym of the parent compound.

    +

    The dataset sheets should be named using the dataset numbers read in from +the 'Datasets' sheet, i.e. '1', '2', ... . In each dataset sheet, name +of the observed variable (e.g. the acronym of the parent compound or +one of its transformation products) should be in the first column, +the time values should be in the second colum, and the observed value +in the third column.

    +

    In case relevant covariate data are available, they should be given +in a sheet 'Covariates', containing one line for each value of the grouping +variable specified in 'Datasets'. These values should be in the first +column and the column must have the same name as the second column in +'Datasets'. Covariates will be read in from columns four and higher. +Their names should preferably not contain special characters like spaces, +so they can be easily used for specifying covariate models.

    +

    An similar data structure is defined as the R6 class mkindsg, but +is probably more complicated to use.

    +
    + +
    + +
    + + +
    + +
    +

    Site built with pkgdown 2.0.6.

    +
    + +
    + + + + + + + + diff --git a/docs/reference/reexports.html b/docs/reference/reexports.html index 4da7092a..24b9771e 100644 --- a/docs/reference/reexports.html +++ b/docs/reference/reexports.html @@ -28,7 +28,7 @@ intervals, nlme mkin - 1.1.0 + 1.2.0 @@ -55,11 +55,14 @@ intervals, nlme Example evaluations of dimethenamid data from 2018 with nonlinear mixed-effects models
  • - Example evaluation of FOCUS Example Dataset Z + Short demo of the multistart method
  • Performance benefit by using compiled model definitions in mkin
  • +
  • + Example evaluation of FOCUS Example Dataset Z +
  • Calculation of time weighted average concentrations with mkin
  • @@ -67,7 +70,10 @@ intervals, nlme Example evaluation of NAFTA SOP Attachment examples
  • - Some benchmark timings + Benchmark timings for mkin +
  • +
  • + Benchmark timings for saem.mmkin
  • @@ -120,7 +126,7 @@ below to see their documentation.

    -

    Site built with pkgdown 2.0.3.

    +

    Site built with pkgdown 2.0.6.

    diff --git a/docs/reference/residuals.mkinfit.html b/docs/reference/residuals.mkinfit.html index 7d9e50de..07395436 100644 --- a/docs/reference/residuals.mkinfit.html +++ b/docs/reference/residuals.mkinfit.html @@ -17,7 +17,7 @@ mkin - 1.1.0 + 1.2.0 @@ -44,11 +44,14 @@ Example evaluations of dimethenamid data from 2018 with nonlinear mixed-effects models
  • - Example evaluation of FOCUS Example Dataset Z + Short demo of the multistart method
  • Performance benefit by using compiled model definitions in mkin
  • +
  • + Example evaluation of FOCUS Example Dataset Z +
  • Calculation of time weighted average concentrations with mkin
  • @@ -56,7 +59,10 @@ Example evaluation of NAFTA SOP Attachment examples
  • - Some benchmark timings + Benchmark timings for mkin +
  • +
  • + Benchmark timings for saem.mmkin
  • @@ -87,28 +93,33 @@
    -
    # S3 method for mkinfit
    -residuals(object, standardized = FALSE, ...)
    +
    # S3 method for mkinfit
    +residuals(object, standardized = FALSE, ...)

    Arguments

    object

    A mkinfit object

    + +
    standardized

    Should the residuals be standardized by dividing by the standard deviation obtained from the fitted error model?

    + +
    ...

    Not used

    +

    Examples

    -
    f <- mkinfit("DFOP", FOCUS_2006_C, quiet = TRUE)
    -residuals(f)
    +    
    f <- mkinfit("DFOP", FOCUS_2006_C, quiet = TRUE)
    +residuals(f)
     #> [1]  0.09726374 -0.13912142 -0.15351210  0.73388322 -0.08657004 -0.93204702
     #> [7] -0.03269080  1.45347823 -0.88423697
    -residuals(f, standardized = TRUE)
    +residuals(f, standardized = TRUE)
     #> [1]  0.13969917 -0.19981904 -0.22048826  1.05407091 -0.12433989 -1.33869208
     #> [7] -0.04695355  2.08761977 -1.27002287
     
    @@ -125,7 +136,7 @@ standard deviation obtained from the fitted error model?

    -

    Site built with pkgdown 2.0.3.

    +

    Site built with pkgdown 2.0.6.

    diff --git a/docs/reference/saem-1.png b/docs/reference/saem-1.png index 08939d4f..9e310252 100644 Binary files a/docs/reference/saem-1.png and b/docs/reference/saem-1.png differ diff --git a/docs/reference/saem-2.png b/docs/reference/saem-2.png index b737db03..de1bcf57 100644 Binary files a/docs/reference/saem-2.png and b/docs/reference/saem-2.png differ diff --git a/docs/reference/saem-3.png b/docs/reference/saem-3.png index 08e0f544..de569ce0 100644 Binary files a/docs/reference/saem-3.png and b/docs/reference/saem-3.png differ diff --git a/docs/reference/saem-4.png b/docs/reference/saem-4.png index bb775c25..0f2ee3e7 100644 Binary files a/docs/reference/saem-4.png and b/docs/reference/saem-4.png differ diff --git a/docs/reference/saem.html b/docs/reference/saem.html index 1bc6308e..5e7e0861 100644 --- a/docs/reference/saem.html +++ b/docs/reference/saem.html @@ -19,7 +19,7 @@ Expectation Maximisation algorithm (SAEM)."> + + +
    +
    + + + +
    +
    + + +
    +

    This function automates replacing unquantified values in residue time and +depth series. For time series, the function performs part of the residue +processing proposed in the FOCUS kinetics guidance for parent compounds +and metabolites. For two-dimensional residue series over time and depth, +it automates the proposal of Boesten et al (2015).

    +
    + +
    +
    set_nd_nq(res_raw, lod, loq = NA, time_zero_presence = FALSE)
    +
    +set_nd_nq_focus(
    +  res_raw,
    +  lod,
    +  loq = NA,
    +  set_first_sample_nd = TRUE,
    +  first_sample_nd_value = 0,
    +  ignore_below_loq_after_first_nd = TRUE
    +)
    +
    + +
    +

    Arguments

    +
    res_raw
    +

    Character vector of a residue time series, or matrix of +residue values with rows representing depth profiles for a specific sampling +time, and columns representing time series of residues at the same depth. +Values below the limit of detection (lod) have to be coded as "nd", values +between the limit of detection and the limit of quantification, if any, have +to be coded as "nq". Samples not analysed have to be coded as "na". All +values that are not "na", "nd" or "nq" have to be coercible to numeric

    + + +
    lod
    +

    Limit of detection (numeric)

    + + +
    loq
    +

    Limit of quantification(numeric). Must be specified if the FOCUS rule to +stop after the first non-detection is to be applied

    + + +
    time_zero_presence
    +

    Do we assume that residues occur at time zero? +This only affects samples from the first sampling time that have been +reported as "nd" (not detected).

    + + +
    set_first_sample_nd
    +

    Should the first sample be set to "first_sample_nd_value" +in case it is a non-detection?

    + + +
    first_sample_nd_value
    +

    Value to be used for the first sample if it is a non-detection

    + + +
    ignore_below_loq_after_first_nd
    +

    Should we ignore values below the LOQ after the first +non-detection that occurs after the quantified values?

    + +
    +
    +

    Value

    + + +

    A numeric vector, if a vector was supplied, or a numeric matrix otherwise

    +
    +
    +

    Functions

    + +
    • set_nd_nq_focus(): Set non-detects in residue time series according to FOCUS rules

    • +
    +
    +

    References

    +

    Boesten, J. J. T. I., van der Linden, A. M. A., Beltman, W. H. +J. and Pol, J. W. (2015). Leaching of plant protection products and their +transformation products; Proposals for improving the assessment of leaching +to groundwater in the Netherlands — Version 2. Alterra report 2630, Alterra +Wageningen UR (University & Research centre)

    +

    FOCUS (2014) Generic Guidance for Estimating Persistence and Degradation +Kinetics from Environmental Fate Studies on Pesticides in EU Registration, Version 1.1, +18 December 2014, p. 251

    +
    + +
    +

    Examples

    +
    # FOCUS (2014) p. 75/76 and 131/132
    +parent_1 <- c(.12, .09, .05, .03, "nd", "nd", "nd", "nd", "nd", "nd")
    +set_nd_nq(parent_1, 0.02)
    +#>  [1] 0.12 0.09 0.05 0.03 0.01   NA   NA   NA   NA   NA
    +parent_2 <- c(.12, .09, .05, .03, "nd", "nd", .03, "nd", "nd", "nd")
    +set_nd_nq(parent_2, 0.02)
    +#>  [1] 0.12 0.09 0.05 0.03 0.01 0.01 0.03 0.01   NA   NA
    +set_nd_nq_focus(parent_2, 0.02, loq = 0.05)
    +#>  [1] 0.12 0.09 0.05 0.03 0.01   NA   NA   NA   NA   NA
    +parent_3 <- c(.12, .09, .05, .03, "nd", "nd", .06, "nd", "nd", "nd")
    +set_nd_nq(parent_3, 0.02)
    +#>  [1] 0.12 0.09 0.05 0.03 0.01 0.01 0.06 0.01   NA   NA
    +set_nd_nq_focus(parent_3, 0.02, loq = 0.05)
    +#>  [1] 0.12 0.09 0.05 0.03 0.01 0.01 0.06 0.01   NA   NA
    +metabolite <- c("nd", "nd", "nd", 0.03, 0.06, 0.10, 0.11, 0.10, 0.09, 0.05, 0.03, "nd", "nd")
    +set_nd_nq(metabolite, 0.02)
    +#>  [1]   NA   NA 0.01 0.03 0.06 0.10 0.11 0.10 0.09 0.05 0.03 0.01   NA
    +set_nd_nq_focus(metabolite, 0.02, 0.05)
    +#>  [1] 0.00   NA 0.01 0.03 0.06 0.10 0.11 0.10 0.09 0.05 0.03 0.01   NA
    +#
    +# Boesten et al. (2015), p. 57/58
    +table_8 <- matrix(
    +  c(10, 10, rep("nd", 4),
    +    10, 10, rep("nq", 2), rep("nd", 2),
    +    10, 10, 10, "nq", "nd", "nd",
    +    "nq", 10, "nq", rep("nd", 3),
    +    "nd", "nq", "nq", rep("nd", 3),
    +    rep("nd", 6), rep("nd", 6)),
    +  ncol = 6, byrow = TRUE)
    +set_nd_nq(table_8, 0.5, 1.5, time_zero_presence = TRUE)
    +#>       [,1]  [,2]  [,3] [,4] [,5] [,6]
    +#> [1,] 10.00 10.00  0.25 0.25   NA   NA
    +#> [2,] 10.00 10.00  1.00 1.00 0.25   NA
    +#> [3,] 10.00 10.00 10.00 1.00 0.25   NA
    +#> [4,]  1.00 10.00  1.00 0.25   NA   NA
    +#> [5,]  0.25  1.00  1.00 0.25   NA   NA
    +#> [6,]    NA  0.25  0.25   NA   NA   NA
    +#> [7,]    NA    NA    NA   NA   NA   NA
    +table_10 <- matrix(
    +  c(10, 10, rep("nd", 4),
    +    10, 10, rep("nd", 4),
    +    10, 10, 10, rep("nd", 3),
    +    "nd", 10, rep("nd", 4),
    +    rep("nd", 18)),
    +  ncol = 6, byrow = TRUE)
    +set_nd_nq(table_10, 0.5, time_zero_presence = TRUE)
    +#>       [,1]  [,2]  [,3] [,4] [,5] [,6]
    +#> [1,] 10.00 10.00  0.25   NA   NA   NA
    +#> [2,] 10.00 10.00  0.25   NA   NA   NA
    +#> [3,] 10.00 10.00 10.00 0.25   NA   NA
    +#> [4,]  0.25 10.00  0.25   NA   NA   NA
    +#> [5,]    NA  0.25    NA   NA   NA   NA
    +#> [6,]    NA    NA    NA   NA   NA   NA
    +#> [7,]    NA    NA    NA   NA   NA   NA
    +
    +
    +
    + +
    + + +
    + +
    +

    Site built with pkgdown 2.0.6.

    +
    + +
    + + + + + + + + diff --git a/docs/reference/sigma_twocomp.html b/docs/reference/sigma_twocomp.html index 23102f17..c1db0d30 100644 --- a/docs/reference/sigma_twocomp.html +++ b/docs/reference/sigma_twocomp.html @@ -18,7 +18,7 @@ dependence of the measured value \(y\):"> + + +
    +
    + + + +
    +
    + + +
    +

    Method to get status information for fit array objects

    +
    + +
    +
    status(object, ...)
    +
    +# S3 method for mmkin
    +status(object, ...)
    +
    +# S3 method for status.mmkin
    +print(x, ...)
    +
    +# S3 method for mhmkin
    +status(object, ...)
    +
    +# S3 method for status.mhmkin
    +print(x, ...)
    +
    + +
    +

    Arguments

    +
    object
    +

    The object to investigate

    + + +
    ...
    +

    For potential future extensions

    + + +
    x
    +

    The object to be printed

    + +
    +
    +

    Value

    + + +

    An object with the same dimensions as the fit array +suitable printing method.

    +
    + +
    +

    Examples

    +
    # \dontrun{
    +fits <- mmkin(
    +  c("SFO", "FOMC"),
    +  list("FOCUS A" = FOCUS_2006_A,
    +       "FOCUS B" = FOCUS_2006_C),
    +  quiet = TRUE)
    +status(fits)
    +#>       dataset
    +#> model  FOCUS A FOCUS B
    +#>   SFO  OK      OK     
    +#>   FOMC OK      OK     
    +#> 
    +#> OK: No warnings
    +# }
    +
    +
    +
    + +
    + + +
    + +
    +

    Site built with pkgdown 2.0.6.

    +
    + +
    + + + + + + + + diff --git a/docs/reference/summary.mkinfit.html b/docs/reference/summary.mkinfit.html index 17ecdfe4..0bb7f424 100644 --- a/docs/reference/summary.mkinfit.html +++ b/docs/reference/summary.mkinfit.html @@ -21,7 +21,7 @@ values.">Summary method for class "mmkin" — summary.mmkin • mkinWrap the output of a summary function in tex listing environment — tex_listing • mkin + + +
    +
    + + + +
    +
    + + +
    +

    This function can be used in a R markdown code chunk with the chunk +option results = "asis".

    +
    + +
    +
    tex_listing(object, caption = NULL, label = NULL, clearpage = TRUE)
    +
    + +
    +

    Arguments

    +
    object
    +

    The object for which the summary is to be listed

    + + +
    caption
    +

    An optional caption

    + + +
    label
    +

    An optional label

    + + +
    clearpage
    +

    Should a new page be started after the listing?

    + +
    + +
    + +
    + + +
    + +
    +

    Site built with pkgdown 2.0.6.

    +
    + +
    + + + + + + + + diff --git a/docs/reference/transform_odeparms.html b/docs/reference/transform_odeparms.html index 2da09efe..66e94941 100644 --- a/docs/reference/transform_odeparms.html +++ b/docs/reference/transform_odeparms.html @@ -22,7 +22,7 @@ the ilr transformation is used.">