diff options
-rw-r--r-- | R/parent_solutions.R | 128 | ||||
-rw-r--r-- | log/test.log | 40 | ||||
-rw-r--r-- | man/FOMC.solution.Rd | 4 | ||||
-rw-r--r-- | man/IORE.solution.Rd | 4 |
4 files changed, 88 insertions, 88 deletions
diff --git a/R/parent_solutions.R b/R/parent_solutions.R index 04226b73..f11cbff9 100644 --- a/R/parent_solutions.R +++ b/R/parent_solutions.R @@ -7,7 +7,7 @@ #' @param parent_0 Starting value for the response variable at time zero. #' @param k Kinetic rate constant. #' @return The value of the response variable at time \code{t}. -#' @references +#' @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, @@ -25,33 +25,33 @@ #' @export SFO.solution <- function(t, parent_0, k) { - parent = parent_0 * exp(-k * t) + parent = parent_0 * exp(-k * t) } #' First-Order Multi-Compartment kinetics -#' +#' #' Function describing exponential decline from a defined starting value, with #' a decreasing rate constant. -#' +#' #' The form given here differs slightly from the original reference by #' Gustafson and Holden (1990). The parameter \code{beta} corresponds to 1/beta #' in the original equation. -#' +#' #' @family parent solutions -#' @inherit SFO.solution +#' @inherit SFO.solution #' @param alpha Shape parameter determined by coefficient of variation of rate -#' constant values. +#' constant values. #' @param beta Location parameter. #' @note The solution of the FOMC kinetic model reduces to the -#' \code{\link{SFO.solution}} for large values of \code{alpha} and -#' \code{beta} with \eqn{k = \frac{\beta}{\alpha}}{k = beta/alpha}. -#' @references +#' \code{\link{SFO.solution}} for large values of \code{alpha} and \code{beta} +#' with \eqn{k = \frac{\beta}{\alpha}}{k = beta/alpha}. +#' @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, @@ -62,119 +62,119 @@ SFO.solution <- function(t, parent_0, k) #' A new model based on spatial variability. \emph{Environmental Science and #' Technology} \bold{24}, 1032-1038 #' @examples -#' +#' #' plot(function(x) FOMC.solution(x, 100, 10, 2), 0, 2, ylim = c(0, 100)) -#' +#' #' @export FOMC.solution <- function(t, parent_0, alpha, beta) { - parent = parent_0 / (t/beta + 1)^alpha + parent = parent_0 / (t/beta + 1)^alpha } #' Indeterminate order rate equation kinetics -#' +#' #' Function describing exponential decline from a defined starting value, with #' a concentration dependent rate constant. -#' +#' #' @family parent solutions -#' @inherit SFO.solution +#' @inherit SFO.solution #' @param k__iore Rate constant. Note that this depends on the concentration -#' units used. +#' units used. #' @param N Exponent describing the nonlinearity of the rate equation #' @note The solution of the IORE kinetic model reduces to the -#' \code{\link{SFO.solution}} if N = 1. The parameters of the IORE model can -#' be transformed to equivalent parameters of the FOMC mode - see the NAFTA -#' guidance for details. +#' \code{\link{SFO.solution}} if N = 1. The parameters of the IORE model can +#' be transformed to equivalent parameters of the FOMC mode - see the NAFTA +#' guidance for details. #' @references NAFTA Technical Working Group on Pesticides (not dated) Guidance -#' for Evaluating and Calculating Degradation Kinetics in Environmental Media +#' for Evaluating and Calculating Degradation Kinetics in Environmental Media #' @examples -#' +#' #' plot(function(x) IORE.solution(x, 100, 0.2, 1.3), 0, 2, ylim = c(0, 100)) #' \dontrun{ #' fit.fomc <- mkinfit("FOMC", FOCUS_2006_C, quiet = TRUE) #' fit.iore <- mkinfit("IORE", FOCUS_2006_C, quiet = TRUE) #' fit.iore.deS <- mkinfit("IORE", FOCUS_2006_C, solution_type = "deSolve", quiet = TRUE) -#' -#' print(data.frame(fit.fomc$par, fit.iore$par, fit.iore.deS$par, +#' +#' print(data.frame(fit.fomc$par, fit.iore$par, fit.iore.deS$par, #' row.names = paste("model par", 1:4))) -#' print(rbind(fomc = endpoints(fit.fomc)$distimes, iore = endpoints(fit.iore)$distimes, +#' print(rbind(fomc = endpoints(fit.fomc)$distimes, iore = endpoints(fit.iore)$distimes, #' iore.deS = endpoints(fit.iore)$distimes)) #' } -#' +#' #' @export IORE.solution <- function(t, parent_0, k__iore, N) { - parent = (parent_0^(1 - N) - (1 - N) * k__iore * t)^(1/(1 - N)) + parent = (parent_0^(1 - N) - (1 - N) * k__iore * t)^(1/(1 - N)) } #' Double First-Order in Parallel kinetics -#' +#' #' Function describing decline from a defined starting value using the sum of #' two exponential decline functions. -#' +#' #' @family parent solutions -#' @inherit SFO.solution +#' @inherit SFO.solution #' @param t Time. #' @param k1 First kinetic constant. #' @param k2 Second kinetic constant. #' @param g Fraction of the starting value declining according to the first -#' kinetic constant. +#' kinetic constant. #' @examples -#' +#' #' plot(function(x) DFOP.solution(x, 100, 5, 0.5, 0.3), 0, 4, ylim = c(0,100)) -#' +#' #' @export DFOP.solution <- function(t, parent_0, k1, k2, g) { - parent = g * parent_0 * exp(-k1 * t) + - (1 - g) * parent_0 * exp(-k2 * t) + parent = g * parent_0 * exp(-k1 * t) + + (1 - g) * parent_0 * exp(-k2 * t) } #' Hockey-Stick kinetics -#' +#' #' Function describing two exponential decline functions with a break point #' between them. -#' +#' #' @family parent solutions -#' @inherit DFOP.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}. +#' \code{k1} is calculated, after this time, exponential decline proceeds +#' according to \code{k2}. #' @examples -#' +#' #' plot(function(x) HS.solution(x, 100, 2, 0.3, 0.5), 0, 2, ylim=c(0,100)) -#' +#' #' @export HS.solution <- function(t, parent_0, k1, k2, tb) { - parent = ifelse(t <= tb, - parent_0 * exp(-k1 * t), - parent_0 * exp(-k1 * tb) * exp(-k2 * (t - tb))) + parent = ifelse(t <= tb, + parent_0 * exp(-k1 * t), + parent_0 * exp(-k1 * tb) * exp(-k2 * (t - tb))) } #' Single First-Order Reversible Binding kinetics -#' +#' #' Function describing the solution of the differential equations describing #' the kinetic model with first-order terms for a two-way transfer from a free #' to a bound fraction, and a first-order degradation term for the free #' fraction. The initial condition is a defined amount in the free fraction #' and no substance in the bound fraction. -#' +#' #' @family parent solutions -#' @inherit SFO.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 -#' fraction. +#' fraction. #' @return The value of the response variable, which is the sum of free and -#' bound fractions at time \code{t}. +#' bound fractions at time \code{t}. #' @examples -#' +#' #' \dontrun{plot(function(x) SFORB.solution(x, 100, 0.5, 2, 3), 0, 2)} -#' +#' #' @export SFORB.solution = function(t, parent_0, k_12, k_21, k_1output) { - sqrt_exp = sqrt(1/4 * (k_12 + k_21 + k_1output)^2 + k_12 * k_21 - (k_12 + k_1output) * k_21) + sqrt_exp = sqrt(1/4 * (k_12 + k_21 + k_1output)^2 - k_1output * k_21) b1 = 0.5 * (k_12 + k_21 + k_1output) + sqrt_exp b2 = 0.5 * (k_12 + k_21 + k_1output) - sqrt_exp @@ -184,19 +184,19 @@ SFORB.solution = function(t, parent_0, k_12, k_21, k_1output) { } #' Logistic kinetics -#' +#' #' Function describing exponential decline from a defined starting value, with #' an increasing rate constant, supposedly caused by microbial growth -#' +#' #' @family parent solutions -#' @inherit SFO.solution +#' @inherit SFO.solution #' @param kmax Maximum rate constant. #' @param k0 Minimum rate constant effective at time zero. #' @param r Growth rate of the increase in the rate constant. #' @note The solution of the logistic model reduces to the -#' \code{\link{SFO.solution}} if \code{k0} is equal to \code{kmax}. +#' \code{\link{SFO.solution}} if \code{k0} is equal to \code{kmax}. #' @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), @@ -213,10 +213,10 @@ SFORB.solution = function(t, parent_0, k_12, k_21, k_1output) { #' 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, @@ -225,14 +225,14 @@ SFORB.solution = function(t, parent_0, k_12, k_21, k_1output) { #' 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) + parent = parent_0 * (kmax / (kmax - k0 + k0 * exp (r * t))) ^(kmax/r) } diff --git a/log/test.log b/log/test.log index 95d50017..52b92245 100644 --- a/log/test.log +++ b/log/test.log @@ -1,53 +1,53 @@ ℹ Testing mkin ✔ | F W S OK | Context ✔ | 5 | AIC calculation -✔ | 5 | Analytical solutions for coupled models [3.4s] +✔ | 5 | Analytical solutions for coupled models [3.3s] ✔ | 5 | Calculation of Akaike weights ✔ | 3 | Export dataset for reading into CAKE ✔ | 12 | Confidence intervals and p-values [1.0s] -✔ | 1 12 | Dimethenamid data from 2018 [33.0s] +✔ | 1 12 | Dimethenamid data from 2018 [31.5s] ──────────────────────────────────────────────────────────────────────────────── Skip (test_dmta.R:98:3): Different backends get consistent results for SFO-SFO3+, dimethenamid data Reason: Fitting this ODE model with saemix takes about 15 minutes on my system ──────────────────────────────────────────────────────────────────────────────── -✔ | 14 | Error model fitting [5.6s] +✔ | 14 | Error model fitting [4.9s] ✔ | 5 | Time step normalisation ✔ | 4 | Calculation of FOCUS chi2 error levels [0.6s] -✔ | 14 | Results for FOCUS D established in expertise for UBA (Ranke 2014) [0.9s] +✔ | 14 | Results for FOCUS D established in expertise for UBA (Ranke 2014) [0.8s] ✔ | 4 | Test fitting the decline of metabolites from their maximum [0.4s] ✔ | 1 | Fitting the logistic model [0.2s] -✔ | 10 | Batch fitting and diagnosing hierarchical kinetic models [26.9s] +✔ | 10 | Batch fitting and diagnosing hierarchical kinetic models [23.7s] ✔ | 1 12 | Nonlinear mixed-effects models [0.3s] ──────────────────────────────────────────────────────────────────────────────── Skip (test_mixed.R:74:3): saemix results are reproducible for biphasic fits Reason: Fitting with saemix takes around 10 minutes when using deSolve ──────────────────────────────────────────────────────────────────────────────── ✔ | 3 | Test dataset classes mkinds and mkindsg -✔ | 10 | Special cases of mkinfit calls [0.6s] -✔ | 3 | mkinfit features [0.8s] -✔ | 8 | mkinmod model generation and printing [0.3s] -✔ | 3 | Model predictions with mkinpredict [0.4s] -✔ | 7 | Multistart method for saem.mmkin models [44.7s] -✔ | 16 | Evaluations according to 2015 NAFTA guidance [2.8s] -✔ | 9 | Nonlinear mixed-effects models with nlme [9.9s] -✔ | 16 | Plotting [10.5s] +✔ | 10 | Special cases of mkinfit calls [0.5s] +✔ | 3 | mkinfit features [0.7s] +✔ | 8 | mkinmod model generation and printing [0.2s] +✔ | 3 | Model predictions with mkinpredict [0.3s] +✔ | 7 | Multistart method for saem.mmkin models [36.3s] +✔ | 16 | Evaluations according to 2015 NAFTA guidance [2.3s] +✔ | 9 | Nonlinear mixed-effects models with nlme [8.9s] +✔ | 16 | Plotting [10.0s] ✔ | 4 | Residuals extracted from mkinfit models -✔ | 1 37 | saemix parent models [76.1s] +✔ | 1 37 | saemix parent models [72.0s] ──────────────────────────────────────────────────────────────────────────────── Skip (test_saemix_parent.R:153:3): We can also use mkin solution methods for saem Reason: This still takes almost 2.5 minutes although we do not solve ODEs ──────────────────────────────────────────────────────────────────────────────── -✔ | 2 | Complex test case from Schaefer et al. (2007) Piacenza paper [1.5s] +✔ | 2 | Complex test case from Schaefer et al. (2007) Piacenza paper [1.4s] ✔ | 11 | Processing of residue series -✔ | 7 | Fitting the SFORB model [3.9s] +✔ | 7 | Fitting the SFORB model [3.7s] ✔ | 1 | Summaries of old mkinfit objects ✔ | 5 | Summary [0.2s] -✔ | 4 | Results for synthetic data established in expertise for UBA (Ranke 2014) [2.3s] -✔ | 9 | Hypothesis tests [8.4s] -✔ | 4 | Calculation of maximum time weighted average concentrations (TWAs) [2.2s] +✔ | 4 | Results for synthetic data established in expertise for UBA (Ranke 2014) [2.2s] +✔ | 9 | Hypothesis tests [8.1s] +✔ | 4 | Calculation of maximum time weighted average concentrations (TWAs) [2.4s] ══ Results ═════════════════════════════════════════════════════════════════════ -Duration: 237.3 s +Duration: 216.5 s ── Skipped tests ────────────────────────────────────────────────────────────── • Fitting this ODE model with saemix takes about 15 minutes on my system (1) diff --git a/man/FOMC.solution.Rd b/man/FOMC.solution.Rd index eeee85f9..d645113c 100644 --- a/man/FOMC.solution.Rd +++ b/man/FOMC.solution.Rd @@ -30,8 +30,8 @@ in the original equation. } \note{ The solution of the FOMC kinetic model reduces to the -\code{\link{SFO.solution}} for large values of \code{alpha} and -\code{beta} with \eqn{k = \frac{\beta}{\alpha}}{k = beta/alpha}. +\code{\link{SFO.solution}} for large values of \code{alpha} and \code{beta} +with \eqn{k = \frac{\beta}{\alpha}}{k = beta/alpha}. } \examples{ diff --git a/man/IORE.solution.Rd b/man/IORE.solution.Rd index 1150f023..5d0126a7 100644 --- a/man/IORE.solution.Rd +++ b/man/IORE.solution.Rd @@ -37,9 +37,9 @@ guidance for details. fit.iore <- mkinfit("IORE", FOCUS_2006_C, quiet = TRUE) fit.iore.deS <- mkinfit("IORE", FOCUS_2006_C, solution_type = "deSolve", quiet = TRUE) - print(data.frame(fit.fomc$par, fit.iore$par, fit.iore.deS$par, + print(data.frame(fit.fomc$par, fit.iore$par, fit.iore.deS$par, row.names = paste("model par", 1:4))) - print(rbind(fomc = endpoints(fit.fomc)$distimes, iore = endpoints(fit.iore)$distimes, + print(rbind(fomc = endpoints(fit.fomc)$distimes, iore = endpoints(fit.iore)$distimes, iore.deS = endpoints(fit.iore)$distimes)) } |