From 92bd33824bde6b6b21bfc7e30953092a74d3cce5 Mon Sep 17 00:00:00 2001 From: Johannes Ranke Date: Thu, 7 May 2020 22:13:33 +0200 Subject: Another overhaul of analytical solutions Still in preparation for analytical solutions of coupled models --- DESCRIPTION | 4 +- NEWS.md | 2 + R/create_deg_func.R | 54 +++++++ R/logistic.solution.R | 59 ------- R/mkinfit.R | 2 +- R/mkinmod.R | 43 +---- R/mkinpredict.R | 22 +-- R/nlme.R | 6 +- R/parent_solutions.R | 4 +- build.log | 2 +- check.log | 2 +- docs/404.html | 2 +- docs/articles/index.html | 2 +- docs/authors.html | 2 +- docs/index.html | 2 +- docs/news/index.html | 6 +- docs/pkgdown.yml | 2 +- docs/reference/DFOP.solution.html | 2 +- docs/reference/FOMC.solution.html | 2 +- docs/reference/HS.solution.html | 33 +++- docs/reference/SFO.solution.html | 2 +- docs/reference/SFORB.solution.html | 22 ++- docs/reference/create_deg_func.html | 198 ++++++++++++++++++++++++ docs/reference/index.html | 4 +- docs/reference/logistic.solution.html | 63 ++------ docs/reference/mkinmod.html | 16 +- docs/reference/mkinpredict.html | 48 ++++-- docs/reference/nlme-1.png | Bin 70555 -> 71651 bytes docs/reference/nlme.html | 75 ++++----- docs/sitemap.xml | 3 + man/HS.solution.Rd | 23 +++ man/SFORB.solution.Rd | 16 ++ man/create_deg_func.Rd | 26 ++++ man/logistic.solution.Rd | 52 +------ man/mkinmod.Rd | 2 +- man/mkinpredict.Rd | 22 +-- man/nlme.Rd | 6 +- test.log | 22 +-- tests/testthat/FOCUS_2006_D.csf | 2 +- tests/testthat/SFO_SFO_printed.txt | 6 +- tests/testthat/summary_DFOP_FOCUS_C.txt | 5 + tests/testthat/summary_DFOP_FOCUS_D_deSolve.txt | 70 +++++---- tests/testthat/summary_DFOP_FOCUS_D_eigen.txt | 60 +++---- tests/testthat/test_SFORB.R | 8 +- tests/testthat/test_nlme.R | 12 +- 45 files changed, 626 insertions(+), 390 deletions(-) create mode 100644 R/create_deg_func.R delete mode 100644 R/logistic.solution.R create mode 100644 docs/reference/create_deg_func.html create mode 100644 man/create_deg_func.Rd diff --git a/DESCRIPTION b/DESCRIPTION index 96f4637d..5f38d12c 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,8 +1,8 @@ Package: mkin Type: Package Title: Kinetic Evaluation of Chemical Degradation Data -Version: 0.9.49.11 -Date: 2020-05-20 +Version: 0.9.50 +Date: 2020-05-07 Authors@R: c(person("Johannes", "Ranke", role = c("aut", "cre", "cph"), email = "jranke@uni-bremen.de", comment = c(ORCID = "0000-0003-4371-6538")), diff --git a/NEWS.md b/NEWS.md index ba1daa87..2512f361 100644 --- a/NEWS.md +++ b/NEWS.md @@ -2,6 +2,8 @@ - Support SFORB with formation fractions +- 'mkinmod': Make 'use_of_ff' = "max" the default + # mkin 0.9.49.11 (2020-04-20) - Increase a test tolerance to make it pass on all CRAN check machines diff --git a/R/create_deg_func.R b/R/create_deg_func.R new file mode 100644 index 00000000..40efb3a3 --- /dev/null +++ b/R/create_deg_func.R @@ -0,0 +1,54 @@ +#' Create degradation functions for known analytical solutions +#' +#' @param spec List of model specifications as contained in mkinmod objects +#' @param use_of_ff Minimum or maximum use of formation fractions +#' @return Degradation function to be attached to mkinmod objects +#' @examples +#' +#' SFO_SFO <- mkinmod( +#' parent = mkinsub("SFO", "m1"), +#' m1 = mkinsub("SFO")) +#' fit <- mkinfit(SFO_SFO, FOCUS_2006_D, quiet = TRUE) + +create_deg_func <- function(spec, use_of_ff = c("min", "max")) { + + use_of_ff <- match.arg(use_of_ff) + + min_ff <- use_of_ff == "min" + + obs_vars <- names(spec) + + n <- character(0) + + parent <- obs_vars[1] + + n[1] <- paste0(parent, " = ", spec[[1]]$type, ".solution(outtimes, odeini['", parent, + if (spec[[1]]$type == "SFORB") "_free", "'], ", + switch(spec[[1]]$type, + SFO = paste0("k_", parent, if (min_ff) "_sink" else "", ")"), + FOMC = "alpha, beta)", + IORE = paste0("k__iore_", parent, if (min_ff) "_sink" else "", ", N_", parent, ")"), + DFOP = "k1, k2, g)", + SFORB = paste0("k_", parent, "_free_bound, k_", parent, "_bound_free, k_", parent, "_free", if (min_ff) "_sink" else "", ")"), + HS = "k1, k2, tb)", + logistic = "kmax, k0, r)" + ) + ) + + all_n <- paste(n, collapse = ",\n") + + f_body <- paste0("{\n", + "out <- with(as.list(odeparms), {\n", + "data.frame(\n", + "time = outtimes,\n", + all_n, "\n", + ")})\n", + "return(out)\n}\n" + ) + + deg_func <- function(odeini, odeparms, outtimes) {} + + body(deg_func) <- parse(text = f_body) + + return(deg_func) +} diff --git a/R/logistic.solution.R b/R/logistic.solution.R deleted file mode 100644 index d9db13d7..00000000 --- a/R/logistic.solution.R +++ /dev/null @@ -1,59 +0,0 @@ -#' Logistic kinetics -#' -#' Function describing exponential decline from a defined starting value, with -#' an increasing rate constant, supposedly caused by microbial growth -#' -#' @param t Time. -#' @param parent.0 Starting value for the response variable at time zero. -#' @param kmax Maximum rate constant. -#' @param k0 Minumum rate constant effective at time zero. -#' @param r Growth rate of the increase in the rate constant. -#' @return The value of the response variable at time \code{t}. -#' @note The solution of the logistic model reduces to the -#' \code{\link{SFO.solution}} if \code{k0} is equal to \code{kmax}. -#' @references FOCUS (2014) \dQuote{Generic guidance for Estimating Persistence -#' and Degradation Kinetics from Environmental Fate Studies on Pesticides in -#' EU Registration} Report of the FOCUS Work Group on Degradation Kinetics, -#' Version 1.1, 18 December 2014 -#' \url{http://esdac.jrc.ec.europa.eu/projects/degradation-kinetics} -#' @examples -#' -#' # Reproduce the plot on page 57 of FOCUS (2014) -#' plot(function(x) logistic.solution(x, 100, 0.08, 0.0001, 0.2), -#' from = 0, to = 100, ylim = c(0, 100), -#' xlab = "Time", ylab = "Residue") -#' plot(function(x) logistic.solution(x, 100, 0.08, 0.0001, 0.4), -#' from = 0, to = 100, add = TRUE, lty = 2, col = 2) -#' plot(function(x) logistic.solution(x, 100, 0.08, 0.0001, 0.8), -#' from = 0, to = 100, add = TRUE, lty = 3, col = 3) -#' plot(function(x) logistic.solution(x, 100, 0.08, 0.001, 0.2), -#' from = 0, to = 100, add = TRUE, lty = 4, col = 4) -#' plot(function(x) logistic.solution(x, 100, 0.08, 0.08, 0.2), -#' from = 0, to = 100, add = TRUE, lty = 5, col = 5) -#' legend("topright", inset = 0.05, -#' legend = paste0("k0 = ", c(0.0001, 0.0001, 0.0001, 0.001, 0.08), -#' ", r = ", c(0.2, 0.4, 0.8, 0.2, 0.2)), -#' lty = 1:5, col = 1:5) -#' -#' # Fit with synthetic data -#' logistic <- mkinmod(parent = mkinsub("logistic")) -#' -#' sampling_times = c(0, 1, 3, 7, 14, 28, 60, 90, 120) -#' parms_logistic <- c(kmax = 0.08, k0 = 0.0001, r = 0.2) -#' d_logistic <- mkinpredict(logistic, -#' parms_logistic, c(parent = 100), -#' sampling_times) -#' d_2_1 <- add_err(d_logistic, -#' sdfunc = function(x) sigma_twocomp(x, 0.5, 0.07), -#' n = 1, reps = 2, digits = 5, LOD = 0.1, seed = 123456)[[1]] -#' -#' m <- mkinfit("logistic", d_2_1, quiet = TRUE) -#' plot_sep(m) -#' summary(m)$bpar -#' endpoints(m)$distimes -#' -#' @export -logistic.solution <- function(t, parent.0, kmax, k0, r) -{ - parent = parent.0 * (kmax / (kmax - k0 + k0 * exp (r * t))) ^(kmax/r) -} diff --git a/R/mkinfit.R b/R/mkinfit.R index 2b7e71cb..54dd75c2 100644 --- a/R/mkinfit.R +++ b/R/mkinfit.R @@ -269,7 +269,7 @@ mkinfit <- function(mkinmod, observed, if (mkinmod[[1]] %in% parent_models_available) { speclist <- list(list(type = mkinmod, sink = TRUE)) names(speclist) <- presumed_parent_name - mkinmod <- mkinmod(speclist = speclist) + mkinmod <- mkinmod(speclist = speclist, use_of_ff = "min") } else { stop("Argument mkinmod must be of class mkinmod or a string containing one of\n ", paste(parent_models_available, collapse = ", ")) diff --git a/R/mkinmod.R b/R/mkinmod.R index f52baa4f..21551861 100644 --- a/R/mkinmod.R +++ b/R/mkinmod.R @@ -101,7 +101,7 @@ #' } #' #' @export mkinmod -mkinmod <- function(..., use_of_ff = "min", speclist = NULL, quiet = FALSE, verbose = FALSE) +mkinmod <- function(..., use_of_ff = "max", speclist = NULL, quiet = FALSE, verbose = FALSE) { if (is.null(speclist)) spec <- list(...) else spec <- speclist @@ -421,45 +421,8 @@ mkinmod <- function(..., use_of_ff = "min", speclist = NULL, quiet = FALSE, verb } # }}} - # Attach a degradation function if an analytical solution is available {{{ - parent_type = spec[[1]]$type - parent_name = names(spec)[[1]] - if (length(spec) == 1) { - odeparm_map <- switch(parent_type, - SFO = c( - k = if(use_of_ff == "min") paste("k", parent_name, "sink", sep = "_") - else paste("k", parent_name, sep = "_")), - FOMC = c(alpha = "alpha", beta = "beta"), - IORE = c( - k__iore = if(use_of_ff == "min") paste("k__iore", parent_name, "sink", sep = "_") - else paste("k__iore", parent_name, sep = "_"), - N = paste("N", parent_name, sep = "_")), - DFOP = c(k1 = "k1", k2 = "k2", g = "g"), - HS = c(k1 = "k1", k2 = "k2", tb = "tb"), - SFORB = c( - k_12 = paste("k", parent_name, "free_bound", sep = "_"), - k_21 = paste("k", parent_name, "bound_free", sep = "_"), - k_1output = paste("k", parent_name, "free_sink", sep = "_")), - logistic = c(kmax = "kmax", k0 = "k0", r = "r") - ) - odeparm_rev_map <- names(odeparm_map) - names(odeparm_rev_map) <- odeparm_map - - model$deg_func <- function(odeini, odeparms, outtimes) { - parent_func <- getFromNamespace(paste0(parent_type, ".solution"), "mkin") - odeparm_list <- as.list(odeparms) - names(odeparm_list) <- odeparm_rev_map[names(odeparm_list)] - - values <- do.call(parent_func, - args = c( - list(t = outtimes, parent_0 = odeini[1]), - odeparm_list)) - out <- data.frame(outtimes, values) - names(out) <- c("time", parent_name) - return(out) - } - } - # }}} + # Attach a degradation function if an analytical solution is available + model$deg_func <- create_deg_func(spec, use_of_ff) class(model) <- "mkinmod" return(model) diff --git a/R/mkinpredict.R b/R/mkinpredict.R index 0f8e83bb..df51dbe3 100644 --- a/R/mkinpredict.R +++ b/R/mkinpredict.R @@ -43,36 +43,36 @@ #' #' SFO <- mkinmod(degradinol = mkinsub("SFO")) #' # Compare solution types -#' mkinpredict(SFO, c(k_degradinol_sink = 0.3), c(degradinol = 100), 0:20, +#' mkinpredict(SFO, c(k_degradinol = 0.3), c(degradinol = 100), 0:20, #' solution_type = "analytical") -#' mkinpredict(SFO, c(k_degradinol_sink = 0.3), c(degradinol = 100), 0:20, +#' mkinpredict(SFO, c(k_degradinol = 0.3), c(degradinol = 100), 0:20, #' solution_type = "deSolve") -#' mkinpredict(SFO, c(k_degradinol_sink = 0.3), c(degradinol = 100), 0:20, +#' mkinpredict(SFO, c(k_degradinol = 0.3), c(degradinol = 100), 0:20, #' solution_type = "deSolve", use_compiled = FALSE) -#' mkinpredict(SFO, c(k_degradinol_sink = 0.3), c(degradinol = 100), 0:20, +#' mkinpredict(SFO, c(k_degradinol = 0.3), c(degradinol = 100), 0:20, #' solution_type = "eigen") #' #' # Compare integration methods to analytical solution -#' mkinpredict(SFO, c(k_degradinol_sink = 0.3), c(degradinol = 100), 0:20, +#' mkinpredict(SFO, c(k_degradinol = 0.3), c(degradinol = 100), 0:20, #' solution_type = "analytical")[21,] -#' mkinpredict(SFO, c(k_degradinol_sink = 0.3), c(degradinol = 100), 0:20, +#' mkinpredict(SFO, c(k_degradinol = 0.3), c(degradinol = 100), 0:20, #' method = "lsoda")[21,] -#' mkinpredict(SFO, c(k_degradinol_sink = 0.3), c(degradinol = 100), 0:20, +#' mkinpredict(SFO, c(k_degradinol = 0.3), c(degradinol = 100), 0:20, #' method = "ode45")[21,] -#' mkinpredict(SFO, c(k_degradinol_sink = 0.3), c(degradinol = 100), 0:20, +#' mkinpredict(SFO, c(k_degradinol = 0.3), c(degradinol = 100), 0:20, #' method = "rk4")[21,] #' # rk4 is not as precise here #' #' # The number of output times used to make a lot of difference until the #' # default for atol was adjusted -#' mkinpredict(SFO, c(k_degradinol_sink = 0.3), c(degradinol = 100), +#' mkinpredict(SFO, c(k_degradinol = 0.3), c(degradinol = 100), #' seq(0, 20, by = 0.1))[201,] -#' mkinpredict(SFO, c(k_degradinol_sink = 0.3), c(degradinol = 100), +#' mkinpredict(SFO, c(k_degradinol = 0.3), c(degradinol = 100), #' seq(0, 20, by = 0.01))[2001,] #' #' # Check compiled model versions - they are faster than the eigenvalue based solutions! #' SFO_SFO = mkinmod(parent = list(type = "SFO", to = "m1"), -#' m1 = list(type = "SFO")) +#' m1 = list(type = "SFO"), use_of_ff = "min") #' if(require(rbenchmark)) { #' benchmark( #' eigen = mkinpredict(SFO_SFO, c(k_parent_m1 = 0.05, k_parent_sink = 0.1, k_m1_sink = 0.01), diff --git a/R/nlme.R b/R/nlme.R index 60cd2ca1..fa69db3c 100644 --- a/R/nlme.R +++ b/R/nlme.R @@ -13,15 +13,15 @@ #' 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_sink = 0.1), +#' 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_sink = 0.05), +#' 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_sink = 0.02), +#' c(k_parent = 0.02), #' c(parent = 103), sampling_times) #' d_SFO_3_long <- mkin_wide_to_long(d_SFO_3, time = "time") #' diff --git a/R/parent_solutions.R b/R/parent_solutions.R index c33d6d13..e02bcda7 100644 --- a/R/parent_solutions.R +++ b/R/parent_solutions.R @@ -136,7 +136,7 @@ DFOP.solution <- function(t, parent_0, k1, k2, g) #' between them. #' #' @family parent solutions -#' @inherit HS.solution +#' @inherit DFOP.solution #' @param tb Break point. Before this time, exponential decline according to #' \code{k1} is calculated, after this time, exponential decline proceeds #' according to \code{k2}. @@ -161,7 +161,7 @@ HS.solution <- function(t, parent_0, k1, k2, tb) #' and no substance in the bound fraction. #' #' @family parent solutions -#' @inherit HS.solution +#' @inherit SFO.solution #' @param k_12 Kinetic constant describing transfer from free to bound. #' @param k_21 Kinetic constant describing transfer from bound to free. #' @param k_1output Kinetic constant describing degradation of the free diff --git a/build.log b/build.log index e1e92209..b3df3235 100644 --- a/build.log +++ b/build.log @@ -5,5 +5,5 @@ * creating vignettes ... OK * checking for LF line-endings in source and make files and shell scripts * checking for empty or unneeded directories -* building ‘mkin_0.9.49.11.tar.gz’ +* building ‘mkin_0.9.50.tar.gz’ diff --git a/check.log b/check.log index ddf3c6f4..cc24b711 100644 --- a/check.log +++ b/check.log @@ -5,7 +5,7 @@ * using options ‘--no-tests --as-cran’ * checking for file ‘mkin/DESCRIPTION’ ... OK * checking extension type ... Package -* this is package ‘mkin’ version ‘0.9.49.11’ +* this is package ‘mkin’ version ‘0.9.50’ * package encoding: UTF-8 * checking CRAN incoming feasibility ... Note_to_CRAN_maintainers Maintainer: ‘Johannes Ranke ’ diff --git a/docs/404.html b/docs/404.html index 12d9b275..c6da911d 100644 --- a/docs/404.html +++ b/docs/404.html @@ -71,7 +71,7 @@ mkin - 0.9.49.11 + 0.9.50 diff --git a/docs/articles/index.html b/docs/articles/index.html index 40f16c15..7091d4c9 100644 --- a/docs/articles/index.html +++ b/docs/articles/index.html @@ -71,7 +71,7 @@ mkin - 0.9.49.11 + 0.9.50 diff --git a/docs/authors.html b/docs/authors.html index 9bba91ac..bc170e49 100644 --- a/docs/authors.html +++ b/docs/authors.html @@ -71,7 +71,7 @@ mkin - 0.9.49.11 + 0.9.50 diff --git a/docs/index.html b/docs/index.html index 546f9143..5c4a0a9b 100644 --- a/docs/index.html +++ b/docs/index.html @@ -37,7 +37,7 @@ mkin - 0.9.49.11 + 0.9.50 diff --git a/docs/news/index.html b/docs/news/index.html index 07f733dd..bc69fd2d 100644 --- a/docs/news/index.html +++ b/docs/news/index.html @@ -71,7 +71,7 @@ mkin - 0.9.49.11 + 0.9.50 @@ -143,7 +143,9 @@ mkin 0.9.50.1 (unreleased) Unreleased
diff --git a/docs/pkgdown.yml b/docs/pkgdown.yml index 6489b012..32bcaa05 100644 --- a/docs/pkgdown.yml +++ b/docs/pkgdown.yml @@ -10,7 +10,7 @@ articles: NAFTA_examples: web_only/NAFTA_examples.html benchmarks: web_only/benchmarks.html compiled_models: web_only/compiled_models.html -last_built: 2020-05-07T07:07Z +last_built: 2020-05-07T20:11Z urls: reference: https://pkgdown.jrwb.de/mkin/reference article: https://pkgdown.jrwb.de/mkin/articles diff --git a/docs/reference/DFOP.solution.html b/docs/reference/DFOP.solution.html index 46e0cc91..84e33f9e 100644 --- a/docs/reference/DFOP.solution.html +++ b/docs/reference/DFOP.solution.html @@ -73,7 +73,7 @@ two exponential decline functions." /> mkin - 0.9.49.11 + 0.9.50
diff --git a/docs/reference/FOMC.solution.html b/docs/reference/FOMC.solution.html index 6c1f5229..369398d5 100644 --- a/docs/reference/FOMC.solution.html +++ b/docs/reference/FOMC.solution.html @@ -73,7 +73,7 @@ a decreasing rate constant." /> mkin - 0.9.49.11 + 0.9.50 diff --git a/docs/reference/HS.solution.html b/docs/reference/HS.solution.html index ad33d948..2684ee60 100644 --- a/docs/reference/HS.solution.html +++ b/docs/reference/HS.solution.html @@ -73,7 +73,7 @@ between them." /> mkin - 0.9.49.11 + 0.9.50 @@ -151,6 +151,22 @@ between them.

Arguments

+ + + + + + + + + + + + + + + +
t

Time.

parent_0

Starting value for the response variable at time zero.

k1

First kinetic constant.

k2

Second kinetic constant.

tb

Break point. Before this time, exponential decline according to @@ -159,6 +175,21 @@ according to k2.

+

Value

+ +

The value of the response variable at time t.

+

References

+ +

FOCUS (2006) “Guidance Document on Estimating Persistence + and Degradation Kinetics from Environmental Fate Studies on Pesticides in + EU Registration” Report of the FOCUS Work Group on Degradation Kinetics, + EC Document Reference Sanco/10058/2005 version 2.0, 434 pp, + http://esdac.jrc.ec.europa.eu/projects/degradation-kinetics +FOCUS (2014) “Generic guidance for Estimating Persistence + and Degradation Kinetics from Environmental Fate Studies on Pesticides in + EU Registration” Report of the FOCUS Work Group on Degradation Kinetics, + Version 1.1, 18 December 2014 + http://esdac.jrc.ec.europa.eu/projects/degradation-kinetics

See also

Other parent solutions: diff --git a/docs/reference/SFO.solution.html b/docs/reference/SFO.solution.html index 93da04eb..9664deb3 100644 --- a/docs/reference/SFO.solution.html +++ b/docs/reference/SFO.solution.html @@ -72,7 +72,7 @@ mkin - 0.9.49.11 + 0.9.50

diff --git a/docs/reference/SFORB.solution.html b/docs/reference/SFORB.solution.html index c9f1b471..504f209f 100644 --- a/docs/reference/SFORB.solution.html +++ b/docs/reference/SFORB.solution.html @@ -76,7 +76,7 @@ and no substance in the bound fraction." /> mkin - 0.9.49.11 + 0.9.50 @@ -157,6 +157,14 @@ and no substance in the bound fraction.

Arguments

+ + + + + + + + @@ -176,6 +184,18 @@ fraction.

The value of the response variable, which is the sum of free and bound fractions at time t.

+

References

+ +

FOCUS (2006) “Guidance Document on Estimating Persistence + and Degradation Kinetics from Environmental Fate Studies on Pesticides in + EU Registration” Report of the FOCUS Work Group on Degradation Kinetics, + EC Document Reference Sanco/10058/2005 version 2.0, 434 pp, + http://esdac.jrc.ec.europa.eu/projects/degradation-kinetics +FOCUS (2014) “Generic guidance for Estimating Persistence + and Degradation Kinetics from Environmental Fate Studies on Pesticides in + EU Registration” Report of the FOCUS Work Group on Degradation Kinetics, + Version 1.1, 18 December 2014 + http://esdac.jrc.ec.europa.eu/projects/degradation-kinetics

See also

Other parent solutions: diff --git a/docs/reference/create_deg_func.html b/docs/reference/create_deg_func.html new file mode 100644 index 00000000..e14857cc --- /dev/null +++ b/docs/reference/create_deg_func.html @@ -0,0 +1,198 @@ + + + + + + + + +Create degradation functions for known analytical solutions — create_deg_func • mkin + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +

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

Create degradation functions for known analytical solutions

+
+ +
create_deg_func(spec, use_of_ff = c("min", "max"))
+ +

Arguments

+
t

Time.

parent_0

Starting value for the response variable at time zero.

k_12

Kinetic constant describing transfer from free to bound.

+ + + + + + + + + +
spec

List of model specifications as contained in mkinmod objects

use_of_ff

Minimum or maximum use of formation fractions

+ +

Value

+ +

Degradation function to be attached to mkinmod objects

+ +

Examples

+
+SFO_SFO <- mkinmod( + parent = mkinsub("SFO", "m1"), + m1 = mkinsub("SFO"))
#> Successfully compiled differential equation model from auto-generated C code.
fit <- mkinfit(SFO_SFO, FOCUS_2006_D, quiet = TRUE)
#> Warning: Observations with value of zero were removed from the data
+ + + + + +
+ + +
+

Site built with pkgdown 1.5.1.

+
+ +
+ + + + + + + + + diff --git a/docs/reference/index.html b/docs/reference/index.html index f77881fe..75820166 100644 --- a/docs/reference/index.html +++ b/docs/reference/index.html @@ -71,7 +71,7 @@ mkin - 0.9.49.11 + 0.9.50 @@ -609,7 +609,7 @@ kinetic models fitted with mkinfit

-

logistic.solution() logistic.solution()

+

logistic.solution()

Logistic kinetics

diff --git a/docs/reference/logistic.solution.html b/docs/reference/logistic.solution.html index 9697d420..b0ec77b1 100644 --- a/docs/reference/logistic.solution.html +++ b/docs/reference/logistic.solution.html @@ -41,8 +41,6 @@ @@ -75,7 +73,7 @@ an increasing rate constant, supposedly caused by microbial growth" /> mkin - 0.9.49.11 + 0.9.50 @@ -139,20 +137,16 @@ an increasing rate constant, supposedly caused by microbial growth" />

Function describing exponential decline from a defined starting value, with -an increasing rate constant, supposedly caused by microbial growth

-

Function describing exponential decline from a defined starting value, with an increasing rate constant, supposedly caused by microbial growth

-
logistic.solution(t, parent_0, kmax, k0, r)
-
-logistic.solution(t, parent_0, kmax, k0, r)
+
logistic.solution(t, parent_0, kmax, k0, r)

Arguments

@@ -177,10 +171,6 @@ an increasing rate constant, supposedly caused by microbial growth

- - - -
r

Growth rate of the increase in the rate constant.

parent.0

Starting value for the response variable at time zero.

Value

@@ -189,12 +179,15 @@ an increasing rate constant, supposedly caused by microbial growth

Note

The solution of the logistic model reduces to the - SFO.solution if k0 is equal to kmax.

-

The solution of the logistic model reduces to the SFO.solution if k0 is equal to kmax.

References

-

FOCUS (2014) “Generic guidance for Estimating Persistence +

FOCUS (2006) “Guidance Document on Estimating Persistence + and Degradation Kinetics from Environmental Fate Studies on Pesticides in + EU Registration” Report of the FOCUS Work Group on Degradation Kinetics, + EC Document Reference Sanco/10058/2005 version 2.0, 434 pp, + http://esdac.jrc.ec.europa.eu/projects/degradation-kinetics +FOCUS (2014) “Generic guidance for Estimating Persistence and Degradation Kinetics from Environmental Fate Studies on Pesticides in EU Registration” Report of the FOCUS Work Group on Degradation Kinetics, Version 1.1, 18 December 2014 @@ -247,44 +240,6 @@ an increasing rate constant, supposedly caused by microbial growth

#> k0 0.4448749 #> r 1.1821120 #> sigma 7.3256566
endpoints(m)$distimes
#> DT50 DT90 DT50_k0 DT50_kmax -#> parent 36.86533 62.41511 4297.853 10.83349
- - # Reproduce the plot on page 57 of FOCUS (2014) - plot(function(x) logistic.solution(x, 100, 0.08, 0.0001, 0.2), - from = 0, to = 100, ylim = c(0, 100), - xlab = "Time", ylab = "Residue")
plot(function(x) logistic.solution(x, 100, 0.08, 0.0001, 0.4), - from = 0, to = 100, add = TRUE, lty = 2, col = 2)
plot(function(x) logistic.solution(x, 100, 0.08, 0.0001, 0.8), - from = 0, to = 100, add = TRUE, lty = 3, col = 3)
plot(function(x) logistic.solution(x, 100, 0.08, 0.001, 0.2), - from = 0, to = 100, add = TRUE, lty = 4, col = 4)
plot(function(x) logistic.solution(x, 100, 0.08, 0.08, 0.2), - from = 0, to = 100, add = TRUE, lty = 5, col = 5)
legend("topright", inset = 0.05, - legend = paste0("k0 = ", c(0.0001, 0.0001, 0.0001, 0.001, 0.08), - ", r = ", c(0.2, 0.4, 0.8, 0.2, 0.2)), - lty = 1:5, col = 1:5)
- # Fit with synthetic data - logistic <- mkinmod(parent = mkinsub("logistic")) - - sampling_times = c(0, 1, 3, 7, 14, 28, 60, 90, 120) - parms_logistic <- c(kmax = 0.08, k0 = 0.0001, r = 0.2) - d_logistic <- mkinpredict(logistic, - parms_logistic, c(parent = 100), - sampling_times) - d_2_1 <- add_err(d_logistic, - sdfunc = function(x) sigma_twocomp(x, 0.5, 0.07), - n = 1, reps = 2, digits = 5, LOD = 0.1, seed = 123456)[[1]] - - m <- mkinfit("logistic", d_2_1, quiet = TRUE) - plot_sep(m)
summary(m)$bpar
#> Estimate se_notrans t value Pr(>t) Lower -#> parent_0 1.057896e+02 1.9023449703 55.610119 3.768361e-16 1.016451e+02 -#> kmax 6.398190e-02 0.0143201031 4.467978 3.841829e-04 3.929235e-02 -#> k0 1.612775e-04 0.0005866813 0.274898 3.940351e-01 5.846688e-08 -#> r 2.263946e-01 0.1718110715 1.317695 1.061044e-01 4.335843e-02 -#> sigma 5.332935e+00 0.9145907310 5.830952 4.036926e-05 3.340213e+00 -#> Upper -#> parent_0 109.9341588 -#> kmax 0.1041853 -#> k0 0.4448749 -#> r 1.1821120 -#> sigma 7.3256566
endpoints(m)$distimes
#> DT50 DT90 DT50_k0 DT50_kmax #> parent 36.86533 62.41511 4297.853 10.83349
diff --git a/docs/reference/mkinmod.html b/docs/reference/mkinmod.html index d1204e2e..2f2e89d9 100644 --- a/docs/reference/mkinmod.html +++ b/docs/reference/mkinmod.html @@ -75,7 +75,7 @@ list of lists can be given in the speclist argument." /> mkin - 0.9.49.11 + 0.9.50 @@ -152,7 +152,7 @@ list of lists can be given in the speclist argument.

mkinmod(
   ...,
-  use_of_ff = "min",
+  use_of_ff = "max",
   speclist = NULL,
   quiet = FALSE,
   verbose = FALSE
@@ -252,15 +252,15 @@ in the FOCUS and NAFTA guidance documents are used.

SFO_SFO <- mkinmod( parent = mkinsub("SFO", "m1"), m1 = mkinsub("SFO"), verbose = TRUE)
#> Compilation argument: -#> /usr/lib/R/bin/R CMD SHLIB file66a9718e919b.c 2> file66a9718e919b.c.err.txt +#> /usr/lib/R/bin/R CMD SHLIB fileb6a4eaab60.c 2> fileb6a4eaab60.c.err.txt #> Program source: #> 1: #include <R.h> #> 2: #> 3: #> 4: static double parms [3]; -#> 5: #define k_parent_sink parms[0] -#> 6: #define k_parent_m1 parms[1] -#> 7: #define k_m1_sink parms[2] +#> 5: #define k_parent parms[0] +#> 6: #define f_parent_to_m1 parms[1] +#> 7: #define k_m1 parms[2] #> 8: #> 9: void initpar(void (* odeparms)(int *, double *)) { #> 10: int N = 3; @@ -270,8 +270,8 @@ in the FOCUS and NAFTA guidance documents are used.

#> 14: #> 15: void func ( int * n, double * t, double * y, double * f, double * rpar, int * ipar ) { #> 16: -#> 17: f[0] = - k_parent_sink * y[0] - k_parent_m1 * y[0]; -#> 18: f[1] = + k_parent_m1 * y[0] - k_m1_sink * y[1]; +#> 17: f[0] = - k_parent * y[0]; +#> 18: f[1] = + f_parent_to_m1 * k_parent * y[0] - k_m1 * y[1]; #> 19: }
#> Successfully compiled differential equation model from auto-generated C code.
# If we have several parallel metabolites # (compare tests/testthat/test_synthetic_data_for_UBA_2014.R) diff --git a/docs/reference/mkinpredict.html b/docs/reference/mkinpredict.html index 689fb7c7..21c13156 100644 --- a/docs/reference/mkinpredict.html +++ b/docs/reference/mkinpredict.html @@ -74,7 +74,7 @@ kinetic parameters and initial values for the state variables." /> mkin - 0.9.49.11 + 0.9.50
@@ -268,8 +268,29 @@ solver is used.

SFO <- mkinmod(degradinol = mkinsub("SFO")) # Compare solution types -mkinpredict(SFO, c(k_degradinol_sink = 0.3), c(degradinol = 100), 0:20, - solution_type = "analytical")
#> Error in (function (t, parent_0, k) { parent = parent_0 * exp(-k * t)})(t = 0:20, parent.0 = c(degradinol = 100), k = 0.3): unbenutztes Argument (parent.0 = 100)
mkinpredict(SFO, c(k_degradinol_sink = 0.3), c(degradinol = 100), 0:20, +mkinpredict(SFO, c(k_degradinol = 0.3), c(degradinol = 100), 0:20, + solution_type = "analytical")
#> time degradinol +#> 1 0 100.0000000 +#> 2 1 74.0818221 +#> 3 2 54.8811636 +#> 4 3 40.6569660 +#> 5 4 30.1194212 +#> 6 5 22.3130160 +#> 7 6 16.5298888 +#> 8 7 12.2456428 +#> 9 8 9.0717953 +#> 10 9 6.7205513 +#> 11 10 4.9787068 +#> 12 11 3.6883167 +#> 13 12 2.7323722 +#> 14 13 2.0241911 +#> 15 14 1.4995577 +#> 16 15 1.1108997 +#> 17 16 0.8229747 +#> 18 17 0.6096747 +#> 19 18 0.4516581 +#> 20 19 0.3345965 +#> 21 20 0.2478752
mkinpredict(SFO, c(k_degradinol = 0.3), c(degradinol = 100), 0:20, solution_type = "deSolve")
#> time degradinol #> 1 0 100.0000000 #> 2 1 74.0818221 @@ -291,7 +312,7 @@ solver is used.

#> 18 17 0.6096747 #> 19 18 0.4516581 #> 20 19 0.3345965 -#> 21 20 0.2478752
mkinpredict(SFO, c(k_degradinol_sink = 0.3), c(degradinol = 100), 0:20, +#> 21 20 0.2478752
mkinpredict(SFO, c(k_degradinol = 0.3), c(degradinol = 100), 0:20, solution_type = "deSolve", use_compiled = FALSE)
#> time degradinol #> 1 0 100.0000000 #> 2 1 74.0818221 @@ -313,7 +334,7 @@ solver is used.

#> 18 17 0.6096747 #> 19 18 0.4516581 #> 20 19 0.3345965 -#> 21 20 0.2478752
mkinpredict(SFO, c(k_degradinol_sink = 0.3), c(degradinol = 100), 0:20, +#> 21 20 0.2478752
mkinpredict(SFO, c(k_degradinol = 0.3), c(degradinol = 100), 0:20, solution_type = "eigen")
#> time degradinol #> 1 0 100.0000000 #> 2 1 74.0818221 @@ -337,25 +358,26 @@ solver is used.

#> 20 19 0.3345965 #> 21 20 0.2478752
# Compare integration methods to analytical solution -mkinpredict(SFO, c(k_degradinol_sink = 0.3), c(degradinol = 100), 0:20, - solution_type = "analytical")[21,]
#> Error in (function (t, parent_0, k) { parent = parent_0 * exp(-k * t)})(t = 0:20, parent.0 = c(degradinol = 100), k = 0.3): unbenutztes Argument (parent.0 = 100)
mkinpredict(SFO, c(k_degradinol_sink = 0.3), c(degradinol = 100), 0:20, +mkinpredict(SFO, c(k_degradinol = 0.3), c(degradinol = 100), 0:20, + solution_type = "analytical")[21,]
#> time degradinol +#> 21 20 0.2478752
mkinpredict(SFO, c(k_degradinol = 0.3), c(degradinol = 100), 0:20, method = "lsoda")[21,]
#> time degradinol -#> 21 20 0.2478752
mkinpredict(SFO, c(k_degradinol_sink = 0.3), c(degradinol = 100), 0:20, +#> 21 20 0.2478752
mkinpredict(SFO, c(k_degradinol = 0.3), c(degradinol = 100), 0:20, method = "ode45")[21,]
#> time degradinol -#> 21 20 0.2478752
mkinpredict(SFO, c(k_degradinol_sink = 0.3), c(degradinol = 100), 0:20, +#> 21 20 0.2478752
mkinpredict(SFO, c(k_degradinol = 0.3), c(degradinol = 100), 0:20, method = "rk4")[21,]
#> time degradinol #> 21 20 0.2480043
# rk4 is not as precise here # The number of output times used to make a lot of difference until the # default for atol was adjusted -mkinpredict(SFO, c(k_degradinol_sink = 0.3), c(degradinol = 100), +mkinpredict(SFO, c(k_degradinol = 0.3), c(degradinol = 100), seq(0, 20, by = 0.1))[201,]
#> time degradinol -#> 201 20 0.2478752
mkinpredict(SFO, c(k_degradinol_sink = 0.3), c(degradinol = 100), +#> 201 20 0.2478752
mkinpredict(SFO, c(k_degradinol = 0.3), c(degradinol = 100), seq(0, 20, by = 0.01))[2001,]
#> time degradinol #> 2001 20 0.2478752
# Check compiled model versions - they are faster than the eigenvalue based solutions! SFO_SFO = mkinmod(parent = list(type = "SFO", to = "m1"), - m1 = list(type = "SFO"))
#> Successfully compiled differential equation model from auto-generated C code.
if(require(rbenchmark)) { + m1 = list(type = "SFO"), use_of_ff = "min")
#> Successfully compiled differential equation model from auto-generated C code.
if(require(rbenchmark)) { benchmark( eigen = mkinpredict(SFO_SFO, c(k_parent_m1 = 0.05, k_parent_sink = 0.1, k_m1_sink = 0.01), c(parent = 100, m1 = 0), seq(0, 20, by = 0.1), @@ -371,7 +393,7 @@ solver is used.

}
#> Lade nötiges Paket: rbenchmark
#> test replications elapsed relative user.self sys.self user.child #> 3 deSolve 10 0.229 28.625 0.229 0 0 #> 2 deSolve_compiled 10 0.008 1.000 0.008 0 0 -#> 1 eigen 10 0.025 3.125 0.026 0 0 +#> 1 eigen 10 0.026 3.250 0.025 0 0 #> sys.child #> 3 0 #> 2 0 diff --git a/docs/reference/nlme-1.png b/docs/reference/nlme-1.png index 68ccb43f..8db1f999 100644 Binary files a/docs/reference/nlme-1.png and b/docs/reference/nlme-1.png differ diff --git a/docs/reference/nlme.html b/docs/reference/nlme.html index 70c6b63c..b92d2141 100644 --- a/docs/reference/nlme.html +++ b/docs/reference/nlme.html @@ -10,23 +10,27 @@ - + - + - + + + + + - - + + - + - - + + @@ -40,7 +44,6 @@ an mmkin row object. An mmkin row object is essentially a list of mkinfit objects that have been obtained by fitting the same model to a list of datasets." /> - @@ -58,7 +61,7 @@ datasets." /> - +
@@ -116,7 +119,12 @@ datasets." />
@@ -131,7 +139,7 @@ datasets." />
@@ -177,15 +185,15 @@ datasets.

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_sink = 0.1), + 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_sink = 0.05), + 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_sink = 0.02), + c(k_parent = 0.02), c(parent = 103), sampling_times) d_SFO_3_long <- mkin_wide_to_long(d_SFO_3, time = "time") @@ -214,42 +222,37 @@ datasets.

#> Model: value ~ nlme_f(name, time, parent_0, log_k_parent_sink) #> Data: grouped_data #> AIC BIC logLik -#> 298.2781 307.7372 -144.1391 +#> 252.7798 262.1358 -121.3899 #> #> Random effects: #> Formula: list(parent_0 ~ 1, log_k_parent_sink ~ 1) #> Level: ds #> Structure: Diagonal -#> parent_0 log_k_parent_sink Residual -#> StdDev: 0.9374733 0.7098105 3.83543 +#> parent_0 log_k_parent_sink Residual +#> StdDev: 0.0006768135 0.6800777 2.489397 #> #> Fixed effects: parent_0 + log_k_parent_sink ~ 1 -#> Value Std.Error DF t-value p-value -#> parent_0 101.76838 1.1445444 45 88.91606 0 -#> log_k_parent_sink -3.05444 0.4195622 45 -7.28008 0 +#> Value Std.Error DF t-value p-value +#> parent_0 101.74884 0.6456014 44 157.60321 0 +#> log_k_parent_sink -3.05575 0.4015811 44 -7.60929 0 #> Correlation: #> prnt_0 -#> log_k_parent_sink 0.034 +#> log_k_parent_sink 0.026 #> #> Standardized Within-Group Residuals: #> Min Q1 Med Q3 Max -#> -2.6169360 -0.2185329 0.0574070 0.5720937 3.0459868 +#> -2.1317488 -0.6878121 0.0828385 0.8592270 2.9529864 #> -#> Number of Observations: 49 -#> Number of Groups: 3
plot(augPred(m_nlme, level = 0:1), layout = c(3, 1))
# augPred does not seem to work on fits with more than one state +#> Number of Observations: 48 +#> Number of Groups: 3
plot(augPred(m_nlme, level = 0:1), layout = c(3, 1))
# augPred does not seem to work on fits with more than one state # variable
- @@ -260,7 +263,7 @@ datasets.

-

Site built with pkgdown 1.4.1.

+

Site built with pkgdown 1.5.1.

diff --git a/docs/sitemap.xml b/docs/sitemap.xml index 5abcc894..81368436 100644 --- a/docs/sitemap.xml +++ b/docs/sitemap.xml @@ -60,6 +60,9 @@ https://pkgdown.jrwb.de/mkin/reference/confint.mkinfit.html + + https://pkgdown.jrwb.de/mkin/reference/create_deg_func.html + https://pkgdown.jrwb.de/mkin/reference/endpoints.html diff --git a/man/HS.solution.Rd b/man/HS.solution.Rd index 343f83f0..f72df23b 100644 --- a/man/HS.solution.Rd +++ b/man/HS.solution.Rd @@ -7,10 +7,21 @@ HS.solution(t, parent_0, k1, k2, tb) } \arguments{ +\item{t}{Time.} + +\item{parent_0}{Starting value for the response variable at time zero.} + +\item{k1}{First kinetic constant.} + +\item{k2}{Second kinetic constant.} + \item{tb}{Break point. Before this time, exponential decline according to \code{k1} is calculated, after this time, exponential decline proceeds according to \code{k2}.} } +\value{ +The value of the response variable at time \code{t}. +} \description{ Function describing two exponential decline functions with a break point between them. @@ -20,6 +31,18 @@ between them. plot(function(x) HS.solution(x, 100, 2, 0.3, 0.5), 0, 2, ylim=c(0,100)) } +\references{ +FOCUS (2006) \dQuote{Guidance Document on Estimating Persistence + and Degradation Kinetics from Environmental Fate Studies on Pesticides in + EU Registration} Report of the FOCUS Work Group on Degradation Kinetics, + EC Document Reference Sanco/10058/2005 version 2.0, 434 pp, + \url{http://esdac.jrc.ec.europa.eu/projects/degradation-kinetics} +FOCUS (2014) \dQuote{Generic guidance for Estimating Persistence + and Degradation Kinetics from Environmental Fate Studies on Pesticides in + EU Registration} Report of the FOCUS Work Group on Degradation Kinetics, + Version 1.1, 18 December 2014 + \url{http://esdac.jrc.ec.europa.eu/projects/degradation-kinetics} +} \seealso{ Other parent solutions: \code{\link{DFOP.solution}()}, diff --git a/man/SFORB.solution.Rd b/man/SFORB.solution.Rd index c70ce13b..98a8c684 100644 --- a/man/SFORB.solution.Rd +++ b/man/SFORB.solution.Rd @@ -7,6 +7,10 @@ SFORB.solution(t, parent_0, k_12, k_21, k_1output) } \arguments{ +\item{t}{Time.} + +\item{parent_0}{Starting value for the response variable at time zero.} + \item{k_12}{Kinetic constant describing transfer from free to bound.} \item{k_21}{Kinetic constant describing transfer from bound to free.} @@ -30,6 +34,18 @@ and no substance in the bound fraction. \dontrun{plot(function(x) SFORB.solution(x, 100, 0.5, 2, 3), 0, 2)} } +\references{ +FOCUS (2006) \dQuote{Guidance Document on Estimating Persistence + and Degradation Kinetics from Environmental Fate Studies on Pesticides in + EU Registration} Report of the FOCUS Work Group on Degradation Kinetics, + EC Document Reference Sanco/10058/2005 version 2.0, 434 pp, + \url{http://esdac.jrc.ec.europa.eu/projects/degradation-kinetics} +FOCUS (2014) \dQuote{Generic guidance for Estimating Persistence + and Degradation Kinetics from Environmental Fate Studies on Pesticides in + EU Registration} Report of the FOCUS Work Group on Degradation Kinetics, + Version 1.1, 18 December 2014 + \url{http://esdac.jrc.ec.europa.eu/projects/degradation-kinetics} +} \seealso{ Other parent solutions: \code{\link{DFOP.solution}()}, diff --git a/man/create_deg_func.Rd b/man/create_deg_func.Rd new file mode 100644 index 00000000..2eefdb80 --- /dev/null +++ b/man/create_deg_func.Rd @@ -0,0 +1,26 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/create_deg_func.R +\name{create_deg_func} +\alias{create_deg_func} +\title{Create degradation functions for known analytical solutions} +\usage{ +create_deg_func(spec, use_of_ff = c("min", "max")) +} +\arguments{ +\item{spec}{List of model specifications as contained in mkinmod objects} + +\item{use_of_ff}{Minimum or maximum use of formation fractions} +} +\value{ +Degradation function to be attached to mkinmod objects +} +\description{ +Create degradation functions for known analytical solutions +} +\examples{ + +SFO_SFO <- mkinmod( + parent = mkinsub("SFO", "m1"), + m1 = mkinsub("SFO")) +fit <- mkinfit(SFO_SFO, FOCUS_2006_D, quiet = TRUE) +} diff --git a/man/logistic.solution.Rd b/man/logistic.solution.Rd index 589ee8ec..33b3d44a 100644 --- a/man/logistic.solution.Rd +++ b/man/logistic.solution.Rd @@ -1,11 +1,9 @@ % Generated by roxygen2: do not edit by hand -% Please edit documentation in R/logistic.solution.R, R/parent_solutions.R +% Please edit documentation in R/parent_solutions.R \name{logistic.solution} \alias{logistic.solution} \title{Logistic kinetics} \usage{ -logistic.solution(t, parent_0, kmax, k0, r) - logistic.solution(t, parent_0, kmax, k0, r) } \arguments{ @@ -18,23 +16,15 @@ logistic.solution(t, parent_0, kmax, k0, r) \item{k0}{Minumum rate constant effective at time zero.} \item{r}{Growth rate of the increase in the rate constant.} - -\item{parent.0}{Starting value for the response variable at time zero.} } \value{ The value of the response variable at time \code{t}. } \description{ -Function describing exponential decline from a defined starting value, with -an increasing rate constant, supposedly caused by microbial growth - Function describing exponential decline from a defined starting value, with an increasing rate constant, supposedly caused by microbial growth } \note{ -The solution of the logistic model reduces to the - \code{\link{SFO.solution}} if \code{k0} is equal to \code{kmax}. - The solution of the logistic model reduces to the \code{\link{SFO.solution}} if \code{k0} is equal to \code{kmax}. } @@ -74,43 +64,13 @@ The solution of the logistic model reduces to the summary(m)$bpar endpoints(m)$distimes - - # Reproduce the plot on page 57 of FOCUS (2014) - plot(function(x) logistic.solution(x, 100, 0.08, 0.0001, 0.2), - from = 0, to = 100, ylim = c(0, 100), - xlab = "Time", ylab = "Residue") - plot(function(x) logistic.solution(x, 100, 0.08, 0.0001, 0.4), - from = 0, to = 100, add = TRUE, lty = 2, col = 2) - plot(function(x) logistic.solution(x, 100, 0.08, 0.0001, 0.8), - from = 0, to = 100, add = TRUE, lty = 3, col = 3) - plot(function(x) logistic.solution(x, 100, 0.08, 0.001, 0.2), - from = 0, to = 100, add = TRUE, lty = 4, col = 4) - plot(function(x) logistic.solution(x, 100, 0.08, 0.08, 0.2), - from = 0, to = 100, add = TRUE, lty = 5, col = 5) - legend("topright", inset = 0.05, - legend = paste0("k0 = ", c(0.0001, 0.0001, 0.0001, 0.001, 0.08), - ", r = ", c(0.2, 0.4, 0.8, 0.2, 0.2)), - lty = 1:5, col = 1:5) - - # Fit with synthetic data - logistic <- mkinmod(parent = mkinsub("logistic")) - - sampling_times = c(0, 1, 3, 7, 14, 28, 60, 90, 120) - parms_logistic <- c(kmax = 0.08, k0 = 0.0001, r = 0.2) - d_logistic <- mkinpredict(logistic, - parms_logistic, c(parent = 100), - sampling_times) - d_2_1 <- add_err(d_logistic, - sdfunc = function(x) sigma_twocomp(x, 0.5, 0.07), - n = 1, reps = 2, digits = 5, LOD = 0.1, seed = 123456)[[1]] - - m <- mkinfit("logistic", d_2_1, quiet = TRUE) - plot_sep(m) - summary(m)$bpar - endpoints(m)$distimes - } \references{ +FOCUS (2006) \dQuote{Guidance Document on Estimating Persistence + and Degradation Kinetics from Environmental Fate Studies on Pesticides in + EU Registration} Report of the FOCUS Work Group on Degradation Kinetics, + EC Document Reference Sanco/10058/2005 version 2.0, 434 pp, + \url{http://esdac.jrc.ec.europa.eu/projects/degradation-kinetics} FOCUS (2014) \dQuote{Generic guidance for Estimating Persistence and Degradation Kinetics from Environmental Fate Studies on Pesticides in EU Registration} Report of the FOCUS Work Group on Degradation Kinetics, diff --git a/man/mkinmod.Rd b/man/mkinmod.Rd index 020917b9..2ba917d6 100644 --- a/man/mkinmod.Rd +++ b/man/mkinmod.Rd @@ -6,7 +6,7 @@ \usage{ mkinmod( ..., - use_of_ff = "min", + use_of_ff = "max", speclist = NULL, quiet = FALSE, verbose = FALSE diff --git a/man/mkinpredict.Rd b/man/mkinpredict.Rd index 366d5b83..f7e4acfc 100644 --- a/man/mkinpredict.Rd +++ b/man/mkinpredict.Rd @@ -102,36 +102,36 @@ kinetic parameters and initial values for the state variables. SFO <- mkinmod(degradinol = mkinsub("SFO")) # Compare solution types -mkinpredict(SFO, c(k_degradinol_sink = 0.3), c(degradinol = 100), 0:20, +mkinpredict(SFO, c(k_degradinol = 0.3), c(degradinol = 100), 0:20, solution_type = "analytical") -mkinpredict(SFO, c(k_degradinol_sink = 0.3), c(degradinol = 100), 0:20, +mkinpredict(SFO, c(k_degradinol = 0.3), c(degradinol = 100), 0:20, solution_type = "deSolve") -mkinpredict(SFO, c(k_degradinol_sink = 0.3), c(degradinol = 100), 0:20, +mkinpredict(SFO, c(k_degradinol = 0.3), c(degradinol = 100), 0:20, solution_type = "deSolve", use_compiled = FALSE) -mkinpredict(SFO, c(k_degradinol_sink = 0.3), c(degradinol = 100), 0:20, +mkinpredict(SFO, c(k_degradinol = 0.3), c(degradinol = 100), 0:20, solution_type = "eigen") # Compare integration methods to analytical solution -mkinpredict(SFO, c(k_degradinol_sink = 0.3), c(degradinol = 100), 0:20, +mkinpredict(SFO, c(k_degradinol = 0.3), c(degradinol = 100), 0:20, solution_type = "analytical")[21,] -mkinpredict(SFO, c(k_degradinol_sink = 0.3), c(degradinol = 100), 0:20, +mkinpredict(SFO, c(k_degradinol = 0.3), c(degradinol = 100), 0:20, method = "lsoda")[21,] -mkinpredict(SFO, c(k_degradinol_sink = 0.3), c(degradinol = 100), 0:20, +mkinpredict(SFO, c(k_degradinol = 0.3), c(degradinol = 100), 0:20, method = "ode45")[21,] -mkinpredict(SFO, c(k_degradinol_sink = 0.3), c(degradinol = 100), 0:20, +mkinpredict(SFO, c(k_degradinol = 0.3), c(degradinol = 100), 0:20, method = "rk4")[21,] # rk4 is not as precise here # The number of output times used to make a lot of difference until the # default for atol was adjusted -mkinpredict(SFO, c(k_degradinol_sink = 0.3), c(degradinol = 100), +mkinpredict(SFO, c(k_degradinol = 0.3), c(degradinol = 100), seq(0, 20, by = 0.1))[201,] -mkinpredict(SFO, c(k_degradinol_sink = 0.3), c(degradinol = 100), +mkinpredict(SFO, c(k_degradinol = 0.3), c(degradinol = 100), seq(0, 20, by = 0.01))[2001,] # Check compiled model versions - they are faster than the eigenvalue based solutions! SFO_SFO = mkinmod(parent = list(type = "SFO", to = "m1"), - m1 = list(type = "SFO")) + m1 = list(type = "SFO"), use_of_ff = "min") if(require(rbenchmark)) { benchmark( eigen = mkinpredict(SFO_SFO, c(k_parent_m1 = 0.05, k_parent_sink = 0.1, k_m1_sink = 0.01), diff --git a/man/nlme.Rd b/man/nlme.Rd index 4a668ac0..a9e368dd 100644 --- a/man/nlme.Rd +++ b/man/nlme.Rd @@ -37,15 +37,15 @@ datasets. 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_sink = 0.1), + 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_sink = 0.05), + 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_sink = 0.02), + c(k_parent = 0.02), c(parent = 103), sampling_times) d_SFO_3_long <- mkin_wide_to_long(d_SFO_3, time = "time") diff --git a/test.log b/test.log index b57bd69a..72ed4ee3 100644 --- a/test.log +++ b/test.log @@ -2,34 +2,34 @@ Loading mkin Testing mkin ✔ | OK F W S | Context ✔ | 2 | Export dataset for reading into CAKE -✔ | 13 | Results for FOCUS D established in expertise for UBA (Ranke 2014) [3.6 s] +✔ | 13 | Results for FOCUS D established in expertise for UBA (Ranke 2014) [3.7 s] ✔ | 4 | Calculation of FOCUS chi2 error levels [2.2 s] -✔ | 6 | Fitting the SFORB model [9.1 s] +✔ | 7 | Fitting the SFORB model [11.7 s] ✔ | 5 | Calculation of Akaike weights -✔ | 10 | Confidence intervals and p-values [9.6 s] -✔ | 14 | Error model fitting [38.5 s] +✔ | 10 | Confidence intervals and p-values [9.3 s] +✔ | 14 | Error model fitting [37.6 s] ✔ | 6 | Test fitting the decline of metabolites from their maximum [0.8 s] ✔ | 1 | Fitting the logistic model [0.8 s] ✔ | 1 | Test dataset class mkinds used in gmkin -✔ | 12 | Special cases of mkinfit calls [2.3 s] +✔ | 12 | Special cases of mkinfit calls [2.2 s] ✔ | 8 | mkinmod model generation and printing [0.2 s] ✔ | 3 | Model predictions with mkinpredict [0.4 s] -✔ | 16 | Evaluations according to 2015 NAFTA guidance [4.2 s] -✔ | 9 | Nonlinear mixed-effects models [12.3 s] +✔ | 16 | Evaluations according to 2015 NAFTA guidance [4.1 s] +✔ | 9 | Nonlinear mixed-effects models [12.0 s] ✔ | 4 | Calculation of maximum time weighted average concentrations (TWAs) [2.4 s] ✔ | 3 | Summary -✔ | 14 | Plotting [5.1 s] +✔ | 14 | Plotting [4.9 s] ✔ | 4 | AIC calculation ✔ | 4 | Residuals extracted from mkinfit models ✔ | 2 | Complex test case from Schaefer et al. (2007) Piacenza paper [5.3 s] ✔ | 1 | Summaries of old mkinfit objects ✔ | 4 | Results for synthetic data established in expertise for UBA (Ranke 2014) [7.2 s] -✔ | 9 | Hypothesis tests [38.2 s] +✔ | 9 | Hypothesis tests [37.9 s] ══ Results ═════════════════════════════════════════════════════════════════════ -Duration: 142.5 s +Duration: 143.0 s -OK: 155 +OK: 156 Failed: 0 Warnings: 0 Skipped: 0 diff --git a/tests/testthat/FOCUS_2006_D.csf b/tests/testthat/FOCUS_2006_D.csf index fa96de74..7c29ab46 100644 --- a/tests/testthat/FOCUS_2006_D.csf +++ b/tests/testthat/FOCUS_2006_D.csf @@ -5,7 +5,7 @@ Description: MeasurementUnits: % AR TimeUnits: days Comments: Created using mkin::CAKE_export -Date: 2020-05-06 +Date: 2020-05-07 Optimiser: IRLS [Data] diff --git a/tests/testthat/SFO_SFO_printed.txt b/tests/testthat/SFO_SFO_printed.txt index d0402fc0..a3a04be2 100644 --- a/tests/testthat/SFO_SFO_printed.txt +++ b/tests/testthat/SFO_SFO_printed.txt @@ -1,5 +1,5 @@ model generated with -Use of formation fractions $use_of_ff: min +Use of formation fractions $use_of_ff: max Specification $spec: $parent $type: SFO; $to: m1; $sink: TRUE @@ -7,5 +7,5 @@ $m1 $type: SFO; $sink: TRUE Coefficient matrix $coefmat available Differential equations: -d_parent/dt = - k_parent_sink * parent - k_parent_m1 * parent -d_m1/dt = + k_parent_m1 * parent - k_m1_sink * m1 +d_parent/dt = - k_parent * parent +d_m1/dt = + f_parent_to_m1 * k_parent * parent - k_m1 * m1 diff --git a/tests/testthat/summary_DFOP_FOCUS_C.txt b/tests/testthat/summary_DFOP_FOCUS_C.txt index 14e00f62..4f96c8d3 100644 --- a/tests/testthat/summary_DFOP_FOCUS_C.txt +++ b/tests/testthat/summary_DFOP_FOCUS_C.txt @@ -33,6 +33,11 @@ g_ilr 0.000000 -Inf Inf Fixed parameter values: None +Results: + + AIC BIC logLik + 29.02372 30.00984 -9.511861 + Optimised, transformed parameters with symmetric confidence intervals: Estimate Std. Error Lower Upper parent_0 85.0000 0.66620 83.1500 86.8500 diff --git a/tests/testthat/summary_DFOP_FOCUS_D_deSolve.txt b/tests/testthat/summary_DFOP_FOCUS_D_deSolve.txt index 66ab9348..fe697794 100644 --- a/tests/testthat/summary_DFOP_FOCUS_D_deSolve.txt +++ b/tests/testthat/summary_DFOP_FOCUS_D_deSolve.txt @@ -4,8 +4,8 @@ Date of fit: Dummy date for testing Date of summary: Dummy date for testing Equations: -d_parent/dt = - k_parent_sink * parent - k_parent_m1 * parent -d_m1/dt = + k_parent_m1 * parent - k_m1_sink * m1 +d_parent/dt = - k_parent * parent +d_m1/dt = + f_parent_to_m1 * k_parent * parent - k_m1 * m1 Model predictions using solution type deSolve @@ -16,30 +16,35 @@ Error model: Constant variance Error model algorithm: OLS Starting values for parameters to be optimised: - value type -parent_0 100.7500 state -k_parent_sink 0.1000 deparm -k_parent_m1 0.1001 deparm -k_m1_sink 0.1002 deparm + value type +parent_0 100.7500 state +k_parent 0.1000 deparm +k_m1 0.1001 deparm +f_parent_to_m1 0.5000 deparm Starting values for the transformed parameters actually optimised: - value lower upper -parent_0 100.750000 -Inf Inf -log_k_parent_sink -2.302585 -Inf Inf -log_k_parent_m1 -2.301586 -Inf Inf -log_k_m1_sink -2.300587 -Inf Inf + value lower upper +parent_0 100.750000 -Inf Inf +log_k_parent -2.302585 -Inf Inf +log_k_m1 -2.301586 -Inf Inf +f_parent_ilr_1 0.000000 -Inf Inf Fixed parameter values: value type m1_0 0 state +Results: + + AIC BIC logLik + 204.4486 212.6365 -97.22429 + Optimised, transformed parameters with symmetric confidence intervals: - Estimate Std. Error Lower Upper -parent_0 99.600 1.57000 96.400 102.800 -log_k_parent_sink -3.038 0.07626 -3.193 -2.883 -log_k_parent_m1 -2.980 0.04033 -3.062 -2.898 -log_k_m1_sink -5.248 0.13320 -5.518 -4.977 -sigma 3.126 0.35850 2.396 3.855 + Estimate Std. Error Lower Upper +parent_0 99.60000 1.57000 96.40000 102.8000 +log_k_parent -2.31600 0.04087 -2.39900 -2.2330 +log_k_m1 -5.24800 0.13320 -5.51800 -4.9770 +f_parent_ilr_1 0.04096 0.06312 -0.08746 0.1694 +sigma 3.12600 0.35850 2.39600 3.8550 Parameter correlation: NULL @@ -48,24 +53,23 @@ Backtransformed parameters: Confidence intervals for internally transformed parameters are asymmetric. t-test (unrealistically) based on the assumption of normal distribution for estimators of untransformed parameters. - Estimate t value Pr(>t) Lower Upper -parent_0 99.600000 63.430 2.298e-36 96.400000 1.028e+02 -k_parent_sink 0.047920 13.110 6.126e-15 0.041030 5.596e-02 -k_parent_m1 0.050780 24.800 3.269e-23 0.046780 5.512e-02 -k_m1_sink 0.005261 7.510 6.165e-09 0.004012 6.898e-03 -sigma 3.126000 8.718 2.235e-10 2.396000 3.855e+00 + Estimate t value Pr(>t) Lower Upper +parent_0 99.600000 63.430 2.298e-36 96.400000 1.028e+02 +k_parent 0.098700 24.470 4.955e-23 0.090820 1.073e-01 +k_m1 0.005261 7.510 6.165e-09 0.004012 6.898e-03 +f_parent_to_m1 0.514500 23.070 3.104e-22 0.469100 5.596e-01 +sigma 3.126000 8.718 2.235e-10 2.396000 3.855e+00 FOCUS Chi2 error levels in percent: err.min n.optim df All data 6.398 4 15 -parent 6.827 3 6 -m1 4.490 1 9 +parent 6.459 2 7 +m1 4.690 2 8 Resulting formation fractions: ff -parent_sink 0.4855 parent_m1 0.5145 -m1_sink 1.0000 +parent_sink 0.4855 Estimated disappearance times: DT50 DT90 @@ -78,10 +82,10 @@ Data: 0 parent 102.04 99.59848 2.442e+00 1 parent 93.50 90.23787 3.262e+00 1 parent 92.50 90.23787 2.262e+00 - 3 parent 63.23 74.07320 -1.084e+01 - 3 parent 68.99 74.07320 -5.083e+00 - 7 parent 52.32 49.91207 2.408e+00 - 7 parent 55.13 49.91207 5.218e+00 + 3 parent 63.23 74.07319 -1.084e+01 + 3 parent 68.99 74.07319 -5.083e+00 + 7 parent 52.32 49.91206 2.408e+00 + 7 parent 55.13 49.91206 5.218e+00 14 parent 27.27 25.01257 2.257e+00 14 parent 26.64 25.01257 1.627e+00 21 parent 11.50 12.53462 -1.035e+00 @@ -91,7 +95,7 @@ Data: 50 parent 0.69 0.71624 -2.624e-02 50 parent 0.63 0.71624 -8.624e-02 75 parent 0.05 0.06074 -1.074e-02 - 75 parent 0.06 0.06074 -7.382e-04 + 75 parent 0.06 0.06074 -7.381e-04 1 m1 4.84 4.80296 3.704e-02 1 m1 5.64 4.80296 8.370e-01 3 m1 12.91 13.02400 -1.140e-01 diff --git a/tests/testthat/summary_DFOP_FOCUS_D_eigen.txt b/tests/testthat/summary_DFOP_FOCUS_D_eigen.txt index 1626c5da..6ddbc1ab 100644 --- a/tests/testthat/summary_DFOP_FOCUS_D_eigen.txt +++ b/tests/testthat/summary_DFOP_FOCUS_D_eigen.txt @@ -4,8 +4,8 @@ Date of fit: Dummy date for testing Date of summary: Dummy date for testing Equations: -d_parent/dt = - k_parent_sink * parent - k_parent_m1 * parent -d_m1/dt = + k_parent_m1 * parent - k_m1_sink * m1 +d_parent/dt = - k_parent * parent +d_m1/dt = + f_parent_to_m1 * k_parent * parent - k_m1 * m1 Model predictions using solution type eigen @@ -16,30 +16,35 @@ Error model: Constant variance Error model algorithm: OLS Starting values for parameters to be optimised: - value type -parent_0 100.7500 state -k_parent_sink 0.1000 deparm -k_parent_m1 0.1001 deparm -k_m1_sink 0.1002 deparm + value type +parent_0 100.7500 state +k_parent 0.1000 deparm +k_m1 0.1001 deparm +f_parent_to_m1 0.5000 deparm Starting values for the transformed parameters actually optimised: - value lower upper -parent_0 100.750000 -Inf Inf -log_k_parent_sink -2.302585 -Inf Inf -log_k_parent_m1 -2.301586 -Inf Inf -log_k_m1_sink -2.300587 -Inf Inf + value lower upper +parent_0 100.750000 -Inf Inf +log_k_parent -2.302585 -Inf Inf +log_k_m1 -2.301586 -Inf Inf +f_parent_ilr_1 0.000000 -Inf Inf Fixed parameter values: value type m1_0 0 state +Results: + + AIC BIC logLik + 204.4486 212.6365 -97.22429 + Optimised, transformed parameters with symmetric confidence intervals: - Estimate Std. Error Lower Upper -parent_0 99.600 1.57000 96.400 102.800 -log_k_parent_sink -3.038 0.07626 -3.193 -2.883 -log_k_parent_m1 -2.980 0.04033 -3.062 -2.898 -log_k_m1_sink -5.248 0.13320 -5.518 -4.977 -sigma 3.126 0.35850 2.396 3.855 + Estimate Std. Error Lower Upper +parent_0 99.60000 1.57000 96.40000 102.8000 +log_k_parent -2.31600 0.04087 -2.39900 -2.2330 +log_k_m1 -5.24800 0.13320 -5.51800 -4.9770 +f_parent_ilr_1 0.04096 0.06312 -0.08746 0.1694 +sigma 3.12600 0.35850 2.39600 3.8550 Parameter correlation: NULL @@ -48,24 +53,23 @@ Backtransformed parameters: Confidence intervals for internally transformed parameters are asymmetric. t-test (unrealistically) based on the assumption of normal distribution for estimators of untransformed parameters. - Estimate t value Pr(>t) Lower Upper -parent_0 99.600000 63.430 2.298e-36 96.400000 1.028e+02 -k_parent_sink 0.047920 13.110 6.126e-15 0.041030 5.596e-02 -k_parent_m1 0.050780 24.800 3.269e-23 0.046780 5.512e-02 -k_m1_sink 0.005261 7.510 6.165e-09 0.004012 6.898e-03 -sigma 3.126000 8.718 2.235e-10 2.396000 3.855e+00 + Estimate t value Pr(>t) Lower Upper +parent_0 99.600000 63.430 2.298e-36 96.400000 1.028e+02 +k_parent 0.098700 24.470 4.955e-23 0.090820 1.073e-01 +k_m1 0.005261 7.510 6.165e-09 0.004012 6.898e-03 +f_parent_to_m1 0.514500 23.070 3.104e-22 0.469100 5.596e-01 +sigma 3.126000 8.718 2.235e-10 2.396000 3.855e+00 FOCUS Chi2 error levels in percent: err.min n.optim df All data 6.398 4 15 -parent 6.827 3 6 -m1 4.490 1 9 +parent 6.459 2 7 +m1 4.690 2 8 Resulting formation fractions: ff -parent_sink 0.4855 parent_m1 0.5145 -m1_sink 1.0000 +parent_sink 0.4855 Estimated disappearance times: DT50 DT90 diff --git a/tests/testthat/test_SFORB.R b/tests/testthat/test_SFORB.R index ad9881a8..4fb736ec 100644 --- a/tests/testthat/test_SFORB.R +++ b/tests/testthat/test_SFORB.R @@ -14,17 +14,21 @@ test_that("Fitting the SFORB model is equivalent to fitting DFOP", { M1 = mkinsub("SFO"), use_of_ff = "max", quiet = TRUE) SFORB_SFO <- mkinmod(parent = mkinsub("SFORB", "M1"), + M1 = mkinsub("SFO"), + use_of_ff = "min", quiet = TRUE) + SFORB_SFO_ff <- mkinmod(parent = mkinsub("SFORB", "M1"), M1 = mkinsub("SFO"), use_of_ff = "max", quiet = TRUE) - SFORB_SFO$coefmat - f_dfop_sfo <- mkinfit(DFOP_SFO, DFOP_par_c, quiet = TRUE) f_sforb_sfo <- mkinfit(SFORB_SFO, DFOP_par_c, quiet = TRUE) + f_sforb_sfo_ff <- mkinfit(SFORB_SFO_ff, DFOP_par_c, quiet = TRUE) f_sforb_sfo_eigen <- mkinfit(SFORB_SFO, DFOP_par_c, solution_type = "eigen", quiet = TRUE) expect_equivalent(endpoints(f_sforb_sfo)$distimes, endpoints(f_dfop_sfo)$distimes, tolerance = 1e-6) + expect_equivalent(endpoints(f_sforb_sfo_ff)$distimes, endpoints(f_dfop_sfo)$distimes, + tolerance = 1e-6) expect_equivalent(endpoints(f_sforb_sfo_eigen)$distimes, endpoints(f_dfop_sfo)$distimes, tolerance = 1e-6) }) diff --git a/tests/testthat/test_nlme.R b/tests/testthat/test_nlme.R index e5e19c60..31fb19de 100644 --- a/tests/testthat/test_nlme.R +++ b/tests/testthat/test_nlme.R @@ -2,20 +2,21 @@ context("Nonlinear mixed-effects models") library(nlme) +sampling_times = c(0, 1, 3, 7, 14, 28, 60, 90, 120) + test_that("nlme_function works correctly", { - 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_sink = 0.1), + 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_sink = 0.05), + 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_sink = 0.02), + c(k_parent = 0.02), c(parent = 103), sampling_times) d_SFO_3_long <- mkin_wide_to_long(d_SFO_3, time = "time") @@ -33,7 +34,6 @@ test_that("nlme_function works correctly", { # The following assignment was introduced for nlme as evaluated by testthat # to find the function assign("nlme_f", nlme_f, pos = globalenv()) - assign("sampling_times", sampling_times, pos = globalenv()) m_nlme_raw <- nlme(value ~ SSasymp(time, 0, parent_0, log_k_parent_sink), data = grouped_data, @@ -101,7 +101,7 @@ test_that("nlme_function works correctly in other cases", { SFO <- mkinmod(parent = mkinsub("SFO")) pred_sfo <- function(k) { mkinpredict(SFO, - c(k_parent_sink = k), + c(k_parent = k), c(parent = 100), sampling_times) } -- cgit v1.2.1