From 92bd33824bde6b6b21bfc7e30953092a74d3cce5 Mon Sep 17 00:00:00 2001
From: Johannes Ranke Support SFORB with formation fractions ‘mkinmod’: Make ‘use_of_ff’ = “max” the default Implement analytical solutions for some coupled models, e.g. SFO-SFO, DFOP-SFO, SFORB-SFO
-
t | +Time. |
+
---|---|
parent_0 | +Starting value for the response variable at time zero. |
+
k1 | +First kinetic constant. |
+
k2 | +Second kinetic constant. |
+
tb | Break point. Before this time, exponential decline according to
@@ -159,6 +175,21 @@ according to |
The value of the response variable at time t
.
FOCUS (2006) “Guidance Document on Estimating Persistence + and Degradation Kinetics from Environmental Fate Studies on Pesticides in + EU Registration” Report of the FOCUS Work Group on Degradation Kinetics, + EC Document Reference Sanco/10058/2005 version 2.0, 434 pp, + http://esdac.jrc.ec.europa.eu/projects/degradation-kinetics +FOCUS (2014) “Generic guidance for Estimating Persistence + and Degradation Kinetics from Environmental Fate Studies on Pesticides in + EU Registration” Report of the FOCUS Work Group on Degradation Kinetics, + Version 1.1, 18 December 2014 + http://esdac.jrc.ec.europa.eu/projects/degradation-kinetics
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 @@
t | +Time. |
+ ||||
---|---|---|---|---|---|
parent_0 | +Starting value for the response variable at time zero. |
+ ||||
k_12 | Kinetic constant describing transfer from free to bound. |
@@ -176,6 +184,18 @@ fraction.
spec | +List of model specifications as contained in mkinmod objects |
+
---|---|
use_of_ff | +Minimum or maximum use of formation fractions |
+
Degradation function to be attached to mkinmod objects
+ ++#>#> Warning: Observations with value of zero were removed from the data
Logistic kinetics
R/logistic.solution.R
, R/parent_solutions.R
+ Source: R/parent_solutions.R
logistic.solution.Rd
Function describing exponential decline from a defined starting value, with -an increasing rate constant, supposedly caused by microbial growth
-Function describing exponential decline from a defined starting value, with an increasing rate constant, supposedly caused by microbial growth
logistic.solution(t, parent_0, kmax, k0, r) - -logistic.solution(t, parent_0, kmax, k0, r)+
logistic.solution(t, parent_0, kmax, k0, r)
r | Growth rate of the increase in the rate constant. |
-
---|---|
parent.0 | -Starting value for the response variable at time zero. |
-
The solution of the logistic model reduces to the
- SFO.solution
if k0
is equal to kmax
.
The solution of the logistic model reduces to the
SFO.solution
if k0
is equal to kmax
.
FOCUS (2014) “Generic guidance for Estimating Persistence +
FOCUS (2006) “Guidance Document on Estimating Persistence + and Degradation Kinetics from Environmental Fate Studies on Pesticides in + EU Registration” Report of the FOCUS Work Group on Degradation Kinetics, + EC Document Reference Sanco/10058/2005 version 2.0, 434 pp, + http://esdac.jrc.ec.europa.eu/projects/degradation-kinetics +FOCUS (2014) “Generic guidance for Estimating Persistence and Degradation Kinetics from Environmental Fate Studies on Pesticides in EU Registration” Report of the FOCUS Work Group on Degradation Kinetics, Version 1.1, 18 December 2014 @@ -247,44 +240,6 @@ an increasing rate constant, supposedly caused by microbial growth
#> k0 0.4448749 #> r 1.1821120 #> sigma 7.3256566mkinmod( ..., - use_of_ff = "min", + use_of_ff = "max", speclist = NULL, quiet = FALSE, verbose = FALSE @@ -252,15 +252,15 @@ in the FOCUS and NAFTA guidance documents are used. SFO_SFO <- mkinmod( parent = mkinsub("SFO", "m1"), m1 = mkinsub("SFO"), verbose = TRUE)#> Compilation argument: -#> /usr/lib/R/bin/R CMD SHLIB file66a9718e919b.c 2> file66a9718e919b.c.err.txt +#> /usr/lib/R/bin/R CMD SHLIB fileb6a4eaab60.c 2> fileb6a4eaab60.c.err.txt #> Program source: #> 1: #include <R.h> #> 2: #> 3: #> 4: static double parms [3]; -#> 5: #define k_parent_sink parms[0] -#> 6: #define k_parent_m1 parms[1] -#> 7: #define k_m1_sink parms[2] +#> 5: #define k_parent parms[0] +#> 6: #define f_parent_to_m1 parms[1] +#> 7: #define k_m1 parms[2] #> 8: #> 9: void initpar(void (* odeparms)(int *, double *)) { #> 10: int N = 3; @@ -270,8 +270,8 @@ in the FOCUS and NAFTA guidance documents are used. #> 14: #> 15: void func ( int * n, double * t, double * y, double * f, double * rpar, int * ipar ) { #> 16: -#> 17: f[0] = - k_parent_sink * y[0] - k_parent_m1 * y[0]; -#> 18: f[1] = + k_parent_m1 * y[0] - k_m1_sink * y[1]; +#> 17: f[0] = - k_parent * y[0]; +#> 18: f[1] = + f_parent_to_m1 * k_parent * y[0] - k_m1 * y[1]; #> 19: }#># If we have several parallel metabolites # (compare tests/testthat/test_synthetic_data_for_UBA_2014.R) diff --git a/docs/reference/mkinpredict.html b/docs/reference/mkinpredict.html index 689fb7c7..21c13156 100644 --- a/docs/reference/mkinpredict.html +++ b/docs/reference/mkinpredict.html @@ -74,7 +74,7 @@ kinetic parameters and initial values for the state variables." />@@ -268,8 +268,29 @@ solver is used.SFO <- mkinmod(degradinol = mkinsub("SFO")) # Compare solution types -mkinpredict(SFO, c(k_degradinol_sink = 0.3), c(degradinol = 100), 0:20, - solution_type = "analytical")#> Error in (function (t, parent_0, k) { parent = parent_0 * exp(-k * t)})(t = 0:20, parent.0 = c(degradinol = 100), k = 0.3): unbenutztes Argument (parent.0 = 100)mkinpredict(SFO, c(k_degradinol_sink = 0.3), c(degradinol = 100), 0:20, +mkinpredict(SFO, c(k_degradinol = 0.3), c(degradinol = 100), 0:20, + solution_type = "analytical")#> time degradinol +#> 1 0 100.0000000 +#> 2 1 74.0818221 +#> 3 2 54.8811636 +#> 4 3 40.6569660 +#> 5 4 30.1194212 +#> 6 5 22.3130160 +#> 7 6 16.5298888 +#> 8 7 12.2456428 +#> 9 8 9.0717953 +#> 10 9 6.7205513 +#> 11 10 4.9787068 +#> 12 11 3.6883167 +#> 13 12 2.7323722 +#> 14 13 2.0241911 +#> 15 14 1.4995577 +#> 16 15 1.1108997 +#> 17 16 0.8229747 +#> 18 17 0.6096747 +#> 19 18 0.4516581 +#> 20 19 0.3345965 +#> 21 20 0.2478752#> time degradinol #> 1 0 100.0000000 #> 2 1 74.0818221 @@ -291,7 +312,7 @@ solver is used. #> 18 17 0.6096747 #> 19 18 0.4516581 #> 20 19 0.3345965 -#> 21 20 0.2478752mkinpredict(SFO, c(k_degradinol = 0.3), c(degradinol = 100), 0:20, solution_type = "deSolve", use_compiled = FALSE)#> time degradinol #> 1 0 100.0000000 #> 2 1 74.0818221 @@ -313,7 +334,7 @@ solver is used. #> 18 17 0.6096747 #> 19 18 0.4516581 #> 20 19 0.3345965 -#> 21 20 0.2478752#> time degradinol #> 1 0 100.0000000 #> 2 1 74.0818221 @@ -337,25 +358,26 @@ solver is used. #> 20 19 0.3345965 #> 21 20 0.2478752# Compare integration methods to analytical solution -mkinpredict(SFO, c(k_degradinol_sink = 0.3), c(degradinol = 100), 0:20, - solution_type = "analytical")[21,]#> Error in (function (t, parent_0, k) { parent = parent_0 * exp(-k * t)})(t = 0:20, parent.0 = c(degradinol = 100), k = 0.3): unbenutztes Argument (parent.0 = 100)mkinpredict(SFO, c(k_degradinol_sink = 0.3), c(degradinol = 100), 0:20, +mkinpredict(SFO, c(k_degradinol = 0.3), c(degradinol = 100), 0:20, + solution_type = "analytical")[21,]#> time degradinol +#> 21 20 0.2478752#> time degradinol -#> 21 20 0.2478752#> time degradinol -#> 21 20 0.2478752#> time degradinol #> 21 20 0.2480043# rk4 is not as precise here # The number of output times used to make a lot of difference until the # default for atol was adjusted -mkinpredict(SFO, c(k_degradinol_sink = 0.3), c(degradinol = 100), +mkinpredict(SFO, c(k_degradinol = 0.3), c(degradinol = 100), seq(0, 20, by = 0.1))[201,]#> time degradinol -#> 201 20 0.2478752#> time degradinol #> 2001 20 0.2478752# Check compiled model versions - they are faster than the eigenvalue based solutions! SFO_SFO = mkinmod(parent = list(type = "SFO", to = "m1"), - m1 = list(type = "SFO"))#>#>if(require(rbenchmark)) { benchmark( eigen = mkinpredict(SFO_SFO, c(k_parent_m1 = 0.05, k_parent_sink = 0.1, k_m1_sink = 0.01), c(parent = 100, m1 = 0), seq(0, 20, by = 0.1), @@ -371,7 +393,7 @@ solver is used. }#>#> test replications elapsed relative user.self sys.self user.child #> 3 deSolve 10 0.229 28.625 0.229 0 0 #> 2 deSolve_compiled 10 0.008 1.000 0.008 0 0 -#> 1 eigen 10 0.025 3.125 0.026 0 0 +#> 1 eigen 10 0.026 3.250 0.025 0 0 #> sys.child #> 3 0 #> 2 0 diff --git a/docs/reference/nlme-1.png b/docs/reference/nlme-1.png index 68ccb43f..8db1f999 100644 Binary files a/docs/reference/nlme-1.png and b/docs/reference/nlme-1.png differ diff --git a/docs/reference/nlme.html b/docs/reference/nlme.html index 70c6b63c..b92d2141 100644 --- a/docs/reference/nlme.html +++ b/docs/reference/nlme.html @@ -10,23 +10,27 @@ - + - + - + + + + + - - + + - + - - + + @@ -40,7 +44,6 @@ an mmkin row object. An mmkin row object is essentially a list of mkinfit objects that have been obtained by fitting the same model to a list of datasets." /> - @@ -58,7 +61,7 @@ datasets." /> - +diff --git a/docs/sitemap.xml b/docs/sitemap.xml index 5abcc894..81368436 100644 --- a/docs/sitemap.xml +++ b/docs/sitemap.xml @@ -60,6 +60,9 @@@@ -131,7 +139,7 @@ datasets." />@@ -116,7 +119,12 @@ datasets." /> @@ -177,15 +185,15 @@ datasets.- @@ -260,7 +263,7 @@ datasets.sampling_times = c(0, 1, 3, 7, 14, 28, 60, 90, 120) m_SFO <- mkinmod(parent = mkinsub("SFO")) d_SFO_1 <- mkinpredict(m_SFO, - c(k_parent_sink = 0.1), + c(k_parent = 0.1), c(parent = 98), sampling_times) d_SFO_1_long <- mkin_wide_to_long(d_SFO_1, time = "time") d_SFO_2 <- mkinpredict(m_SFO, - c(k_parent_sink = 0.05), + c(k_parent = 0.05), c(parent = 102), sampling_times) d_SFO_2_long <- mkin_wide_to_long(d_SFO_2, time = "time") d_SFO_3 <- mkinpredict(m_SFO, - c(k_parent_sink = 0.02), + c(k_parent = 0.02), c(parent = 103), sampling_times) d_SFO_3_long <- mkin_wide_to_long(d_SFO_3, time = "time") @@ -214,42 +222,37 @@ datasets. #> Model: value ~ nlme_f(name, time, parent_0, log_k_parent_sink) #> Data: grouped_data #> AIC BIC logLik -#> 298.2781 307.7372 -144.1391 +#> 252.7798 262.1358 -121.3899 #> #> Random effects: #> Formula: list(parent_0 ~ 1, log_k_parent_sink ~ 1) #> Level: ds #> Structure: Diagonal -#> parent_0 log_k_parent_sink Residual -#> StdDev: 0.9374733 0.7098105 3.83543 +#> parent_0 log_k_parent_sink Residual +#> StdDev: 0.0006768135 0.6800777 2.489397 #> #> Fixed effects: parent_0 + log_k_parent_sink ~ 1 -#> Value Std.Error DF t-value p-value -#> parent_0 101.76838 1.1445444 45 88.91606 0 -#> log_k_parent_sink -3.05444 0.4195622 45 -7.28008 0 +#> Value Std.Error DF t-value p-value +#> parent_0 101.74884 0.6456014 44 157.60321 0 +#> log_k_parent_sink -3.05575 0.4015811 44 -7.60929 0 #> Correlation: #> prnt_0 -#> log_k_parent_sink 0.034 +#> log_k_parent_sink 0.026 #> #> Standardized Within-Group Residuals: #> Min Q1 Med Q3 Max -#> -2.6169360 -0.2185329 0.0574070 0.5720937 3.0459868 +#> -2.1317488 -0.6878121 0.0828385 0.8592270 2.9529864 #> -#> Number of Observations: 49 -#> Number of Groups: 3# augPred does not seem to work on fits with more than one state +#> Number of Observations: 48 +#> Number of Groups: 3# augPred does not seem to work on fits with more than one state # variable+ https://pkgdown.jrwb.de/mkin/reference/confint.mkinfit.html + https://pkgdown.jrwb.de/mkin/reference/create_deg_func.html +diff --git a/man/HS.solution.Rd b/man/HS.solution.Rd index 343f83f0..f72df23b 100644 --- a/man/HS.solution.Rd +++ b/man/HS.solution.Rd @@ -7,10 +7,21 @@ HS.solution(t, parent_0, k1, k2, tb) } \arguments{ +\item{t}{Time.} + +\item{parent_0}{Starting value for the response variable at time zero.} + +\item{k1}{First kinetic constant.} + +\item{k2}{Second kinetic constant.} + \item{tb}{Break point. Before this time, exponential decline according to \code{k1} is calculated, after this time, exponential decline proceeds according to \code{k2}.} } +\value{ +The value of the response variable at time \code{t}. +} \description{ Function describing two exponential decline functions with a break point between them. @@ -20,6 +31,18 @@ between them. plot(function(x) HS.solution(x, 100, 2, 0.3, 0.5), 0, 2, ylim=c(0,100)) } +\references{ +FOCUS (2006) \dQuote{Guidance Document on Estimating Persistence + and Degradation Kinetics from Environmental Fate Studies on Pesticides in + EU Registration} Report of the FOCUS Work Group on Degradation Kinetics, + EC Document Reference Sanco/10058/2005 version 2.0, 434 pp, + \url{http://esdac.jrc.ec.europa.eu/projects/degradation-kinetics} +FOCUS (2014) \dQuote{Generic guidance for Estimating Persistence + and Degradation Kinetics from Environmental Fate Studies on Pesticides in + EU Registration} Report of the FOCUS Work Group on Degradation Kinetics, + Version 1.1, 18 December 2014 + \url{http://esdac.jrc.ec.europa.eu/projects/degradation-kinetics} +} \seealso{ Other parent solutions: \code{\link{DFOP.solution}()}, diff --git a/man/SFORB.solution.Rd b/man/SFORB.solution.Rd index c70ce13b..98a8c684 100644 --- a/man/SFORB.solution.Rd +++ b/man/SFORB.solution.Rd @@ -7,6 +7,10 @@ SFORB.solution(t, parent_0, k_12, k_21, k_1output) } \arguments{ +\item{t}{Time.} + +\item{parent_0}{Starting value for the response variable at time zero.} + \item{k_12}{Kinetic constant describing transfer from free to bound.} \item{k_21}{Kinetic constant describing transfer from bound to free.} @@ -30,6 +34,18 @@ and no substance in the bound fraction. \dontrun{plot(function(x) SFORB.solution(x, 100, 0.5, 2, 3), 0, 2)} } +\references{ +FOCUS (2006) \dQuote{Guidance Document on Estimating Persistence + and Degradation Kinetics from Environmental Fate Studies on Pesticides in + EU Registration} Report of the FOCUS Work Group on Degradation Kinetics, + EC Document Reference Sanco/10058/2005 version 2.0, 434 pp, + \url{http://esdac.jrc.ec.europa.eu/projects/degradation-kinetics} +FOCUS (2014) \dQuote{Generic guidance for Estimating Persistence + and Degradation Kinetics from Environmental Fate Studies on Pesticides in + EU Registration} Report of the FOCUS Work Group on Degradation Kinetics, + Version 1.1, 18 December 2014 + \url{http://esdac.jrc.ec.europa.eu/projects/degradation-kinetics} +} \seealso{ Other parent solutions: \code{\link{DFOP.solution}()}, diff --git a/man/create_deg_func.Rd b/man/create_deg_func.Rd new file mode 100644 index 00000000..2eefdb80 --- /dev/null +++ b/man/create_deg_func.Rd @@ -0,0 +1,26 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/create_deg_func.R +\name{create_deg_func} +\alias{create_deg_func} +\title{Create degradation functions for known analytical solutions} +\usage{ +create_deg_func(spec, use_of_ff = c("min", "max")) +} +\arguments{ +\item{spec}{List of model specifications as contained in mkinmod objects} + +\item{use_of_ff}{Minimum or maximum use of formation fractions} +} +\value{ +Degradation function to be attached to mkinmod objects +} +\description{ +Create degradation functions for known analytical solutions +} +\examples{ + +SFO_SFO <- mkinmod( + parent = mkinsub("SFO", "m1"), + m1 = mkinsub("SFO")) +fit <- mkinfit(SFO_SFO, FOCUS_2006_D, quiet = TRUE) +} diff --git a/man/logistic.solution.Rd b/man/logistic.solution.Rd index 589ee8ec..33b3d44a 100644 --- a/man/logistic.solution.Rd +++ b/man/logistic.solution.Rd @@ -1,11 +1,9 @@ % Generated by roxygen2: do not edit by hand -% Please edit documentation in R/logistic.solution.R, R/parent_solutions.R +% Please edit documentation in R/parent_solutions.R \name{logistic.solution} \alias{logistic.solution} \title{Logistic kinetics} \usage{ -logistic.solution(t, parent_0, kmax, k0, r) - logistic.solution(t, parent_0, kmax, k0, r) } \arguments{ @@ -18,23 +16,15 @@ logistic.solution(t, parent_0, kmax, k0, r) \item{k0}{Minumum rate constant effective at time zero.} \item{r}{Growth rate of the increase in the rate constant.} - -\item{parent.0}{Starting value for the response variable at time zero.} } \value{ The value of the response variable at time \code{t}. } \description{ -Function describing exponential decline from a defined starting value, with -an increasing rate constant, supposedly caused by microbial growth - Function describing exponential decline from a defined starting value, with an increasing rate constant, supposedly caused by microbial growth } \note{ -The solution of the logistic model reduces to the - \code{\link{SFO.solution}} if \code{k0} is equal to \code{kmax}. - The solution of the logistic model reduces to the \code{\link{SFO.solution}} if \code{k0} is equal to \code{kmax}. } @@ -74,43 +64,13 @@ The solution of the logistic model reduces to the summary(m)$bpar endpoints(m)$distimes - - # Reproduce the plot on page 57 of FOCUS (2014) - plot(function(x) logistic.solution(x, 100, 0.08, 0.0001, 0.2), - from = 0, to = 100, ylim = c(0, 100), - xlab = "Time", ylab = "Residue") - plot(function(x) logistic.solution(x, 100, 0.08, 0.0001, 0.4), - from = 0, to = 100, add = TRUE, lty = 2, col = 2) - plot(function(x) logistic.solution(x, 100, 0.08, 0.0001, 0.8), - from = 0, to = 100, add = TRUE, lty = 3, col = 3) - plot(function(x) logistic.solution(x, 100, 0.08, 0.001, 0.2), - from = 0, to = 100, add = TRUE, lty = 4, col = 4) - plot(function(x) logistic.solution(x, 100, 0.08, 0.08, 0.2), - from = 0, to = 100, add = TRUE, lty = 5, col = 5) - legend("topright", inset = 0.05, - legend = paste0("k0 = ", c(0.0001, 0.0001, 0.0001, 0.001, 0.08), - ", r = ", c(0.2, 0.4, 0.8, 0.2, 0.2)), - lty = 1:5, col = 1:5) - - # Fit with synthetic data - logistic <- mkinmod(parent = mkinsub("logistic")) - - sampling_times = c(0, 1, 3, 7, 14, 28, 60, 90, 120) - parms_logistic <- c(kmax = 0.08, k0 = 0.0001, r = 0.2) - d_logistic <- mkinpredict(logistic, - parms_logistic, c(parent = 100), - sampling_times) - d_2_1 <- add_err(d_logistic, - sdfunc = function(x) sigma_twocomp(x, 0.5, 0.07), - n = 1, reps = 2, digits = 5, LOD = 0.1, seed = 123456)[[1]] - - m <- mkinfit("logistic", d_2_1, quiet = TRUE) - plot_sep(m) - summary(m)$bpar - endpoints(m)$distimes - } \references{ +FOCUS (2006) \dQuote{Guidance Document on Estimating Persistence + and Degradation Kinetics from Environmental Fate Studies on Pesticides in + EU Registration} Report of the FOCUS Work Group on Degradation Kinetics, + EC Document Reference Sanco/10058/2005 version 2.0, 434 pp, + \url{http://esdac.jrc.ec.europa.eu/projects/degradation-kinetics} FOCUS (2014) \dQuote{Generic guidance for Estimating Persistence and Degradation Kinetics from Environmental Fate Studies on Pesticides in EU Registration} Report of the FOCUS Work Group on Degradation Kinetics, diff --git a/man/mkinmod.Rd b/man/mkinmod.Rd index 020917b9..2ba917d6 100644 --- a/man/mkinmod.Rd +++ b/man/mkinmod.Rd @@ -6,7 +6,7 @@ \usage{ mkinmod( ..., - use_of_ff = "min", + use_of_ff = "max", speclist = NULL, quiet = FALSE, verbose = FALSE diff --git a/man/mkinpredict.Rd b/man/mkinpredict.Rd index 366d5b83..f7e4acfc 100644 --- a/man/mkinpredict.Rd +++ b/man/mkinpredict.Rd @@ -102,36 +102,36 @@ kinetic parameters and initial values for the state variables. SFO <- mkinmod(degradinol = mkinsub("SFO")) # Compare solution types -mkinpredict(SFO, c(k_degradinol_sink = 0.3), c(degradinol = 100), 0:20, +mkinpredict(SFO, c(k_degradinol = 0.3), c(degradinol = 100), 0:20, solution_type = "analytical") -mkinpredict(SFO, c(k_degradinol_sink = 0.3), c(degradinol = 100), 0:20, +mkinpredict(SFO, c(k_degradinol = 0.3), c(degradinol = 100), 0:20, solution_type = "deSolve") -mkinpredict(SFO, c(k_degradinol_sink = 0.3), c(degradinol = 100), 0:20, +mkinpredict(SFO, c(k_degradinol = 0.3), c(degradinol = 100), 0:20, solution_type = "deSolve", use_compiled = FALSE) -mkinpredict(SFO, c(k_degradinol_sink = 0.3), c(degradinol = 100), 0:20, +mkinpredict(SFO, c(k_degradinol = 0.3), c(degradinol = 100), 0:20, solution_type = "eigen") # Compare integration methods to analytical solution -mkinpredict(SFO, c(k_degradinol_sink = 0.3), c(degradinol = 100), 0:20, +mkinpredict(SFO, c(k_degradinol = 0.3), c(degradinol = 100), 0:20, solution_type = "analytical")[21,] -mkinpredict(SFO, c(k_degradinol_sink = 0.3), c(degradinol = 100), 0:20, +mkinpredict(SFO, c(k_degradinol = 0.3), c(degradinol = 100), 0:20, method = "lsoda")[21,] -mkinpredict(SFO, c(k_degradinol_sink = 0.3), c(degradinol = 100), 0:20, +mkinpredict(SFO, c(k_degradinol = 0.3), c(degradinol = 100), 0:20, method = "ode45")[21,] -mkinpredict(SFO, c(k_degradinol_sink = 0.3), c(degradinol = 100), 0:20, +mkinpredict(SFO, c(k_degradinol = 0.3), c(degradinol = 100), 0:20, method = "rk4")[21,] # rk4 is not as precise here # The number of output times used to make a lot of difference until the # default for atol was adjusted -mkinpredict(SFO, c(k_degradinol_sink = 0.3), c(degradinol = 100), +mkinpredict(SFO, c(k_degradinol = 0.3), c(degradinol = 100), seq(0, 20, by = 0.1))[201,] -mkinpredict(SFO, c(k_degradinol_sink = 0.3), c(degradinol = 100), +mkinpredict(SFO, c(k_degradinol = 0.3), c(degradinol = 100), seq(0, 20, by = 0.01))[2001,] # Check compiled model versions - they are faster than the eigenvalue based solutions! SFO_SFO = mkinmod(parent = list(type = "SFO", to = "m1"), - m1 = list(type = "SFO")) + m1 = list(type = "SFO"), use_of_ff = "min") if(require(rbenchmark)) { benchmark( eigen = mkinpredict(SFO_SFO, c(k_parent_m1 = 0.05, k_parent_sink = 0.1, k_m1_sink = 0.01), diff --git a/man/nlme.Rd b/man/nlme.Rd index 4a668ac0..a9e368dd 100644 --- a/man/nlme.Rd +++ b/man/nlme.Rd @@ -37,15 +37,15 @@ datasets. sampling_times = c(0, 1, 3, 7, 14, 28, 60, 90, 120) m_SFO <- mkinmod(parent = mkinsub("SFO")) d_SFO_1 <- mkinpredict(m_SFO, - c(k_parent_sink = 0.1), + c(k_parent = 0.1), c(parent = 98), sampling_times) d_SFO_1_long <- mkin_wide_to_long(d_SFO_1, time = "time") d_SFO_2 <- mkinpredict(m_SFO, - c(k_parent_sink = 0.05), + c(k_parent = 0.05), c(parent = 102), sampling_times) d_SFO_2_long <- mkin_wide_to_long(d_SFO_2, time = "time") d_SFO_3 <- mkinpredict(m_SFO, - c(k_parent_sink = 0.02), + c(k_parent = 0.02), c(parent = 103), sampling_times) d_SFO_3_long <- mkin_wide_to_long(d_SFO_3, time = "time") diff --git a/test.log b/test.log index b57bd69a..72ed4ee3 100644 --- a/test.log +++ b/test.log @@ -2,34 +2,34 @@ Loading mkin Testing mkin ✔ | OK F W S | Context ✔ | 2 | Export dataset for reading into CAKE -✔ | 13 | Results for FOCUS D established in expertise for UBA (Ranke 2014) [3.6 s] +✔ | 13 | Results for FOCUS D established in expertise for UBA (Ranke 2014) [3.7 s] ✔ | 4 | Calculation of FOCUS chi2 error levels [2.2 s] -✔ | 6 | Fitting the SFORB model [9.1 s] +✔ | 7 | Fitting the SFORB model [11.7 s] ✔ | 5 | Calculation of Akaike weights -✔ | 10 | Confidence intervals and p-values [9.6 s] -✔ | 14 | Error model fitting [38.5 s] +✔ | 10 | Confidence intervals and p-values [9.3 s] +✔ | 14 | Error model fitting [37.6 s] ✔ | 6 | Test fitting the decline of metabolites from their maximum [0.8 s] ✔ | 1 | Fitting the logistic model [0.8 s] ✔ | 1 | Test dataset class mkinds used in gmkin -✔ | 12 | Special cases of mkinfit calls [2.3 s] +✔ | 12 | Special cases of mkinfit calls [2.2 s] ✔ | 8 | mkinmod model generation and printing [0.2 s] ✔ | 3 | Model predictions with mkinpredict [0.4 s] -✔ | 16 | Evaluations according to 2015 NAFTA guidance [4.2 s] -✔ | 9 | Nonlinear mixed-effects models [12.3 s] +✔ | 16 | Evaluations according to 2015 NAFTA guidance [4.1 s] +✔ | 9 | Nonlinear mixed-effects models [12.0 s] ✔ | 4 | Calculation of maximum time weighted average concentrations (TWAs) [2.4 s] ✔ | 3 | Summary -✔ | 14 | Plotting [5.1 s] +✔ | 14 | Plotting [4.9 s] ✔ | 4 | AIC calculation ✔ | 4 | Residuals extracted from mkinfit models ✔ | 2 | Complex test case from Schaefer et al. (2007) Piacenza paper [5.3 s] ✔ | 1 | Summaries of old mkinfit objects ✔ | 4 | Results for synthetic data established in expertise for UBA (Ranke 2014) [7.2 s] -✔ | 9 | Hypothesis tests [38.2 s] +✔ | 9 | Hypothesis tests [37.9 s] ══ Results ═════════════════════════════════════════════════════════════════════ -Duration: 142.5 s +Duration: 143.0 s -OK: 155 +OK: 156 Failed: 0 Warnings: 0 Skipped: 0 diff --git a/tests/testthat/FOCUS_2006_D.csf b/tests/testthat/FOCUS_2006_D.csf index fa96de74..7c29ab46 100644 --- a/tests/testthat/FOCUS_2006_D.csf +++ b/tests/testthat/FOCUS_2006_D.csf @@ -5,7 +5,7 @@ Description: MeasurementUnits: % AR TimeUnits: days Comments: Created using mkin::CAKE_export -Date: 2020-05-06 +Date: 2020-05-07 Optimiser: IRLS [Data] diff --git a/tests/testthat/SFO_SFO_printed.txt b/tests/testthat/SFO_SFO_printed.txt index d0402fc0..a3a04be2 100644 --- a/tests/testthat/SFO_SFO_printed.txt +++ b/tests/testthat/SFO_SFO_printed.txt @@ -1,5 +1,5 @@ https://pkgdown.jrwb.de/mkin/reference/endpoints.html model generated with -Use of formation fractions $use_of_ff: min +Use of formation fractions $use_of_ff: max Specification $spec: $parent $type: SFO; $to: m1; $sink: TRUE @@ -7,5 +7,5 @@ $m1 $type: SFO; $sink: TRUE Coefficient matrix $coefmat available Differential equations: -d_parent/dt = - k_parent_sink * parent - k_parent_m1 * parent -d_m1/dt = + k_parent_m1 * parent - k_m1_sink * m1 +d_parent/dt = - k_parent * parent +d_m1/dt = + f_parent_to_m1 * k_parent * parent - k_m1 * m1 diff --git a/tests/testthat/summary_DFOP_FOCUS_C.txt b/tests/testthat/summary_DFOP_FOCUS_C.txt index 14e00f62..4f96c8d3 100644 --- a/tests/testthat/summary_DFOP_FOCUS_C.txt +++ b/tests/testthat/summary_DFOP_FOCUS_C.txt @@ -33,6 +33,11 @@ g_ilr 0.000000 -Inf Inf Fixed parameter values: None +Results: + + AIC BIC logLik + 29.02372 30.00984 -9.511861 + Optimised, transformed parameters with symmetric confidence intervals: Estimate Std. Error Lower Upper parent_0 85.0000 0.66620 83.1500 86.8500 diff --git a/tests/testthat/summary_DFOP_FOCUS_D_deSolve.txt b/tests/testthat/summary_DFOP_FOCUS_D_deSolve.txt index 66ab9348..fe697794 100644 --- a/tests/testthat/summary_DFOP_FOCUS_D_deSolve.txt +++ b/tests/testthat/summary_DFOP_FOCUS_D_deSolve.txt @@ -4,8 +4,8 @@ Date of fit: Dummy date for testing Date of summary: Dummy date for testing Equations: -d_parent/dt = - k_parent_sink * parent - k_parent_m1 * parent -d_m1/dt = + k_parent_m1 * parent - k_m1_sink * m1 +d_parent/dt = - k_parent * parent +d_m1/dt = + f_parent_to_m1 * k_parent * parent - k_m1 * m1 Model predictions using solution type deSolve @@ -16,30 +16,35 @@ Error model: Constant variance Error model algorithm: OLS Starting values for parameters to be optimised: - value type -parent_0 100.7500 state -k_parent_sink 0.1000 deparm -k_parent_m1 0.1001 deparm -k_m1_sink 0.1002 deparm + value type +parent_0 100.7500 state +k_parent 0.1000 deparm +k_m1 0.1001 deparm +f_parent_to_m1 0.5000 deparm Starting values for the transformed parameters actually optimised: - value lower upper -parent_0 100.750000 -Inf Inf -log_k_parent_sink -2.302585 -Inf Inf -log_k_parent_m1 -2.301586 -Inf Inf -log_k_m1_sink -2.300587 -Inf Inf + value lower upper +parent_0 100.750000 -Inf Inf +log_k_parent -2.302585 -Inf Inf +log_k_m1 -2.301586 -Inf Inf +f_parent_ilr_1 0.000000 -Inf Inf Fixed parameter values: value type m1_0 0 state +Results: + + AIC BIC logLik + 204.4486 212.6365 -97.22429 + Optimised, transformed parameters with symmetric confidence intervals: - Estimate Std. Error Lower Upper -parent_0 99.600 1.57000 96.400 102.800 -log_k_parent_sink -3.038 0.07626 -3.193 -2.883 -log_k_parent_m1 -2.980 0.04033 -3.062 -2.898 -log_k_m1_sink -5.248 0.13320 -5.518 -4.977 -sigma 3.126 0.35850 2.396 3.855 + Estimate Std. Error Lower Upper +parent_0 99.60000 1.57000 96.40000 102.8000 +log_k_parent -2.31600 0.04087 -2.39900 -2.2330 +log_k_m1 -5.24800 0.13320 -5.51800 -4.9770 +f_parent_ilr_1 0.04096 0.06312 -0.08746 0.1694 +sigma 3.12600 0.35850 2.39600 3.8550 Parameter correlation: NULL @@ -48,24 +53,23 @@ Backtransformed parameters: Confidence intervals for internally transformed parameters are asymmetric. t-test (unrealistically) based on the assumption of normal distribution for estimators of untransformed parameters. - Estimate t value Pr(>t) Lower Upper -parent_0 99.600000 63.430 2.298e-36 96.400000 1.028e+02 -k_parent_sink 0.047920 13.110 6.126e-15 0.041030 5.596e-02 -k_parent_m1 0.050780 24.800 3.269e-23 0.046780 5.512e-02 -k_m1_sink 0.005261 7.510 6.165e-09 0.004012 6.898e-03 -sigma 3.126000 8.718 2.235e-10 2.396000 3.855e+00 + Estimate t value Pr(>t) Lower Upper +parent_0 99.600000 63.430 2.298e-36 96.400000 1.028e+02 +k_parent 0.098700 24.470 4.955e-23 0.090820 1.073e-01 +k_m1 0.005261 7.510 6.165e-09 0.004012 6.898e-03 +f_parent_to_m1 0.514500 23.070 3.104e-22 0.469100 5.596e-01 +sigma 3.126000 8.718 2.235e-10 2.396000 3.855e+00 FOCUS Chi2 error levels in percent: err.min n.optim df All data 6.398 4 15 -parent 6.827 3 6 -m1 4.490 1 9 +parent 6.459 2 7 +m1 4.690 2 8 Resulting formation fractions: ff -parent_sink 0.4855 parent_m1 0.5145 -m1_sink 1.0000 +parent_sink 0.4855 Estimated disappearance times: DT50 DT90 @@ -78,10 +82,10 @@ Data: 0 parent 102.04 99.59848 2.442e+00 1 parent 93.50 90.23787 3.262e+00 1 parent 92.50 90.23787 2.262e+00 - 3 parent 63.23 74.07320 -1.084e+01 - 3 parent 68.99 74.07320 -5.083e+00 - 7 parent 52.32 49.91207 2.408e+00 - 7 parent 55.13 49.91207 5.218e+00 + 3 parent 63.23 74.07319 -1.084e+01 + 3 parent 68.99 74.07319 -5.083e+00 + 7 parent 52.32 49.91206 2.408e+00 + 7 parent 55.13 49.91206 5.218e+00 14 parent 27.27 25.01257 2.257e+00 14 parent 26.64 25.01257 1.627e+00 21 parent 11.50 12.53462 -1.035e+00 @@ -91,7 +95,7 @@ Data: 50 parent 0.69 0.71624 -2.624e-02 50 parent 0.63 0.71624 -8.624e-02 75 parent 0.05 0.06074 -1.074e-02 - 75 parent 0.06 0.06074 -7.382e-04 + 75 parent 0.06 0.06074 -7.381e-04 1 m1 4.84 4.80296 3.704e-02 1 m1 5.64 4.80296 8.370e-01 3 m1 12.91 13.02400 -1.140e-01 diff --git a/tests/testthat/summary_DFOP_FOCUS_D_eigen.txt b/tests/testthat/summary_DFOP_FOCUS_D_eigen.txt index 1626c5da..6ddbc1ab 100644 --- a/tests/testthat/summary_DFOP_FOCUS_D_eigen.txt +++ b/tests/testthat/summary_DFOP_FOCUS_D_eigen.txt @@ -4,8 +4,8 @@ Date of fit: Dummy date for testing Date of summary: Dummy date for testing Equations: -d_parent/dt = - k_parent_sink * parent - k_parent_m1 * parent -d_m1/dt = + k_parent_m1 * parent - k_m1_sink * m1 +d_parent/dt = - k_parent * parent +d_m1/dt = + f_parent_to_m1 * k_parent * parent - k_m1 * m1 Model predictions using solution type eigen @@ -16,30 +16,35 @@ Error model: Constant variance Error model algorithm: OLS Starting values for parameters to be optimised: - value type -parent_0 100.7500 state -k_parent_sink 0.1000 deparm -k_parent_m1 0.1001 deparm -k_m1_sink 0.1002 deparm + value type +parent_0 100.7500 state +k_parent 0.1000 deparm +k_m1 0.1001 deparm +f_parent_to_m1 0.5000 deparm Starting values for the transformed parameters actually optimised: - value lower upper -parent_0 100.750000 -Inf Inf -log_k_parent_sink -2.302585 -Inf Inf -log_k_parent_m1 -2.301586 -Inf Inf -log_k_m1_sink -2.300587 -Inf Inf + value lower upper +parent_0 100.750000 -Inf Inf +log_k_parent -2.302585 -Inf Inf +log_k_m1 -2.301586 -Inf Inf +f_parent_ilr_1 0.000000 -Inf Inf Fixed parameter values: value type m1_0 0 state +Results: + + AIC BIC logLik + 204.4486 212.6365 -97.22429 + Optimised, transformed parameters with symmetric confidence intervals: - Estimate Std. Error Lower Upper -parent_0 99.600 1.57000 96.400 102.800 -log_k_parent_sink -3.038 0.07626 -3.193 -2.883 -log_k_parent_m1 -2.980 0.04033 -3.062 -2.898 -log_k_m1_sink -5.248 0.13320 -5.518 -4.977 -sigma 3.126 0.35850 2.396 3.855 + Estimate Std. Error Lower Upper +parent_0 99.60000 1.57000 96.40000 102.8000 +log_k_parent -2.31600 0.04087 -2.39900 -2.2330 +log_k_m1 -5.24800 0.13320 -5.51800 -4.9770 +f_parent_ilr_1 0.04096 0.06312 -0.08746 0.1694 +sigma 3.12600 0.35850 2.39600 3.8550 Parameter correlation: NULL @@ -48,24 +53,23 @@ Backtransformed parameters: Confidence intervals for internally transformed parameters are asymmetric. t-test (unrealistically) based on the assumption of normal distribution for estimators of untransformed parameters. - Estimate t value Pr(>t) Lower Upper -parent_0 99.600000 63.430 2.298e-36 96.400000 1.028e+02 -k_parent_sink 0.047920 13.110 6.126e-15 0.041030 5.596e-02 -k_parent_m1 0.050780 24.800 3.269e-23 0.046780 5.512e-02 -k_m1_sink 0.005261 7.510 6.165e-09 0.004012 6.898e-03 -sigma 3.126000 8.718 2.235e-10 2.396000 3.855e+00 + Estimate t value Pr(>t) Lower Upper +parent_0 99.600000 63.430 2.298e-36 96.400000 1.028e+02 +k_parent 0.098700 24.470 4.955e-23 0.090820 1.073e-01 +k_m1 0.005261 7.510 6.165e-09 0.004012 6.898e-03 +f_parent_to_m1 0.514500 23.070 3.104e-22 0.469100 5.596e-01 +sigma 3.126000 8.718 2.235e-10 2.396000 3.855e+00 FOCUS Chi2 error levels in percent: err.min n.optim df All data 6.398 4 15 -parent 6.827 3 6 -m1 4.490 1 9 +parent 6.459 2 7 +m1 4.690 2 8 Resulting formation fractions: ff -parent_sink 0.4855 parent_m1 0.5145 -m1_sink 1.0000 +parent_sink 0.4855 Estimated disappearance times: DT50 DT90 diff --git a/tests/testthat/test_SFORB.R b/tests/testthat/test_SFORB.R index ad9881a8..4fb736ec 100644 --- a/tests/testthat/test_SFORB.R +++ b/tests/testthat/test_SFORB.R @@ -14,17 +14,21 @@ test_that("Fitting the SFORB model is equivalent to fitting DFOP", { M1 = mkinsub("SFO"), use_of_ff = "max", quiet = TRUE) SFORB_SFO <- mkinmod(parent = mkinsub("SFORB", "M1"), + M1 = mkinsub("SFO"), + use_of_ff = "min", quiet = TRUE) + SFORB_SFO_ff <- mkinmod(parent = mkinsub("SFORB", "M1"), M1 = mkinsub("SFO"), use_of_ff = "max", quiet = TRUE) - SFORB_SFO$coefmat - f_dfop_sfo <- mkinfit(DFOP_SFO, DFOP_par_c, quiet = TRUE) f_sforb_sfo <- mkinfit(SFORB_SFO, DFOP_par_c, quiet = TRUE) + f_sforb_sfo_ff <- mkinfit(SFORB_SFO_ff, DFOP_par_c, quiet = TRUE) f_sforb_sfo_eigen <- mkinfit(SFORB_SFO, DFOP_par_c, solution_type = "eigen", quiet = TRUE) expect_equivalent(endpoints(f_sforb_sfo)$distimes, endpoints(f_dfop_sfo)$distimes, tolerance = 1e-6) + expect_equivalent(endpoints(f_sforb_sfo_ff)$distimes, endpoints(f_dfop_sfo)$distimes, + tolerance = 1e-6) expect_equivalent(endpoints(f_sforb_sfo_eigen)$distimes, endpoints(f_dfop_sfo)$distimes, tolerance = 1e-6) }) diff --git a/tests/testthat/test_nlme.R b/tests/testthat/test_nlme.R index e5e19c60..31fb19de 100644 --- a/tests/testthat/test_nlme.R +++ b/tests/testthat/test_nlme.R @@ -2,20 +2,21 @@ context("Nonlinear mixed-effects models") library(nlme) +sampling_times = c(0, 1, 3, 7, 14, 28, 60, 90, 120) + test_that("nlme_function works correctly", { - sampling_times = c(0, 1, 3, 7, 14, 28, 60, 90, 120) m_SFO <- mkinmod(parent = mkinsub("SFO")) d_SFO_1 <- mkinpredict(m_SFO, - c(k_parent_sink = 0.1), + c(k_parent = 0.1), c(parent = 98), sampling_times) d_SFO_1_long <- mkin_wide_to_long(d_SFO_1, time = "time") d_SFO_2 <- mkinpredict(m_SFO, - c(k_parent_sink = 0.05), + c(k_parent = 0.05), c(parent = 102), sampling_times) d_SFO_2_long <- mkin_wide_to_long(d_SFO_2, time = "time") d_SFO_3 <- mkinpredict(m_SFO, - c(k_parent_sink = 0.02), + c(k_parent = 0.02), c(parent = 103), sampling_times) d_SFO_3_long <- mkin_wide_to_long(d_SFO_3, time = "time") @@ -33,7 +34,6 @@ test_that("nlme_function works correctly", { # The following assignment was introduced for nlme as evaluated by testthat # to find the function assign("nlme_f", nlme_f, pos = globalenv()) - assign("sampling_times", sampling_times, pos = globalenv()) m_nlme_raw <- nlme(value ~ SSasymp(time, 0, parent_0, log_k_parent_sink), data = grouped_data, @@ -101,7 +101,7 @@ test_that("nlme_function works correctly in other cases", { SFO <- mkinmod(parent = mkinsub("SFO")) pred_sfo <- function(k) { mkinpredict(SFO, - c(k_parent_sink = k), + c(k_parent = k), c(parent = 100), sampling_times) } -- cgit v1.2.1