diff options
author | Johannes Ranke <jranke@uni-bremen.de> | 2020-05-07 22:13:33 +0200 |
---|---|---|
committer | Johannes Ranke <jranke@uni-bremen.de> | 2020-05-07 22:14:19 +0200 |
commit | 92bd33824bde6b6b21bfc7e30953092a74d3cce5 (patch) | |
tree | bb2e08ef15d8a4f4f7b04cf4f5312ec861ec1d1c | |
parent | 67c8163487e776e9a378c9dfcd39c74f6e6bc507 (diff) |
Another overhaul of analytical solutions
Still in preparation for analytical solutions of coupled models
45 files changed, 626 insertions, 390 deletions
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")), @@ -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), @@ -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 @@ -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’ @@ -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 <jranke@uni-bremen.de>’ 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 @@ </button> <span class="navbar-brand"> <a class="navbar-link" href="https://pkgdown.jrwb.de/mkin/index.html">mkin</a> - <span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Released version">0.9.49.11</span> + <span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Released version">0.9.50</span> </span> </div> 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 @@ </button> <span class="navbar-brand"> <a class="navbar-link" href="../index.html">mkin</a> - <span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Released version">0.9.49.11</span> + <span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Released version">0.9.50</span> </span> </div> 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 @@ </button> <span class="navbar-brand"> <a class="navbar-link" href="index.html">mkin</a> - <span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Released version">0.9.49.11</span> + <span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Released version">0.9.50</span> </span> </div> 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 @@ </button> <span class="navbar-brand"> <a class="navbar-link" href="index.html">mkin</a> - <span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Released version">0.9.49.11</span> + <span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Released version">0.9.50</span> </span> </div> 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 @@ </button> <span class="navbar-brand"> <a class="navbar-link" href="../index.html">mkin</a> - <span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Released version">0.9.49.11</span> + <span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Released version">0.9.50</span> </span> </div> @@ -143,7 +143,9 @@ <a href="#mkin-0-9-50-1-unreleased" class="anchor"></a>mkin 0.9.50.1 (unreleased)<small> Unreleased </small> </h1> <ul> -<li>Support SFORB with formation fractions</li> +<li><p>Support SFORB with formation fractions</p></li> +<li><p>‘mkinmod’: Make ‘use_of_ff’ = “max” the default</p></li> +<li><p>Implement analytical solutions for some coupled models, e.g. SFO-SFO, DFOP-SFO, SFORB-SFO</p></li> </ul> </div> <div id="mkin-0-9-49-11-2020-04-20" class="section level1"> 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." /> </button> <span class="navbar-brand"> <a class="navbar-link" href="../index.html">mkin</a> - <span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Released version">0.9.49.11</span> + <span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Released version">0.9.50</span> </span> </div> 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." /> </button> <span class="navbar-brand"> <a class="navbar-link" href="../index.html">mkin</a> - <span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Released version">0.9.49.11</span> + <span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Released version">0.9.50</span> </span> </div> 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." /> </button> <span class="navbar-brand"> <a class="navbar-link" href="../index.html">mkin</a> - <span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Released version">0.9.49.11</span> + <span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Released version">0.9.50</span> </span> </div> @@ -152,6 +152,22 @@ between them.</p> <table class="ref-arguments"> <colgroup><col class="name" /><col class="desc" /></colgroup> <tr> + <th>t</th> + <td><p>Time.</p></td> + </tr> + <tr> + <th>parent_0</th> + <td><p>Starting value for the response variable at time zero.</p></td> + </tr> + <tr> + <th>k1</th> + <td><p>First kinetic constant.</p></td> + </tr> + <tr> + <th>k2</th> + <td><p>Second kinetic constant.</p></td> + </tr> + <tr> <th>tb</th> <td><p>Break point. Before this time, exponential decline according to <code>k1</code> is calculated, after this time, exponential decline proceeds @@ -159,6 +175,21 @@ according to <code>k2</code>.</p></td> </tr> </table> + <h2 class="hasAnchor" id="value"><a class="anchor" href="#value"></a>Value</h2> + + <p>The value of the response variable at time <code>t</code>.</p> + <h2 class="hasAnchor" id="references"><a class="anchor" href="#references"></a>References</h2> + + <p>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, + <a href='http://esdac.jrc.ec.europa.eu/projects/degradation-kinetics'>http://esdac.jrc.ec.europa.eu/projects/degradation-kinetics</a> +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 + <a href='http://esdac.jrc.ec.europa.eu/projects/degradation-kinetics'>http://esdac.jrc.ec.europa.eu/projects/degradation-kinetics</a></p> <h2 class="hasAnchor" id="see-also"><a class="anchor" href="#see-also"></a>See also</h2> <div class='dont-index'><p>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 @@ </button> <span class="navbar-brand"> <a class="navbar-link" href="../index.html">mkin</a> - <span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Released version">0.9.49.11</span> + <span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Released version">0.9.50</span> </span> </div> 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." /> </button> <span class="navbar-brand"> <a class="navbar-link" href="../index.html">mkin</a> - <span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Released version">0.9.49.11</span> + <span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Released version">0.9.50</span> </span> </div> @@ -158,6 +158,14 @@ and no substance in the bound fraction.</p> <table class="ref-arguments"> <colgroup><col class="name" /><col class="desc" /></colgroup> <tr> + <th>t</th> + <td><p>Time.</p></td> + </tr> + <tr> + <th>parent_0</th> + <td><p>Starting value for the response variable at time zero.</p></td> + </tr> + <tr> <th>k_12</th> <td><p>Kinetic constant describing transfer from free to bound.</p></td> </tr> @@ -176,6 +184,18 @@ fraction.</p></td> <p>The value of the response variable, which is the sum of free and bound fractions at time <code>t</code>.</p> + <h2 class="hasAnchor" id="references"><a class="anchor" href="#references"></a>References</h2> + + <p>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, + <a href='http://esdac.jrc.ec.europa.eu/projects/degradation-kinetics'>http://esdac.jrc.ec.europa.eu/projects/degradation-kinetics</a> +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 + <a href='http://esdac.jrc.ec.europa.eu/projects/degradation-kinetics'>http://esdac.jrc.ec.europa.eu/projects/degradation-kinetics</a></p> <h2 class="hasAnchor" id="see-also"><a class="anchor" href="#see-also"></a>See also</h2> <div class='dont-index'><p>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 @@ +<!-- Generated by pkgdown: do not edit by hand --> +<!DOCTYPE html> +<html lang="en"> + <head> + <meta charset="utf-8"> +<meta http-equiv="X-UA-Compatible" content="IE=edge"> +<meta name="viewport" content="width=device-width, initial-scale=1.0"> + +<title>Create degradation functions for known analytical solutions — create_deg_func • mkin</title> + + +<!-- jquery --> +<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.4.1/jquery.min.js" integrity="sha256-CSXorXvZcTkaix6Yvo6HppcZGetbYMGWSFlBw8HfCJo=" crossorigin="anonymous"></script> +<!-- Bootstrap --> + +<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/3.4.1/css/bootstrap.min.css" integrity="sha256-bZLfwXAP04zRMK2BjiO8iu9pf4FbLqX6zitd+tIvLhE=" crossorigin="anonymous" /> + +<script src="https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/3.4.1/js/bootstrap.min.js" integrity="sha256-nuL8/2cJ5NDSSwnKD8VqreErSWHtnEP9E7AySL+1ev4=" crossorigin="anonymous"></script> + +<!-- bootstrap-toc --> +<link rel="stylesheet" href="../bootstrap-toc.css"> +<script src="../bootstrap-toc.js"></script> + +<!-- Font Awesome icons --> +<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/5.12.1/css/all.min.css" integrity="sha256-mmgLkCYLUQbXn0B1SRqzHar6dCnv9oZFPEC1g1cwlkk=" crossorigin="anonymous" /> +<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/5.12.1/css/v4-shims.min.css" integrity="sha256-wZjR52fzng1pJHwx4aV2AO3yyTOXrcDW7jBpJtTwVxw=" crossorigin="anonymous" /> + +<!-- clipboard.js --> +<script src="https://cdnjs.cloudflare.com/ajax/libs/clipboard.js/2.0.6/clipboard.min.js" integrity="sha256-inc5kl9MA1hkeYUt+EC3BhlIgyp/2jDIyBLS6k3UxPI=" crossorigin="anonymous"></script> + +<!-- headroom.js --> +<script src="https://cdnjs.cloudflare.com/ajax/libs/headroom/0.11.0/headroom.min.js" integrity="sha256-AsUX4SJE1+yuDu5+mAVzJbuYNPHj/WroHuZ8Ir/CkE0=" crossorigin="anonymous"></script> +<script src="https://cdnjs.cloudflare.com/ajax/libs/headroom/0.11.0/jQuery.headroom.min.js" integrity="sha256-ZX/yNShbjqsohH1k95liqY9Gd8uOiE1S4vZc+9KQ1K4=" crossorigin="anonymous"></script> + +<!-- pkgdown --> +<link href="../pkgdown.css" rel="stylesheet"> +<script src="../pkgdown.js"></script> + + + + +<meta property="og:title" content="Create degradation functions for known analytical solutions — create_deg_func" /> +<meta property="og:description" content="Create degradation functions for known analytical solutions" /> + + + + +<!-- mathjax --> +<script src="https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.5/MathJax.js" integrity="sha256-nvJJv9wWKEm88qvoQl9ekL2J+k/RWIsaSScxxlsrv8k=" crossorigin="anonymous"></script> +<script src="https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.5/config/TeX-AMS-MML_HTMLorMML.js" integrity="sha256-84DKXVJXs0/F8OTMzX4UR909+jtl4G7SPypPavF+GfA=" crossorigin="anonymous"></script> + +<!--[if lt IE 9]> +<script src="https://oss.maxcdn.com/html5shiv/3.7.3/html5shiv.min.js"></script> +<script src="https://oss.maxcdn.com/respond/1.4.2/respond.min.js"></script> +<![endif]--> + + + + </head> + + <body data-spy="scroll" data-target="#toc"> + <div class="container template-reference-topic"> + <header> + <div class="navbar navbar-default navbar-fixed-top" role="navigation"> + <div class="container"> + <div class="navbar-header"> + <button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#navbar" aria-expanded="false"> + <span class="sr-only">Toggle navigation</span> + <span class="icon-bar"></span> + <span class="icon-bar"></span> + <span class="icon-bar"></span> + </button> + <span class="navbar-brand"> + <a class="navbar-link" href="../index.html">mkin</a> + <span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Released version">0.9.50</span> + </span> + </div> + + <div id="navbar" class="navbar-collapse collapse"> + <ul class="nav navbar-nav"> + <li> + <a href="../reference/index.html">Functions and data</a> +</li> +<li class="dropdown"> + <a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-expanded="false"> + Articles + + <span class="caret"></span> + </a> + <ul class="dropdown-menu" role="menu"> + <li> + <a href="../articles/mkin.html">Introduction to mkin</a> + </li> + <li> + <a href="../articles/FOCUS_D.html">Example evaluation of FOCUS Example Dataset D</a> + </li> + <li> + <a href="../articles/FOCUS_L.html">Example evaluation of FOCUS Laboratory Data L1 to L3</a> + </li> + <li> + <a href="../articles/web_only/FOCUS_Z.html">Example evaluation of FOCUS Example Dataset Z</a> + </li> + <li> + <a href="../articles/web_only/compiled_models.html">Performance benefit by using compiled model definitions in mkin</a> + </li> + <li> + <a href="../articles/twa.html">Calculation of time weighted average concentrations with mkin</a> + </li> + <li> + <a href="../articles/web_only/NAFTA_examples.html">Example evaluation of NAFTA SOP Attachment examples</a> + </li> + </ul> +</li> +<li> + <a href="../news/index.html">News</a> +</li> + </ul> + <ul class="nav navbar-nav navbar-right"> + <li> + <a href="http://github.com/jranke/mkin/"> + <span class="fab fa fab fa-github fa-lg"></span> + + </a> +</li> + </ul> + + </div><!--/.nav-collapse --> + </div><!--/.container --> +</div><!--/.navbar --> + + + + </header> + +<div class="row"> + <div class="col-md-9 contents"> + <div class="page-header"> + <h1>Create degradation functions for known analytical solutions</h1> + <small class="dont-index">Source: <a href='http://github.com/jranke/mkin/blob/master/R/create_deg_func.R'><code>R/create_deg_func.R</code></a></small> + <div class="hidden name"><code>create_deg_func.Rd</code></div> + </div> + + <div class="ref-description"> + <p>Create degradation functions for known analytical solutions</p> + </div> + + <pre class="usage"><span class='fu'>create_deg_func</span>(<span class='no'>spec</span>, <span class='kw'>use_of_ff</span> <span class='kw'>=</span> <span class='fu'><a href='https://rdrr.io/r/base/c.html'>c</a></span>(<span class='st'>"min"</span>, <span class='st'>"max"</span>))</pre> + + <h2 class="hasAnchor" id="arguments"><a class="anchor" href="#arguments"></a>Arguments</h2> + <table class="ref-arguments"> + <colgroup><col class="name" /><col class="desc" /></colgroup> + <tr> + <th>spec</th> + <td><p>List of model specifications as contained in mkinmod objects</p></td> + </tr> + <tr> + <th>use_of_ff</th> + <td><p>Minimum or maximum use of formation fractions</p></td> + </tr> + </table> + + <h2 class="hasAnchor" id="value"><a class="anchor" href="#value"></a>Value</h2> + + <p>Degradation function to be attached to mkinmod objects</p> + + <h2 class="hasAnchor" id="examples"><a class="anchor" href="#examples"></a>Examples</h2> + <pre class="examples"><div class='input'> +<span class='no'>SFO_SFO</span> <span class='kw'><-</span> <span class='fu'><a href='mkinmod.html'>mkinmod</a></span>( + <span class='kw'>parent</span> <span class='kw'>=</span> <span class='fu'><a href='mkinsub.html'>mkinsub</a></span>(<span class='st'>"SFO"</span>, <span class='st'>"m1"</span>), + <span class='kw'>m1</span> <span class='kw'>=</span> <span class='fu'><a href='mkinsub.html'>mkinsub</a></span>(<span class='st'>"SFO"</span>))</div><div class='output co'>#> <span class='message'>Successfully compiled differential equation model from auto-generated C code.</span></div><div class='input'><span class='no'>fit</span> <span class='kw'><-</span> <span class='fu'><a href='mkinfit.html'>mkinfit</a></span>(<span class='no'>SFO_SFO</span>, <span class='no'>FOCUS_2006_D</span>, <span class='kw'>quiet</span> <span class='kw'>=</span> <span class='fl'>TRUE</span>)</div><div class='output co'>#> <span class='warning'>Warning: Observations with value of zero were removed from the data</span></div></pre> + </div> + <div class="col-md-3 hidden-xs hidden-sm" id="pkgdown-sidebar"> + <nav id="toc" data-toggle="toc" class="sticky-top"> + <h2 data-toc-skip>Contents</h2> + </nav> + </div> +</div> + + + <footer> + <div class="copyright"> + <p>Developed by Johannes Ranke.</p> +</div> + +<div class="pkgdown"> + <p>Site built with <a href="https://pkgdown.r-lib.org/">pkgdown</a> 1.5.1.</p> +</div> + + </footer> + </div> + + + + + </body> +</html> + + 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 @@ </button> <span class="navbar-brand"> <a class="navbar-link" href="../index.html">mkin</a> - <span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Released version">0.9.49.11</span> + <span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Released version">0.9.50</span> </span> </div> @@ -609,7 +609,7 @@ kinetic models fitted with mkinfit</p></td> </tr><tr> <td> - <p><code><a href="logistic.solution.html">logistic.solution()</a></code> <code><a href="logistic.solution.html">logistic.solution()</a></code> </p> + <p><code><a href="logistic.solution.html">logistic.solution()</a></code> </p> </td> <td><p>Logistic kinetics</p></td> </tr> 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 @@ <meta property="og:title" content="Logistic kinetics — logistic.solution" /> <meta property="og:description" content="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" /> @@ -75,7 +73,7 @@ an increasing rate constant, supposedly caused by microbial growth" /> </button> <span class="navbar-brand"> <a class="navbar-link" href="../index.html">mkin</a> - <span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Released version">0.9.49.11</span> + <span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Released version">0.9.50</span> </span> </div> @@ -139,20 +137,16 @@ an increasing rate constant, supposedly caused by microbial growth" /> <div class="col-md-9 contents"> <div class="page-header"> <h1>Logistic kinetics</h1> - <small class="dont-index">Source: <a href='http://github.com/jranke/mkin/blob/master/R/logistic.solution.R'><code>R/logistic.solution.R</code></a>, <a href='http://github.com/jranke/mkin/blob/master/R/parent_solutions.R'><code>R/parent_solutions.R</code></a></small> + <small class="dont-index">Source: <a href='http://github.com/jranke/mkin/blob/master/R/parent_solutions.R'><code>R/parent_solutions.R</code></a></small> <div class="hidden name"><code>logistic.solution.Rd</code></div> </div> <div class="ref-description"> <p>Function describing exponential decline from a defined starting value, with an increasing rate constant, supposedly caused by microbial growth</p> -<p>Function describing exponential decline from a defined starting value, with -an increasing rate constant, supposedly caused by microbial growth</p> </div> - <pre class="usage"><span class='fu'>logistic.solution</span>(<span class='no'>t</span>, <span class='no'>parent_0</span>, <span class='no'>kmax</span>, <span class='no'>k0</span>, <span class='no'>r</span>) - -<span class='fu'>logistic.solution</span>(<span class='no'>t</span>, <span class='no'>parent_0</span>, <span class='no'>kmax</span>, <span class='no'>k0</span>, <span class='no'>r</span>)</pre> + <pre class="usage"><span class='fu'>logistic.solution</span>(<span class='no'>t</span>, <span class='no'>parent_0</span>, <span class='no'>kmax</span>, <span class='no'>k0</span>, <span class='no'>r</span>)</pre> <h2 class="hasAnchor" id="arguments"><a class="anchor" href="#arguments"></a>Arguments</h2> <table class="ref-arguments"> @@ -177,10 +171,6 @@ an increasing rate constant, supposedly caused by microbial growth</p> <th>r</th> <td><p>Growth rate of the increase in the rate constant.</p></td> </tr> - <tr> - <th>parent.0</th> - <td><p>Starting value for the response variable at time zero.</p></td> - </tr> </table> <h2 class="hasAnchor" id="value"><a class="anchor" href="#value"></a>Value</h2> @@ -190,11 +180,14 @@ an increasing rate constant, supposedly caused by microbial growth</p> <p>The solution of the logistic model reduces to the <code><a href='SFO.solution.html'>SFO.solution</a></code> if <code>k0</code> is equal to <code>kmax</code>.</p> -<p>The solution of the logistic model reduces to the - <code><a href='SFO.solution.html'>SFO.solution</a></code> if <code>k0</code> is equal to <code>kmax</code>.</p> <h2 class="hasAnchor" id="references"><a class="anchor" href="#references"></a>References</h2> - <p>FOCUS (2014) “Generic guidance for Estimating Persistence + <p>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, + <a href='http://esdac.jrc.ec.europa.eu/projects/degradation-kinetics'>http://esdac.jrc.ec.europa.eu/projects/degradation-kinetics</a> +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 @@ -248,44 +241,6 @@ an increasing rate constant, supposedly caused by microbial growth</p> #> r 1.1821120 #> sigma 7.3256566</div><div class='input'> <span class='fu'><a href='endpoints.html'>endpoints</a></span>(<span class='no'>m</span>)$<span class='no'>distimes</span></div><div class='output co'>#> DT50 DT90 DT50_k0 DT50_kmax #> parent 36.86533 62.41511 4297.853 10.83349</div><div class='input'> - - <span class='co'># Reproduce the plot on page 57 of FOCUS (2014)</span> - <span class='fu'><a href='https://rdrr.io/r/base/plot.html'>plot</a></span>(<span class='kw'>function</span>(<span class='no'>x</span>) <span class='fu'>logistic.solution</span>(<span class='no'>x</span>, <span class='fl'>100</span>, <span class='fl'>0.08</span>, <span class='fl'>0.0001</span>, <span class='fl'>0.2</span>), - <span class='kw'>from</span> <span class='kw'>=</span> <span class='fl'>0</span>, <span class='kw'>to</span> <span class='kw'>=</span> <span class='fl'>100</span>, <span class='kw'>ylim</span> <span class='kw'>=</span> <span class='fu'><a href='https://rdrr.io/r/base/c.html'>c</a></span>(<span class='fl'>0</span>, <span class='fl'>100</span>), - <span class='kw'>xlab</span> <span class='kw'>=</span> <span class='st'>"Time"</span>, <span class='kw'>ylab</span> <span class='kw'>=</span> <span class='st'>"Residue"</span>)</div><div class='input'> <span class='fu'><a href='https://rdrr.io/r/base/plot.html'>plot</a></span>(<span class='kw'>function</span>(<span class='no'>x</span>) <span class='fu'>logistic.solution</span>(<span class='no'>x</span>, <span class='fl'>100</span>, <span class='fl'>0.08</span>, <span class='fl'>0.0001</span>, <span class='fl'>0.4</span>), - <span class='kw'>from</span> <span class='kw'>=</span> <span class='fl'>0</span>, <span class='kw'>to</span> <span class='kw'>=</span> <span class='fl'>100</span>, <span class='kw'>add</span> <span class='kw'>=</span> <span class='fl'>TRUE</span>, <span class='kw'>lty</span> <span class='kw'>=</span> <span class='fl'>2</span>, <span class='kw'>col</span> <span class='kw'>=</span> <span class='fl'>2</span>)</div><div class='input'> <span class='fu'><a href='https://rdrr.io/r/base/plot.html'>plot</a></span>(<span class='kw'>function</span>(<span class='no'>x</span>) <span class='fu'>logistic.solution</span>(<span class='no'>x</span>, <span class='fl'>100</span>, <span class='fl'>0.08</span>, <span class='fl'>0.0001</span>, <span class='fl'>0.8</span>), - <span class='kw'>from</span> <span class='kw'>=</span> <span class='fl'>0</span>, <span class='kw'>to</span> <span class='kw'>=</span> <span class='fl'>100</span>, <span class='kw'>add</span> <span class='kw'>=</span> <span class='fl'>TRUE</span>, <span class='kw'>lty</span> <span class='kw'>=</span> <span class='fl'>3</span>, <span class='kw'>col</span> <span class='kw'>=</span> <span class='fl'>3</span>)</div><div class='input'> <span class='fu'><a href='https://rdrr.io/r/base/plot.html'>plot</a></span>(<span class='kw'>function</span>(<span class='no'>x</span>) <span class='fu'>logistic.solution</span>(<span class='no'>x</span>, <span class='fl'>100</span>, <span class='fl'>0.08</span>, <span class='fl'>0.001</span>, <span class='fl'>0.2</span>), - <span class='kw'>from</span> <span class='kw'>=</span> <span class='fl'>0</span>, <span class='kw'>to</span> <span class='kw'>=</span> <span class='fl'>100</span>, <span class='kw'>add</span> <span class='kw'>=</span> <span class='fl'>TRUE</span>, <span class='kw'>lty</span> <span class='kw'>=</span> <span class='fl'>4</span>, <span class='kw'>col</span> <span class='kw'>=</span> <span class='fl'>4</span>)</div><div class='input'> <span class='fu'><a href='https://rdrr.io/r/base/plot.html'>plot</a></span>(<span class='kw'>function</span>(<span class='no'>x</span>) <span class='fu'>logistic.solution</span>(<span class='no'>x</span>, <span class='fl'>100</span>, <span class='fl'>0.08</span>, <span class='fl'>0.08</span>, <span class='fl'>0.2</span>), - <span class='kw'>from</span> <span class='kw'>=</span> <span class='fl'>0</span>, <span class='kw'>to</span> <span class='kw'>=</span> <span class='fl'>100</span>, <span class='kw'>add</span> <span class='kw'>=</span> <span class='fl'>TRUE</span>, <span class='kw'>lty</span> <span class='kw'>=</span> <span class='fl'>5</span>, <span class='kw'>col</span> <span class='kw'>=</span> <span class='fl'>5</span>)</div><div class='input'> <span class='fu'><a href='https://rdrr.io/r/graphics/legend.html'>legend</a></span>(<span class='st'>"topright"</span>, <span class='kw'>inset</span> <span class='kw'>=</span> <span class='fl'>0.05</span>, - <span class='kw'>legend</span> <span class='kw'>=</span> <span class='fu'><a href='https://rdrr.io/r/base/paste.html'>paste0</a></span>(<span class='st'>"k0 = "</span>, <span class='fu'><a href='https://rdrr.io/r/base/c.html'>c</a></span>(<span class='fl'>0.0001</span>, <span class='fl'>0.0001</span>, <span class='fl'>0.0001</span>, <span class='fl'>0.001</span>, <span class='fl'>0.08</span>), - <span class='st'>", r = "</span>, <span class='fu'><a href='https://rdrr.io/r/base/c.html'>c</a></span>(<span class='fl'>0.2</span>, <span class='fl'>0.4</span>, <span class='fl'>0.8</span>, <span class='fl'>0.2</span>, <span class='fl'>0.2</span>)), - <span class='kw'>lty</span> <span class='kw'>=</span> <span class='fl'>1</span>:<span class='fl'>5</span>, <span class='kw'>col</span> <span class='kw'>=</span> <span class='fl'>1</span>:<span class='fl'>5</span>)</div><div class='img'><img src='logistic.solution-3.png' alt='' width='700' height='433' /></div><div class='input'> - <span class='co'># Fit with synthetic data</span> - <span class='no'>logistic</span> <span class='kw'><-</span> <span class='fu'><a href='mkinmod.html'>mkinmod</a></span>(<span class='kw'>parent</span> <span class='kw'>=</span> <span class='fu'><a href='mkinsub.html'>mkinsub</a></span>(<span class='st'>"logistic"</span>)) - - <span class='no'>sampling_times</span> <span class='kw'>=</span> <span class='fu'><a href='https://rdrr.io/r/base/c.html'>c</a></span>(<span class='fl'>0</span>, <span class='fl'>1</span>, <span class='fl'>3</span>, <span class='fl'>7</span>, <span class='fl'>14</span>, <span class='fl'>28</span>, <span class='fl'>60</span>, <span class='fl'>90</span>, <span class='fl'>120</span>) - <span class='no'>parms_logistic</span> <span class='kw'><-</span> <span class='fu'><a href='https://rdrr.io/r/base/c.html'>c</a></span>(<span class='kw'>kmax</span> <span class='kw'>=</span> <span class='fl'>0.08</span>, <span class='kw'>k0</span> <span class='kw'>=</span> <span class='fl'>0.0001</span>, <span class='kw'>r</span> <span class='kw'>=</span> <span class='fl'>0.2</span>) - <span class='no'>d_logistic</span> <span class='kw'><-</span> <span class='fu'><a href='mkinpredict.html'>mkinpredict</a></span>(<span class='no'>logistic</span>, - <span class='no'>parms_logistic</span>, <span class='fu'><a href='https://rdrr.io/r/base/c.html'>c</a></span>(<span class='kw'>parent</span> <span class='kw'>=</span> <span class='fl'>100</span>), - <span class='no'>sampling_times</span>) - <span class='no'>d_2_1</span> <span class='kw'><-</span> <span class='fu'><a href='add_err.html'>add_err</a></span>(<span class='no'>d_logistic</span>, - <span class='kw'>sdfunc</span> <span class='kw'>=</span> <span class='kw'>function</span>(<span class='no'>x</span>) <span class='fu'><a href='sigma_twocomp.html'>sigma_twocomp</a></span>(<span class='no'>x</span>, <span class='fl'>0.5</span>, <span class='fl'>0.07</span>), - <span class='kw'>n</span> <span class='kw'>=</span> <span class='fl'>1</span>, <span class='kw'>reps</span> <span class='kw'>=</span> <span class='fl'>2</span>, <span class='kw'>digits</span> <span class='kw'>=</span> <span class='fl'>5</span>, <span class='kw'>LOD</span> <span class='kw'>=</span> <span class='fl'>0.1</span>, <span class='kw'>seed</span> <span class='kw'>=</span> <span class='fl'>123456</span>)<span class='kw'>[[</span><span class='fl'>1</span>]] - - <span class='no'>m</span> <span class='kw'><-</span> <span class='fu'><a href='mkinfit.html'>mkinfit</a></span>(<span class='st'>"logistic"</span>, <span class='no'>d_2_1</span>, <span class='kw'>quiet</span> <span class='kw'>=</span> <span class='fl'>TRUE</span>) - <span class='fu'><a href='plot.mkinfit.html'>plot_sep</a></span>(<span class='no'>m</span>)</div><div class='img'><img src='logistic.solution-4.png' alt='' width='700' height='433' /></div><div class='input'> <span class='fu'><a href='https://rdrr.io/r/base/summary.html'>summary</a></span>(<span class='no'>m</span>)$<span class='no'>bpar</span></div><div class='output co'>#> 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</div><div class='input'> <span class='fu'><a href='endpoints.html'>endpoints</a></span>(<span class='no'>m</span>)$<span class='no'>distimes</span></div><div class='output co'>#> DT50 DT90 DT50_k0 DT50_kmax -#> parent 36.86533 62.41511 4297.853 10.83349</div><div class='input'> </div></pre> </div> <div class="col-md-3 hidden-xs hidden-sm" id="pkgdown-sidebar"> 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." /> </button> <span class="navbar-brand"> <a class="navbar-link" href="../index.html">mkin</a> - <span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Released version">0.9.49.11</span> + <span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Released version">0.9.50</span> </span> </div> @@ -152,7 +152,7 @@ list of lists can be given in the speclist argument.</p> <pre class="usage"><span class='fu'>mkinmod</span>( <span class='no'>...</span>, - <span class='kw'>use_of_ff</span> <span class='kw'>=</span> <span class='st'>"min"</span>, + <span class='kw'>use_of_ff</span> <span class='kw'>=</span> <span class='st'>"max"</span>, <span class='kw'>speclist</span> <span class='kw'>=</span> <span class='kw'>NULL</span>, <span class='kw'>quiet</span> <span class='kw'>=</span> <span class='fl'>FALSE</span>, <span class='kw'>verbose</span> <span class='kw'>=</span> <span class='fl'>FALSE</span> @@ -252,15 +252,15 @@ in the FOCUS and NAFTA guidance documents are used.</p> <span class='no'>SFO_SFO</span> <span class='kw'><-</span> <span class='fu'>mkinmod</span>( <span class='kw'>parent</span> <span class='kw'>=</span> <span class='fu'><a href='mkinsub.html'>mkinsub</a></span>(<span class='st'>"SFO"</span>, <span class='st'>"m1"</span>), <span class='kw'>m1</span> <span class='kw'>=</span> <span class='fu'><a href='mkinsub.html'>mkinsub</a></span>(<span class='st'>"SFO"</span>), <span class='kw'>verbose</span> <span class='kw'>=</span> <span class='fl'>TRUE</span>)</div><div class='output co'>#> 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.</p> #> 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: }</div><div class='output co'>#> <span class='message'>Successfully compiled differential equation model from auto-generated C code.</span></div><div class='input'> <span class='co'># If we have several parallel metabolites</span> <span class='co'># (compare tests/testthat/test_synthetic_data_for_UBA_2014.R)</span> 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." /> </button> <span class="navbar-brand"> <a class="navbar-link" href="../index.html">mkin</a> - <span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Released version">0.9.49.11</span> + <span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Released version">0.9.50</span> </span> </div> @@ -268,8 +268,29 @@ solver is used.</p></td> <pre class="examples"><div class='input'> <span class='no'>SFO</span> <span class='kw'><-</span> <span class='fu'><a href='mkinmod.html'>mkinmod</a></span>(<span class='kw'>degradinol</span> <span class='kw'>=</span> <span class='fu'><a href='mkinsub.html'>mkinsub</a></span>(<span class='st'>"SFO"</span>)) <span class='co'># Compare solution types</span> -<span class='fu'>mkinpredict</span>(<span class='no'>SFO</span>, <span class='fu'><a href='https://rdrr.io/r/base/c.html'>c</a></span>(<span class='kw'>k_degradinol_sink</span> <span class='kw'>=</span> <span class='fl'>0.3</span>), <span class='fu'><a href='https://rdrr.io/r/base/c.html'>c</a></span>(<span class='kw'>degradinol</span> <span class='kw'>=</span> <span class='fl'>100</span>), <span class='fl'>0</span>:<span class='fl'>20</span>, - <span class='kw'>solution_type</span> <span class='kw'>=</span> <span class='st'>"analytical"</span>)</div><div class='output co'>#> <span class='error'>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)</span></div><div class='input'><span class='fu'>mkinpredict</span>(<span class='no'>SFO</span>, <span class='fu'><a href='https://rdrr.io/r/base/c.html'>c</a></span>(<span class='kw'>k_degradinol_sink</span> <span class='kw'>=</span> <span class='fl'>0.3</span>), <span class='fu'><a href='https://rdrr.io/r/base/c.html'>c</a></span>(<span class='kw'>degradinol</span> <span class='kw'>=</span> <span class='fl'>100</span>), <span class='fl'>0</span>:<span class='fl'>20</span>, +<span class='fu'>mkinpredict</span>(<span class='no'>SFO</span>, <span class='fu'><a href='https://rdrr.io/r/base/c.html'>c</a></span>(<span class='kw'>k_degradinol</span> <span class='kw'>=</span> <span class='fl'>0.3</span>), <span class='fu'><a href='https://rdrr.io/r/base/c.html'>c</a></span>(<span class='kw'>degradinol</span> <span class='kw'>=</span> <span class='fl'>100</span>), <span class='fl'>0</span>:<span class='fl'>20</span>, + <span class='kw'>solution_type</span> <span class='kw'>=</span> <span class='st'>"analytical"</span>)</div><div class='output co'>#> 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</div><div class='input'><span class='fu'>mkinpredict</span>(<span class='no'>SFO</span>, <span class='fu'><a href='https://rdrr.io/r/base/c.html'>c</a></span>(<span class='kw'>k_degradinol</span> <span class='kw'>=</span> <span class='fl'>0.3</span>), <span class='fu'><a href='https://rdrr.io/r/base/c.html'>c</a></span>(<span class='kw'>degradinol</span> <span class='kw'>=</span> <span class='fl'>100</span>), <span class='fl'>0</span>:<span class='fl'>20</span>, <span class='kw'>solution_type</span> <span class='kw'>=</span> <span class='st'>"deSolve"</span>)</div><div class='output co'>#> time degradinol #> 1 0 100.0000000 #> 2 1 74.0818221 @@ -291,7 +312,7 @@ solver is used.</p></td> #> 18 17 0.6096747 #> 19 18 0.4516581 #> 20 19 0.3345965 -#> 21 20 0.2478752</div><div class='input'><span class='fu'>mkinpredict</span>(<span class='no'>SFO</span>, <span class='fu'><a href='https://rdrr.io/r/base/c.html'>c</a></span>(<span class='kw'>k_degradinol_sink</span> <span class='kw'>=</span> <span class='fl'>0.3</span>), <span class='fu'><a href='https://rdrr.io/r/base/c.html'>c</a></span>(<span class='kw'>degradinol</span> <span class='kw'>=</span> <span class='fl'>100</span>), <span class='fl'>0</span>:<span class='fl'>20</span>, +#> 21 20 0.2478752</div><div class='input'><span class='fu'>mkinpredict</span>(<span class='no'>SFO</span>, <span class='fu'><a href='https://rdrr.io/r/base/c.html'>c</a></span>(<span class='kw'>k_degradinol</span> <span class='kw'>=</span> <span class='fl'>0.3</span>), <span class='fu'><a href='https://rdrr.io/r/base/c.html'>c</a></span>(<span class='kw'>degradinol</span> <span class='kw'>=</span> <span class='fl'>100</span>), <span class='fl'>0</span>:<span class='fl'>20</span>, <span class='kw'>solution_type</span> <span class='kw'>=</span> <span class='st'>"deSolve"</span>, <span class='kw'>use_compiled</span> <span class='kw'>=</span> <span class='fl'>FALSE</span>)</div><div class='output co'>#> time degradinol #> 1 0 100.0000000 #> 2 1 74.0818221 @@ -313,7 +334,7 @@ solver is used.</p></td> #> 18 17 0.6096747 #> 19 18 0.4516581 #> 20 19 0.3345965 -#> 21 20 0.2478752</div><div class='input'><span class='fu'>mkinpredict</span>(<span class='no'>SFO</span>, <span class='fu'><a href='https://rdrr.io/r/base/c.html'>c</a></span>(<span class='kw'>k_degradinol_sink</span> <span class='kw'>=</span> <span class='fl'>0.3</span>), <span class='fu'><a href='https://rdrr.io/r/base/c.html'>c</a></span>(<span class='kw'>degradinol</span> <span class='kw'>=</span> <span class='fl'>100</span>), <span class='fl'>0</span>:<span class='fl'>20</span>, +#> 21 20 0.2478752</div><div class='input'><span class='fu'>mkinpredict</span>(<span class='no'>SFO</span>, <span class='fu'><a href='https://rdrr.io/r/base/c.html'>c</a></span>(<span class='kw'>k_degradinol</span> <span class='kw'>=</span> <span class='fl'>0.3</span>), <span class='fu'><a href='https://rdrr.io/r/base/c.html'>c</a></span>(<span class='kw'>degradinol</span> <span class='kw'>=</span> <span class='fl'>100</span>), <span class='fl'>0</span>:<span class='fl'>20</span>, <span class='kw'>solution_type</span> <span class='kw'>=</span> <span class='st'>"eigen"</span>)</div><div class='output co'>#> time degradinol #> 1 0 100.0000000 #> 2 1 74.0818221 @@ -337,25 +358,26 @@ solver is used.</p></td> #> 20 19 0.3345965 #> 21 20 0.2478752</div><div class='input'> <span class='co'># Compare integration methods to analytical solution</span> -<span class='fu'>mkinpredict</span>(<span class='no'>SFO</span>, <span class='fu'><a href='https://rdrr.io/r/base/c.html'>c</a></span>(<span class='kw'>k_degradinol_sink</span> <span class='kw'>=</span> <span class='fl'>0.3</span>), <span class='fu'><a href='https://rdrr.io/r/base/c.html'>c</a></span>(<span class='kw'>degradinol</span> <span class='kw'>=</span> <span class='fl'>100</span>), <span class='fl'>0</span>:<span class='fl'>20</span>, - <span class='kw'>solution_type</span> <span class='kw'>=</span> <span class='st'>"analytical"</span>)[<span class='fl'>21</span>,]</div><div class='output co'>#> <span class='error'>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)</span></div><div class='input'><span class='fu'>mkinpredict</span>(<span class='no'>SFO</span>, <span class='fu'><a href='https://rdrr.io/r/base/c.html'>c</a></span>(<span class='kw'>k_degradinol_sink</span> <span class='kw'>=</span> <span class='fl'>0.3</span>), <span class='fu'><a href='https://rdrr.io/r/base/c.html'>c</a></span>(<span class='kw'>degradinol</span> <span class='kw'>=</span> <span class='fl'>100</span>), <span class='fl'>0</span>:<span class='fl'>20</span>, +<span class='fu'>mkinpredict</span>(<span class='no'>SFO</span>, <span class='fu'><a href='https://rdrr.io/r/base/c.html'>c</a></span>(<span class='kw'>k_degradinol</span> <span class='kw'>=</span> <span class='fl'>0.3</span>), <span class='fu'><a href='https://rdrr.io/r/base/c.html'>c</a></span>(<span class='kw'>degradinol</span> <span class='kw'>=</span> <span class='fl'>100</span>), <span class='fl'>0</span>:<span class='fl'>20</span>, + <span class='kw'>solution_type</span> <span class='kw'>=</span> <span class='st'>"analytical"</span>)[<span class='fl'>21</span>,]</div><div class='output co'>#> time degradinol +#> 21 20 0.2478752</div><div class='input'><span class='fu'>mkinpredict</span>(<span class='no'>SFO</span>, <span class='fu'><a href='https://rdrr.io/r/base/c.html'>c</a></span>(<span class='kw'>k_degradinol</span> <span class='kw'>=</span> <span class='fl'>0.3</span>), <span class='fu'><a href='https://rdrr.io/r/base/c.html'>c</a></span>(<span class='kw'>degradinol</span> <span class='kw'>=</span> <span class='fl'>100</span>), <span class='fl'>0</span>:<span class='fl'>20</span>, <span class='kw'>method</span> <span class='kw'>=</span> <span class='st'>"lsoda"</span>)[<span class='fl'>21</span>,]</div><div class='output co'>#> time degradinol -#> 21 20 0.2478752</div><div class='input'><span class='fu'>mkinpredict</span>(<span class='no'>SFO</span>, <span class='fu'><a href='https://rdrr.io/r/base/c.html'>c</a></span>(<span class='kw'>k_degradinol_sink</span> <span class='kw'>=</span> <span class='fl'>0.3</span>), <span class='fu'><a href='https://rdrr.io/r/base/c.html'>c</a></span>(<span class='kw'>degradinol</span> <span class='kw'>=</span> <span class='fl'>100</span>), <span class='fl'>0</span>:<span class='fl'>20</span>, +#> 21 20 0.2478752</div><div class='input'><span class='fu'>mkinpredict</span>(<span class='no'>SFO</span>, <span class='fu'><a href='https://rdrr.io/r/base/c.html'>c</a></span>(<span class='kw'>k_degradinol</span> <span class='kw'>=</span> <span class='fl'>0.3</span>), <span class='fu'><a href='https://rdrr.io/r/base/c.html'>c</a></span>(<span class='kw'>degradinol</span> <span class='kw'>=</span> <span class='fl'>100</span>), <span class='fl'>0</span>:<span class='fl'>20</span>, <span class='kw'>method</span> <span class='kw'>=</span> <span class='st'>"ode45"</span>)[<span class='fl'>21</span>,]</div><div class='output co'>#> time degradinol -#> 21 20 0.2478752</div><div class='input'><span class='fu'>mkinpredict</span>(<span class='no'>SFO</span>, <span class='fu'><a href='https://rdrr.io/r/base/c.html'>c</a></span>(<span class='kw'>k_degradinol_sink</span> <span class='kw'>=</span> <span class='fl'>0.3</span>), <span class='fu'><a href='https://rdrr.io/r/base/c.html'>c</a></span>(<span class='kw'>degradinol</span> <span class='kw'>=</span> <span class='fl'>100</span>), <span class='fl'>0</span>:<span class='fl'>20</span>, +#> 21 20 0.2478752</div><div class='input'><span class='fu'>mkinpredict</span>(<span class='no'>SFO</span>, <span class='fu'><a href='https://rdrr.io/r/base/c.html'>c</a></span>(<span class='kw'>k_degradinol</span> <span class='kw'>=</span> <span class='fl'>0.3</span>), <span class='fu'><a href='https://rdrr.io/r/base/c.html'>c</a></span>(<span class='kw'>degradinol</span> <span class='kw'>=</span> <span class='fl'>100</span>), <span class='fl'>0</span>:<span class='fl'>20</span>, <span class='kw'>method</span> <span class='kw'>=</span> <span class='st'>"rk4"</span>)[<span class='fl'>21</span>,]</div><div class='output co'>#> time degradinol #> 21 20 0.2480043</div><div class='input'><span class='co'># rk4 is not as precise here</span> <span class='co'># The number of output times used to make a lot of difference until the</span> <span class='co'># default for atol was adjusted</span> -<span class='fu'>mkinpredict</span>(<span class='no'>SFO</span>, <span class='fu'><a href='https://rdrr.io/r/base/c.html'>c</a></span>(<span class='kw'>k_degradinol_sink</span> <span class='kw'>=</span> <span class='fl'>0.3</span>), <span class='fu'><a href='https://rdrr.io/r/base/c.html'>c</a></span>(<span class='kw'>degradinol</span> <span class='kw'>=</span> <span class='fl'>100</span>), +<span class='fu'>mkinpredict</span>(<span class='no'>SFO</span>, <span class='fu'><a href='https://rdrr.io/r/base/c.html'>c</a></span>(<span class='kw'>k_degradinol</span> <span class='kw'>=</span> <span class='fl'>0.3</span>), <span class='fu'><a href='https://rdrr.io/r/base/c.html'>c</a></span>(<span class='kw'>degradinol</span> <span class='kw'>=</span> <span class='fl'>100</span>), <span class='fu'><a href='https://rdrr.io/r/base/seq.html'>seq</a></span>(<span class='fl'>0</span>, <span class='fl'>20</span>, <span class='kw'>by</span> <span class='kw'>=</span> <span class='fl'>0.1</span>))[<span class='fl'>201</span>,]</div><div class='output co'>#> time degradinol -#> 201 20 0.2478752</div><div class='input'><span class='fu'>mkinpredict</span>(<span class='no'>SFO</span>, <span class='fu'><a href='https://rdrr.io/r/base/c.html'>c</a></span>(<span class='kw'>k_degradinol_sink</span> <span class='kw'>=</span> <span class='fl'>0.3</span>), <span class='fu'><a href='https://rdrr.io/r/base/c.html'>c</a></span>(<span class='kw'>degradinol</span> <span class='kw'>=</span> <span class='fl'>100</span>), +#> 201 20 0.2478752</div><div class='input'><span class='fu'>mkinpredict</span>(<span class='no'>SFO</span>, <span class='fu'><a href='https://rdrr.io/r/base/c.html'>c</a></span>(<span class='kw'>k_degradinol</span> <span class='kw'>=</span> <span class='fl'>0.3</span>), <span class='fu'><a href='https://rdrr.io/r/base/c.html'>c</a></span>(<span class='kw'>degradinol</span> <span class='kw'>=</span> <span class='fl'>100</span>), <span class='fu'><a href='https://rdrr.io/r/base/seq.html'>seq</a></span>(<span class='fl'>0</span>, <span class='fl'>20</span>, <span class='kw'>by</span> <span class='kw'>=</span> <span class='fl'>0.01</span>))[<span class='fl'>2001</span>,]</div><div class='output co'>#> time degradinol #> 2001 20 0.2478752</div><div class='input'> <span class='co'># Check compiled model versions - they are faster than the eigenvalue based solutions!</span> <span class='no'>SFO_SFO</span> <span class='kw'>=</span> <span class='fu'><a href='mkinmod.html'>mkinmod</a></span>(<span class='kw'>parent</span> <span class='kw'>=</span> <span class='fu'><a href='https://rdrr.io/r/base/list.html'>list</a></span>(<span class='kw'>type</span> <span class='kw'>=</span> <span class='st'>"SFO"</span>, <span class='kw'>to</span> <span class='kw'>=</span> <span class='st'>"m1"</span>), - <span class='kw'>m1</span> <span class='kw'>=</span> <span class='fu'><a href='https://rdrr.io/r/base/list.html'>list</a></span>(<span class='kw'>type</span> <span class='kw'>=</span> <span class='st'>"SFO"</span>))</div><div class='output co'>#> <span class='message'>Successfully compiled differential equation model from auto-generated C code.</span></div><div class='input'><span class='kw'>if</span>(<span class='fu'><a href='https://rdrr.io/r/base/library.html'>require</a></span>(<span class='no'>rbenchmark</span>)) { + <span class='kw'>m1</span> <span class='kw'>=</span> <span class='fu'><a href='https://rdrr.io/r/base/list.html'>list</a></span>(<span class='kw'>type</span> <span class='kw'>=</span> <span class='st'>"SFO"</span>), <span class='kw'>use_of_ff</span> <span class='kw'>=</span> <span class='st'>"min"</span>)</div><div class='output co'>#> <span class='message'>Successfully compiled differential equation model from auto-generated C code.</span></div><div class='input'><span class='kw'>if</span>(<span class='fu'><a href='https://rdrr.io/r/base/library.html'>require</a></span>(<span class='no'>rbenchmark</span>)) { <span class='fu'><a href='https://rdrr.io/pkg/rbenchmark/man/benchmark.html'>benchmark</a></span>( <span class='kw'>eigen</span> <span class='kw'>=</span> <span class='fu'>mkinpredict</span>(<span class='no'>SFO_SFO</span>, <span class='fu'><a href='https://rdrr.io/r/base/c.html'>c</a></span>(<span class='kw'>k_parent_m1</span> <span class='kw'>=</span> <span class='fl'>0.05</span>, <span class='kw'>k_parent_sink</span> <span class='kw'>=</span> <span class='fl'>0.1</span>, <span class='kw'>k_m1_sink</span> <span class='kw'>=</span> <span class='fl'>0.01</span>), <span class='fu'><a href='https://rdrr.io/r/base/c.html'>c</a></span>(<span class='kw'>parent</span> <span class='kw'>=</span> <span class='fl'>100</span>, <span class='kw'>m1</span> <span class='kw'>=</span> <span class='fl'>0</span>), <span class='fu'><a href='https://rdrr.io/r/base/seq.html'>seq</a></span>(<span class='fl'>0</span>, <span class='fl'>20</span>, <span class='kw'>by</span> <span class='kw'>=</span> <span class='fl'>0.1</span>), @@ -371,7 +393,7 @@ solver is used.</p></td> }</div><div class='output co'>#> <span class='message'>Lade nötiges Paket: rbenchmark</span></div><div class='output co'>#> 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 Binary files differindex 68ccb43f..8db1f999 100644 --- a/docs/reference/nlme-1.png +++ b/docs/reference/nlme-1.png 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 @@ <!-- jquery --> -<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js" integrity="sha256-FgpCb/KJQlLNfOu91ta32o/NMZxltwRo8QtmkMRdAu8=" crossorigin="anonymous"></script> +<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.4.1/jquery.min.js" integrity="sha256-CSXorXvZcTkaix6Yvo6HppcZGetbYMGWSFlBw8HfCJo=" crossorigin="anonymous"></script> <!-- Bootstrap --> -<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/3.3.7/css/bootstrap.min.css" integrity="sha256-916EbMg70RQy9LHiGkXzG8hSg9EdNy97GazNG/aiY1w=" crossorigin="anonymous" /> +<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/3.4.1/css/bootstrap.min.css" integrity="sha256-bZLfwXAP04zRMK2BjiO8iu9pf4FbLqX6zitd+tIvLhE=" crossorigin="anonymous" /> -<script src="https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/3.3.7/js/bootstrap.min.js" integrity="sha256-U5ZEeKfGNOja007MMD3YBI0A3OSZOQbeG6z2f2Y0hu8=" crossorigin="anonymous"></script> +<script src="https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/3.4.1/js/bootstrap.min.js" integrity="sha256-nuL8/2cJ5NDSSwnKD8VqreErSWHtnEP9E7AySL+1ev4=" crossorigin="anonymous"></script> + +<!-- bootstrap-toc --> +<link rel="stylesheet" href="../bootstrap-toc.css"> +<script src="../bootstrap-toc.js"></script> <!-- Font Awesome icons --> -<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/5.7.1/css/all.min.css" integrity="sha256-nAmazAk6vS34Xqo0BSrTb+abbtFlgsFK7NKSi6o7Y78=" crossorigin="anonymous" /> -<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/5.7.1/css/v4-shims.min.css" integrity="sha256-6qHlizsOWFskGlwVOKuns+D1nB6ssZrHQrNj1wGplHc=" crossorigin="anonymous" /> +<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/5.12.1/css/all.min.css" integrity="sha256-mmgLkCYLUQbXn0B1SRqzHar6dCnv9oZFPEC1g1cwlkk=" crossorigin="anonymous" /> +<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/5.12.1/css/v4-shims.min.css" integrity="sha256-wZjR52fzng1pJHwx4aV2AO3yyTOXrcDW7jBpJtTwVxw=" crossorigin="anonymous" /> <!-- clipboard.js --> -<script src="https://cdnjs.cloudflare.com/ajax/libs/clipboard.js/2.0.4/clipboard.min.js" integrity="sha256-FiZwavyI2V6+EXO1U+xzLG3IKldpiTFf3153ea9zikQ=" crossorigin="anonymous"></script> +<script src="https://cdnjs.cloudflare.com/ajax/libs/clipboard.js/2.0.6/clipboard.min.js" integrity="sha256-inc5kl9MA1hkeYUt+EC3BhlIgyp/2jDIyBLS6k3UxPI=" crossorigin="anonymous"></script> <!-- headroom.js --> -<script src="https://cdnjs.cloudflare.com/ajax/libs/headroom/0.9.4/headroom.min.js" integrity="sha256-DJFC1kqIhelURkuza0AvYal5RxMtpzLjFhsnVIeuk+U=" crossorigin="anonymous"></script> -<script src="https://cdnjs.cloudflare.com/ajax/libs/headroom/0.9.4/jQuery.headroom.min.js" integrity="sha256-ZX/yNShbjqsohH1k95liqY9Gd8uOiE1S4vZc+9KQ1K4=" crossorigin="anonymous"></script> +<script src="https://cdnjs.cloudflare.com/ajax/libs/headroom/0.11.0/headroom.min.js" integrity="sha256-AsUX4SJE1+yuDu5+mAVzJbuYNPHj/WroHuZ8Ir/CkE0=" crossorigin="anonymous"></script> +<script src="https://cdnjs.cloudflare.com/ajax/libs/headroom/0.11.0/jQuery.headroom.min.js" integrity="sha256-ZX/yNShbjqsohH1k95liqY9Gd8uOiE1S4vZc+9KQ1K4=" crossorigin="anonymous"></script> <!-- pkgdown --> <link href="../pkgdown.css" rel="stylesheet"> @@ -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." /> -<meta name="twitter:card" content="summary" /> @@ -58,7 +61,7 @@ datasets." /> </head> - <body> + <body data-spy="scroll" data-target="#toc"> <div class="container template-reference-topic"> <header> <div class="navbar navbar-default navbar-fixed-top" role="navigation"> @@ -72,7 +75,7 @@ datasets." /> </button> <span class="navbar-brand"> <a class="navbar-link" href="../index.html">mkin</a> - <span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Released version">0.9.49.10</span> + <span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Released version">0.9.50</span> </span> </div> @@ -116,7 +119,12 @@ datasets." /> </li> </ul> <ul class="nav navbar-nav navbar-right"> - + <li> + <a href="http://github.com/jranke/mkin/"> + <span class="fab fa fab fa-github fa-lg"></span> + + </a> +</li> </ul> </div><!--/.nav-collapse --> @@ -131,7 +139,7 @@ datasets." /> <div class="col-md-9 contents"> <div class="page-header"> <h1>Helper functions to create nlme models from mmkin row objects</h1> - + <small class="dont-index">Source: <a href='http://github.com/jranke/mkin/blob/master/R/nlme.R'><code>R/nlme.R</code></a></small> <div class="hidden name"><code>nlme.Rd</code></div> </div> @@ -177,15 +185,15 @@ datasets.</p> <pre class="examples"><div class='input'><span class='no'>sampling_times</span> <span class='kw'>=</span> <span class='fu'><a href='https://rdrr.io/r/base/c.html'>c</a></span>(<span class='fl'>0</span>, <span class='fl'>1</span>, <span class='fl'>3</span>, <span class='fl'>7</span>, <span class='fl'>14</span>, <span class='fl'>28</span>, <span class='fl'>60</span>, <span class='fl'>90</span>, <span class='fl'>120</span>) <span class='no'>m_SFO</span> <span class='kw'><-</span> <span class='fu'><a href='mkinmod.html'>mkinmod</a></span>(<span class='kw'>parent</span> <span class='kw'>=</span> <span class='fu'><a href='mkinsub.html'>mkinsub</a></span>(<span class='st'>"SFO"</span>)) <span class='no'>d_SFO_1</span> <span class='kw'><-</span> <span class='fu'><a href='mkinpredict.html'>mkinpredict</a></span>(<span class='no'>m_SFO</span>, - <span class='fu'><a href='https://rdrr.io/r/base/c.html'>c</a></span>(<span class='kw'>k_parent_sink</span> <span class='kw'>=</span> <span class='fl'>0.1</span>), + <span class='fu'><a href='https://rdrr.io/r/base/c.html'>c</a></span>(<span class='kw'>k_parent</span> <span class='kw'>=</span> <span class='fl'>0.1</span>), <span class='fu'><a href='https://rdrr.io/r/base/c.html'>c</a></span>(<span class='kw'>parent</span> <span class='kw'>=</span> <span class='fl'>98</span>), <span class='no'>sampling_times</span>) <span class='no'>d_SFO_1_long</span> <span class='kw'><-</span> <span class='fu'><a href='mkin_wide_to_long.html'>mkin_wide_to_long</a></span>(<span class='no'>d_SFO_1</span>, <span class='kw'>time</span> <span class='kw'>=</span> <span class='st'>"time"</span>) <span class='no'>d_SFO_2</span> <span class='kw'><-</span> <span class='fu'><a href='mkinpredict.html'>mkinpredict</a></span>(<span class='no'>m_SFO</span>, - <span class='fu'><a href='https://rdrr.io/r/base/c.html'>c</a></span>(<span class='kw'>k_parent_sink</span> <span class='kw'>=</span> <span class='fl'>0.05</span>), + <span class='fu'><a href='https://rdrr.io/r/base/c.html'>c</a></span>(<span class='kw'>k_parent</span> <span class='kw'>=</span> <span class='fl'>0.05</span>), <span class='fu'><a href='https://rdrr.io/r/base/c.html'>c</a></span>(<span class='kw'>parent</span> <span class='kw'>=</span> <span class='fl'>102</span>), <span class='no'>sampling_times</span>) <span class='no'>d_SFO_2_long</span> <span class='kw'><-</span> <span class='fu'><a href='mkin_wide_to_long.html'>mkin_wide_to_long</a></span>(<span class='no'>d_SFO_2</span>, <span class='kw'>time</span> <span class='kw'>=</span> <span class='st'>"time"</span>) <span class='no'>d_SFO_3</span> <span class='kw'><-</span> <span class='fu'><a href='mkinpredict.html'>mkinpredict</a></span>(<span class='no'>m_SFO</span>, - <span class='fu'><a href='https://rdrr.io/r/base/c.html'>c</a></span>(<span class='kw'>k_parent_sink</span> <span class='kw'>=</span> <span class='fl'>0.02</span>), + <span class='fu'><a href='https://rdrr.io/r/base/c.html'>c</a></span>(<span class='kw'>k_parent</span> <span class='kw'>=</span> <span class='fl'>0.02</span>), <span class='fu'><a href='https://rdrr.io/r/base/c.html'>c</a></span>(<span class='kw'>parent</span> <span class='kw'>=</span> <span class='fl'>103</span>), <span class='no'>sampling_times</span>) <span class='no'>d_SFO_3_long</span> <span class='kw'><-</span> <span class='fu'><a href='mkin_wide_to_long.html'>mkin_wide_to_long</a></span>(<span class='no'>d_SFO_3</span>, <span class='kw'>time</span> <span class='kw'>=</span> <span class='st'>"time"</span>) @@ -214,42 +222,37 @@ datasets.</p> #> 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 </div><div class='input'><span class='fu'><a href='https://rdrr.io/r/graphics/plot.html'>plot</a></span>(<span class='fu'><a href='https://rdrr.io/pkg/nlme/man/augPred.html'>augPred</a></span>(<span class='no'>m_nlme</span>, <span class='kw'>level</span> <span class='kw'>=</span> <span class='fl'>0</span>:<span class='fl'>1</span>), <span class='kw'>layout</span> <span class='kw'>=</span> <span class='fu'><a href='https://rdrr.io/r/base/c.html'>c</a></span>(<span class='fl'>3</span>, <span class='fl'>1</span>))</div><div class='img'><img src='nlme-1.png' alt='' width='700' height='433' /></div><div class='input'># augPred does not seem to work on fits with more than one state +#> Number of Observations: 48 +#> Number of Groups: 3 </div><div class='input'><span class='fu'><a href='https://rdrr.io/r/base/plot.html'>plot</a></span>(<span class='fu'><a href='https://rdrr.io/pkg/nlme/man/augPred.html'>augPred</a></span>(<span class='no'>m_nlme</span>, <span class='kw'>level</span> <span class='kw'>=</span> <span class='fl'>0</span>:<span class='fl'>1</span>), <span class='kw'>layout</span> <span class='kw'>=</span> <span class='fu'><a href='https://rdrr.io/r/base/c.html'>c</a></span>(<span class='fl'>3</span>, <span class='fl'>1</span>))</div><div class='img'><img src='nlme-1.png' alt='' width='700' height='433' /></div><div class='input'># augPred does not seem to work on fits with more than one state # variable </div></pre> </div> - <div class="col-md-3 hidden-xs hidden-sm" id="sidebar"> - <h2>Contents</h2> - <ul class="nav nav-pills nav-stacked"> - <li><a href="#arguments">Arguments</a></li> - <li><a href="#value">Value</a></li> - <li><a href="#see-also">See also</a></li> - <li><a href="#examples">Examples</a></li> - </ul> - + <div class="col-md-3 hidden-xs hidden-sm" id="pkgdown-sidebar"> + <nav id="toc" data-toggle="toc" class="sticky-top"> + <h2 data-toc-skip>Contents</h2> + </nav> </div> </div> @@ -260,7 +263,7 @@ datasets.</p> </div> <div class="pkgdown"> - <p>Site built with <a href="https://pkgdown.r-lib.org/">pkgdown</a> 1.4.1.</p> + <p>Site built with <a href="https://pkgdown.r-lib.org/">pkgdown</a> 1.5.1.</p> </div> </footer> diff --git a/docs/sitemap.xml b/docs/sitemap.xml index 5abcc894..81368436 100644 --- a/docs/sitemap.xml +++ b/docs/sitemap.xml @@ -61,6 +61,9 @@ <loc>https://pkgdown.jrwb.de/mkin/reference/confint.mkinfit.html</loc> </url> <url> + <loc>https://pkgdown.jrwb.de/mkin/reference/create_deg_func.html</loc> + </url> + <url> <loc>https://pkgdown.jrwb.de/mkin/reference/endpoints.html</loc> </url> <url> 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,12 +1,10 @@ % 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{ \item{t}{Time.} @@ -18,8 +16,6 @@ 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}. @@ -27,16 +23,10 @@ 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}. } \examples{ @@ -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") @@ -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 @@ <mkinmod> 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 @@ -15,16 +15,20 @@ test_that("Fitting the SFORB model is equivalent to fitting DFOP", { 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) } |