From 0a3eb0893cb4bd1b12f07a79069d1c7f5e991495 Mon Sep 17 00:00:00 2001 From: Johannes Ranke Date: Fri, 25 Oct 2019 00:37:42 +0200 Subject: Use roxygen for functions and methods --- man/AIC.mmkin.Rd | 39 ++--- man/CAKE_export.Rd | 104 +++++------ man/DFOP.solution.Rd | 74 ++++---- man/Extract.mmkin.Rd | 22 ++- man/FOMC.solution.Rd | 99 ++++++----- man/HS.solution.Rd | 73 ++++---- man/IORE.solution.Rd | 95 +++++----- man/SFO.solution.Rd | 61 ++++--- man/SFORB.solution.Rd | 78 +++++---- man/add_err.Rd | 92 +++++----- man/endpoints.Rd | 38 ++-- man/ilr.Rd | 52 +++--- man/logLik.mkinfit.Rd | 54 +++--- man/logistic.solution.Rd | 52 +++--- man/max_twa_parent.Rd | 112 ++++++------ man/mkin_long_to_wide.Rd | 44 +++-- man/mkin_wide_to_long.Rd | 37 ++-- man/mkinds.Rd | 26 +-- man/mkinerrmin.Rd | 106 ++++++----- man/mkinerrplot.Rd | 118 ++++++------- man/mkinfit.Rd | 438 ++++++++++++++++++++++------------------------ man/mkinmod.Rd | 238 +++++++++++++------------ man/mkinparplot.Rd | 67 ++++--- man/mkinplot.Rd | 28 ++- man/mkinpredict.Rd | 133 +++++++------- man/mkinresplot.Rd | 141 +++++++-------- man/mkinsub.Rd | 54 +++--- man/mmkin.Rd | 76 ++++---- man/nafta.Rd | 79 +++++---- man/plot.mkinfit.Rd | 213 ++++++++++------------ man/plot.mmkin.Rd | 96 +++++----- man/plot.nafta.Rd | 43 +++-- man/print.mkinds.Rd | 21 +-- man/print.mkinmod.Rd | 28 +-- man/print.nafta.Rd | 27 --- man/sigma_twocomp.Rd | 41 +++-- man/summary.mkinfit.Rd | 152 ++++++++-------- man/transform_odeparms.Rd | 110 ++++++------ 38 files changed, 1656 insertions(+), 1705 deletions(-) delete mode 100644 man/print.nafta.Rd (limited to 'man') diff --git a/man/AIC.mmkin.Rd b/man/AIC.mmkin.Rd index ca3fcf20..42c9a73b 100644 --- a/man/AIC.mmkin.Rd +++ b/man/AIC.mmkin.Rd @@ -1,31 +1,29 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/AIC.mmkin.R \name{AIC.mmkin} \alias{AIC.mmkin} -\title{ - Calculated the AIC for a column of an mmkin object -} -\description{ - Provides a convenient way to compare different kineti models fitted to the - same dataset. -} +\title{Calculated the AIC for a column of an mmkin object} \usage{ - \method{AIC}{mmkin}(object, ..., k = 2) +\method{AIC}{mmkin}(object, ..., k = 2) } \arguments{ - \item{object}{ - An object of class \code{\link{mmkin}}, containing only one column. - } - \item{\dots}{ - For compatibility with the generic method - } - \item{k}{ - As in the generic method - } +\item{object}{An object of class \code{\link{mmkin}}, containing only one +column.} + +\item{\dots}{For compatibility with the generic method} + +\item{k}{As in the generic method} } \value{ - As in the generic method (a numeric value for single fits, or a dataframe if - there are several fits in the column). +As in the generic method (a numeric value for single fits, or a + dataframe if there are several fits in the column). +} +\description{ +Provides a convenient way to compare different kinetic models fitted to the +same dataset. } \examples{ + \dontrun{ # skip, as it takes > 10 s on winbuilder f <- mmkin(c("SFO", "FOMC", "DFOP"), list("FOCUS A" = FOCUS_2006_A, @@ -40,7 +38,8 @@ # For FOCUS C, the more complex models fit better AIC(f[, "FOCUS C"]) } + } \author{ - Johannes Ranke +Johannes Ranke } diff --git a/man/CAKE_export.Rd b/man/CAKE_export.Rd index c7111bc8..142b4a75 100644 --- a/man/CAKE_export.Rd +++ b/man/CAKE_export.Rd @@ -1,73 +1,55 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/CAKE_export.R \name{CAKE_export} \alias{CAKE_export} -\title{ - Export a list of datasets format to a CAKE study file -} -\description{ - In addition to the datasets, the pathways in the degradation - model can be specified as well. -} +\title{Export a list of datasets format to a CAKE study file} \usage{ -CAKE_export(ds, map = c(parent = "Parent"), - links = NA, +CAKE_export(ds, map = c(parent = "Parent"), links = NA, filename = "CAKE_export.csf", path = ".", overwrite = FALSE, - study = "Codlemone aerobic soil degradation", - description = "", - time_unit = "days", - res_unit = "\% AR", - comment = "Created using mkin::CAKE_export", - date = Sys.Date(), + study = "Codlemone aerobic soil degradation", description = "", + time_unit = "days", res_unit = "\% AR", + comment = "Created using mkin::CAKE_export", date = Sys.Date(), optimiser = "IRLS") } \arguments{ - \item{ds}{ - A named list of datasets in long format as compatible with - \code{\link{mkinfit}}. - } - \item{map}{ - A character vector with CAKE compartment names (Parent, A1, ...), - named with the names used in the list of datasets. - } - \item{links}{ - An optional character vector of target compartments, named with - the names of the source compartments. In order to make this - easier, the names are used as in the datasets supplied. - } - \item{filename}{ - Where to write the result. Should end in .csf in order to be compatible - with CAKE. - } - \item{path}{ - An optional path to the output file. - } - \item{overwrite}{ - If TRUE, existing files are overwritten. - } - \item{study}{ - The name of the study. - } - \item{description}{ - An optional description. - } - \item{time_unit}{ - The time unit for the residue data. - } - \item{res_unit}{ - The unit used for the residues. - } - \item{comment}{ - An optional comment. - } - \item{date}{ - The date of file creation. - } - \item{optimiser}{ - Can be OLS or IRLS. - } +\item{ds}{A named list of datasets in long format as compatible with +\code{\link{mkinfit}}.} + +\item{map}{A character vector with CAKE compartment names (Parent, A1, ...), +named with the names used in the list of datasets.} + +\item{links}{An optional character vector of target compartments, named with +the names of the source compartments. In order to make this easier, the +names are used as in the datasets supplied.} + +\item{filename}{Where to write the result. Should end in .csf in order to be +compatible with CAKE.} + +\item{path}{An optional path to the output file.} + +\item{overwrite}{If TRUE, existing files are overwritten.} + +\item{study}{The name of the study.} + +\item{description}{An optional description.} + +\item{time_unit}{The time unit for the residue data.} + +\item{res_unit}{The unit used for the residues.} + +\item{comment}{An optional comment.} + +\item{date}{The date of file creation.} + +\item{optimiser}{Can be OLS or IRLS.} } \value{ - The function is called for its side effect. +The function is called for its side effect. +} +\description{ +In addition to the datasets, the pathways in the degradation model can be +specified as well. } \author{ - Johannes Ranke +Johannes Ranke } diff --git a/man/DFOP.solution.Rd b/man/DFOP.solution.Rd index 50c4dce1..b145984a 100644 --- a/man/DFOP.solution.Rd +++ b/man/DFOP.solution.Rd @@ -1,35 +1,39 @@ -\name{DFOP.solution} -\alias{DFOP.solution} -\title{ -Double First-Order in Parallel kinetics -} -\description{ - Function describing decline from a defined starting value using the sum - of two exponential decline functions. -} -\usage{ -DFOP.solution(t, parent.0, k1, k2, g) -} -\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{g}{ Fraction of the starting value declining according to the - first kinetic constant. - } -} -\value{ - The value of the response variable at time \code{t}. -} -\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} -} -\examples{ - plot(function(x) DFOP.solution(x, 100, 5, 0.5, 0.3), 0, 4, ylim=c(0,100)) -} -\keyword{ manip } +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/DFOP.solution.R +\name{DFOP.solution} +\alias{DFOP.solution} +\title{Double First-Order in Parallel kinetics} +\usage{ +DFOP.solution(t, parent.0, k1, k2, g) +} +\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{g}{Fraction of the starting value declining according to the first +kinetic constant.} +} +\value{ +The value of the response variable at time \code{t}. +} +\description{ +Function describing decline from a defined starting value using the sum of +two exponential decline functions. +} +\examples{ + + plot(function(x) DFOP.solution(x, 100, 5, 0.5, 0.3), 0, 4, 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} +} diff --git a/man/Extract.mmkin.Rd b/man/Extract.mmkin.Rd index 973dc28f..7677bdba 100644 --- a/man/Extract.mmkin.Rd +++ b/man/Extract.mmkin.Rd @@ -1,12 +1,11 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/mmkin.R \name{[.mmkin} \alias{[.mmkin} \title{Subsetting method for mmkin objects} \usage{ \method{[}{mmkin}(x, i, j, ..., drop = FALSE) } -\description{ - Subsetting method for mmkin objects. -} \arguments{ \item{x}{An \code{\link{mmkin} object}} @@ -16,16 +15,17 @@ \item{...}{Not used, only there to satisfy the generic method definition} -\item{drop}{If FALSE, the method always returns an mmkin object, otherwise either - a list of mkinfit objects or a single mkinfit object.} +\item{drop}{If FALSE, the method always returns an mmkin object, otherwise +either a list of mkinfit objects or a single mkinfit object.} } \value{ - An object of class \code{\link{mmkin}}. +An object of class \code{\link{mmkin}}. } -\author{ - Johannes Ranke +\description{ +Subsetting method for mmkin objects. } \examples{ + # Only use one core, to pass R CMD check --as-cran fits <- mmkin(c("SFO", "FOMC"), list(B = FOCUS_2006_B, C = FOCUS_2006_C), cores = 1, quiet = TRUE) @@ -35,6 +35,10 @@ head( # This extracts an mkinfit object with lots of components - fits[["FOMC", "B"]] + fits[["FOMC", "B"]] ) + +} +\author{ +Johannes Ranke } diff --git a/man/FOMC.solution.Rd b/man/FOMC.solution.Rd index 55d89709..54430dd1 100644 --- a/man/FOMC.solution.Rd +++ b/man/FOMC.solution.Rd @@ -1,48 +1,51 @@ -\name{FOMC.solution} -\alias{FOMC.solution} -\title{ First-Order Multi-Compartment kinetics } -\description{ - 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. -} -\usage{ -FOMC.solution(t, parent.0, alpha, beta) -} -\arguments{ - \item{t}{ Time. } - \item{parent.0}{ Starting value for the response variable at time zero. } - \item{alpha}{ - Shape parameter determined by coefficient of variation of rate constant - values. } - \item{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}. -} -\value{ - The value of the response variable at time \code{t}. -} -\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} - - Gustafson DI and Holden LR (1990) Nonlinear pesticide dissipation in soil: 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)) -} -\keyword{ manip } +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/FOMC.solution.R +\name{FOMC.solution} +\alias{FOMC.solution} +\title{First-Order Multi-Compartment kinetics} +\usage{ +FOMC.solution(t, parent.0, alpha, beta) +} +\arguments{ +\item{t}{Time.} + +\item{parent.0}{Starting value for the response variable at time zero.} + +\item{alpha}{Shape parameter determined by coefficient of variation of rate +constant values.} + +\item{beta}{Location parameter.} +} +\value{ +The value of the response variable at time \code{t}. +} +\description{ +Function describing exponential decline from a defined starting value, with +a decreasing rate constant. +} +\details{ +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. +} +\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}. +} +\examples{ + + plot(function(x) FOMC.solution(x, 100, 10, 2), 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} + + Gustafson DI and Holden LR (1990) Nonlinear pesticide dissipation in soil: + A new model based on spatial variability. \emph{Environmental Science and + Technology} \bold{24}, 1032-1038 +} diff --git a/man/HS.solution.Rd b/man/HS.solution.Rd index 41e36c68..ba96b139 100644 --- a/man/HS.solution.Rd +++ b/man/HS.solution.Rd @@ -1,33 +1,40 @@ -\name{HS.solution} -\alias{HS.solution} -\title{ Hockey-Stick kinetics } -\description{ - Function describing two exponential decline functions with a break point - between them. -} -\usage{ -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}. -} -\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} -} -\examples{ - plot(function(x) HS.solution(x, 100, 2, 0.3, 0.5), 0, 2, ylim=c(0,100)) -} -\keyword{ manip } +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/HS.solution.R +\name{HS.solution} +\alias{HS.solution} +\title{Hockey-Stick kinetics} +\usage{ +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. +} +\examples{ + + 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} +} diff --git a/man/IORE.solution.Rd b/man/IORE.solution.Rd index 65760f95..ad2df3df 100644 --- a/man/IORE.solution.Rd +++ b/man/IORE.solution.Rd @@ -1,44 +1,51 @@ -\name{IORE.solution} -\alias{IORE.solution} -\title{ Indeterminate order rate equation kinetics } -\description{ - Function describing exponential decline from a defined starting value, with - a concentration dependent rate constant. -} -\usage{ - IORE.solution(t, parent.0, k__iore, N) -} -\arguments{ - \item{t}{ Time. } - \item{parent.0}{ Starting value for the response variable at time zero. } - \item{k__iore}{ Rate constant. Note that this depends on the concentration units used. } - \item{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. -} -\value{ - The value of the response variable at time \code{t}. -} -\references{ - NAFTA Technical Working Group on Pesticides (not dated) Guidance 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, - row.names = paste("model par", 1:4))) - print(rbind(fomc = endpoints(fit.fomc)$distimes, iore = endpoints(fit.iore)$distimes, - iore.deS = endpoints(fit.iore)$distimes)) - } -} -\keyword{ manip } +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/IORE.solution.R +\name{IORE.solution} +\alias{IORE.solution} +\title{Indeterminate order rate equation kinetics} +\usage{ +IORE.solution(t, parent.0, k__iore, N) +} +\arguments{ +\item{t}{Time.} + +\item{parent.0}{Starting value for the response variable at time zero.} + +\item{k__iore}{Rate constant. Note that this depends on the concentration +units used.} + +\item{N}{Exponent describing the nonlinearity of the rate equation} +} +\value{ +The value of the response variable at time \code{t}. +} +\description{ +Function describing exponential decline from a defined starting value, with +a concentration dependent rate constant. +} +\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. +} +\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, + row.names = paste("model par", 1:4))) + print(rbind(fomc = endpoints(fit.fomc)$distimes, iore = endpoints(fit.iore)$distimes, + iore.deS = endpoints(fit.iore)$distimes)) + } + +} +\references{ +NAFTA Technical Working Group on Pesticides (not dated) Guidance + for Evaluating and Calculating Degradation Kinetics in Environmental Media +} +\keyword{manip} diff --git a/man/SFO.solution.Rd b/man/SFO.solution.Rd index 5853d566..03c0dce8 100644 --- a/man/SFO.solution.Rd +++ b/man/SFO.solution.Rd @@ -1,28 +1,33 @@ -\name{SFO.solution} -\alias{SFO.solution} -\title{ Single First-Order kinetics } -\description{ - Function describing exponential decline from a defined starting value. -} -\usage{ - SFO.solution(t, parent.0, k) -} -\arguments{ - \item{t}{ Time. } - \item{parent.0}{ Starting value for the response variable at time zero. } - \item{k}{ Kinetic constant. } -} -\value{ - The value of the response variable at time \code{t}. -} -\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} -} -\examples{ - \dontrun{plot(function(x) SFO.solution(x, 100, 3), 0, 2)} -} -\keyword{ manip } +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/SFO.solution.R +\name{SFO.solution} +\alias{SFO.solution} +\title{Single First-Order kinetics} +\usage{ +SFO.solution(t, parent.0, k) +} +\arguments{ +\item{t}{Time.} + +\item{parent.0}{Starting value for the response variable at time zero.} + +\item{k}{Kinetic constant.} +} +\value{ +The value of the response variable at time \code{t}. +} +\description{ +Function describing exponential decline from a defined starting value. +} +\examples{ + + \dontrun{plot(function(x) SFO.solution(x, 100, 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} +} diff --git a/man/SFORB.solution.Rd b/man/SFORB.solution.Rd index 67c4c3f2..ce9dce73 100644 --- a/man/SFORB.solution.Rd +++ b/man/SFORB.solution.Rd @@ -1,35 +1,43 @@ -\name{SFORB.solution} -\alias{SFORB.solution} -\title{ Single First-Order Reversible Binding kinetics } -\description{ - 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. -} -\usage{ - 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. } - \item{k_1output}{ Kinetic constant describing degradation of the free fraction. } -} -\value{ - The value of the response variable, which is the sum of free and bound - fractions at time \code{t}. -} -\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} -} -\examples{ - \dontrun{plot(function(x) SFORB.solution(x, 100, 0.5, 2, 3), 0, 2)} -} -\keyword{ manip } +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/SFORB.solution.R +\name{SFORB.solution} +\alias{SFORB.solution} +\title{Single First-Order Reversible Binding kinetics} +\usage{ +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.} + +\item{k_1output}{Kinetic constant describing degradation of the free +fraction.} +} +\value{ +The value of the response variable, which is the sum of free and + bound fractions at time \code{t}. +} +\description{ +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. +} +\examples{ + + \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} +} diff --git a/man/add_err.Rd b/man/add_err.Rd index 00b50878..36b98be9 100644 --- a/man/add_err.Rd +++ b/man/add_err.Rd @@ -1,61 +1,46 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/add_err.R \name{add_err} \alias{add_err} -\title{ - Add normally distributed errors to simulated kinetic degradation data -} -\description{ - Normally distributed errors are added to data predicted for a specific - degradation model using \code{\link{mkinpredict}}. The variance of the error - may depend on the predicted value and is specified as a standard deviation. -} +\title{Add normally distributed errors to simulated kinetic degradation data} \usage{ - add_err(prediction, sdfunc, secondary = c("M1", "M2"), - n = 1000, LOD = 0.1, reps = 2, - digits = 1, seed = NA) +add_err(prediction, sdfunc, secondary = c("M1", "M2"), n = 1000, + LOD = 0.1, reps = 2, digits = 1, seed = NA) } \arguments{ - \item{prediction}{ - A prediction from a kinetic model as produced by \code{\link{mkinpredict}}. - } - \item{sdfunc}{ - A function taking the predicted value as its only argument and returning - a standard deviation that should be used for generating the random error - terms for this value. - } - \item{secondary}{ - The names of state variables that should have an initial value of zero - } - \item{n}{ - The number of datasets to be generated. - } - \item{LOD}{ - The limit of detection (LOD). Values that are below the LOD after adding - the random error will be set to NA. - } - \item{reps}{ - The number of replicates to be generated within the datasets. - } - \item{digits}{ - The number of digits to which the values will be rounded. - } - \item{seed}{ - The seed used for the generation of random numbers. If NA, the seed - is not set. - } +\item{prediction}{A prediction from a kinetic model as produced by +\code{\link{mkinpredict}}.} + +\item{sdfunc}{A function taking the predicted value as its only argument and +returning a standard deviation that should be used for generating the +random error terms for this value.} + +\item{secondary}{The names of state variables that should have an initial +value of zero} + +\item{n}{The number of datasets to be generated.} + +\item{LOD}{The limit of detection (LOD). Values that are below the LOD after +adding the random error will be set to NA.} + +\item{reps}{The number of replicates to be generated within the datasets.} + +\item{digits}{The number of digits to which the values will be rounded.} + +\item{seed}{The seed used for the generation of random numbers. If NA, the +seed is not set.} } \value{ - A list of datasets compatible with \code{\link{mmkin}}, i.e. - the components of the list are datasets compatible with - \code{\link{mkinfit}}. +A list of datasets compatible with \code{\link{mmkin}}, i.e. the + components of the list are datasets compatible with \code{\link{mkinfit}}. } -\references{ - Ranke J and Lehmann R (2015) To t-test or not to t-test, that is the question. XV Symposium on Pesticide Chemistry 2-4 September 2015, Piacenza, Italy - http://chem.uft.uni-bremen.de/ranke/posters/piacenza_2015.pdf -} -\author{ - Johannes Ranke +\description{ +Normally distributed errors are added to data predicted for a specific +degradation model using \code{\link{mkinpredict}}. The variance of the error +may depend on the predicted value and is specified as a standard deviation. } \examples{ + # The kinetic model m_SFO_SFO <- mkinmod(parent = mkinsub("SFO", "M1"), M1 = mkinsub("SFO"), use_of_ff = "max") @@ -97,5 +82,14 @@ plot(f_SFO_SFO[[3]], show_residuals = TRUE) # and plot.mmkin is used plot(f_SFO_SFO[1, 3]) } + +} +\references{ +Ranke J and Lehmann R (2015) To t-test or not to t-test, that is +the question. XV Symposium on Pesticide Chemistry 2-4 September 2015, +Piacenza, Italy +http://chem.uft.uni-bremen.de/ranke/posters/piacenza_2015.pdf +} +\author{ +Johannes Ranke } -\keyword{ manip } diff --git a/man/endpoints.Rd b/man/endpoints.Rd index 55a4cb0a..13182369 100644 --- a/man/endpoints.Rd +++ b/man/endpoints.Rd @@ -1,33 +1,35 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/endpoints.R \name{endpoints} \alias{endpoints} -\title{ -Function to calculate endpoints for further use from kinetic models fitted with mkinfit -} -\description{ -This function calculates DT50 and DT90 values as well as formation fractions from kinetic models -fitted with mkinfit. If the SFORB model was specified for one of the parents or metabolites, -the Eigenvalues are returned. These are equivalent to the rate constantes of the DFOP model, but -with the advantage that the SFORB model can also be used for metabolites. -} +\title{Function to calculate endpoints for further use from kinetic models fitted +with mkinfit} \usage{ endpoints(fit) } \arguments{ - \item{fit}{ - An object of class \code{\link{mkinfit}}. - } -} -\note{ - The function is used internally by \code{\link{summary.mkinfit}}. +\item{fit}{An object of class \code{\link{mkinfit}}.} } \value{ - A list with the components mentioned above. +A list with the components mentioned above. +} +\description{ +This function calculates DT50 and DT90 values as well as formation fractions +from kinetic models fitted with mkinfit. If the SFORB model was specified +for one of the parents or metabolites, the Eigenvalues are returned. These +are equivalent to the rate constantes of the DFOP model, but with the +advantage that the SFORB model can also be used for metabolites. +} +\note{ +The function is used internally by \code{\link{summary.mkinfit}}. } \examples{ + fit <- mkinfit("FOMC", FOCUS_2006_C, quiet = TRUE) endpoints(fit) + } \author{ - Johannes Ranke +Johannes Ranke } -\keyword{ manip } +\keyword{manip} diff --git a/man/ilr.Rd b/man/ilr.Rd index 29bf7d87..0cbd7e2c 100644 --- a/man/ilr.Rd +++ b/man/ilr.Rd @@ -1,36 +1,29 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/ilr.R \name{ilr} \alias{ilr} \alias{invilr} -\title{ - Function to perform isometric log-ratio transformation -} -\description{ - This implementation is a special case of the class of isometric log-ratio transformations. -} +\title{Function to perform isometric log-ratio transformation} \usage{ - ilr(x) - invilr(x) +ilr(x) + +invilr(x) } \arguments{ - \item{x}{ - A numeric vector. Naturally, the forward transformation is only sensible for - vectors with all elements being greater than zero. - } +\item{x}{A numeric vector. Naturally, the forward transformation is only +sensible for vectors with all elements being greater than zero.} } \value{ - The result of the forward or backward transformation. The returned components always - sum to 1 for the case of the inverse log-ratio transformation. -} -\references{ - Peter Filzmoser, Karel Hron (2008) Outlier Detection for Compositional Data Using Robust Methods. Math Geosci 40 233-248 -} -\author{ - René Lehmann and Johannes Ranke +The result of the forward or backward transformation. The returned + components always sum to 1 for the case of the inverse log-ratio + transformation. } -\seealso{ - Another implementation can be found in R package \code{robCompositions}. +\description{ +This implementation is a special case of the class of isometric log-ratio +transformations. } \examples{ + # Order matters ilr(c(0.1, 1, 10)) ilr(c(10, 1, 0.1)) @@ -51,6 +44,17 @@ a <- c(0.1, 0.3, 0.5) b <- invilr(a) length(b) # Four elements ilr(c(b[1:3], 1 - sum(b[1:3]))) # Gives c(0.1, 0.3, 0.5) -} -\keyword{ manip } +} +\references{ +Peter Filzmoser, Karel Hron (2008) Outlier Detection for + Compositional Data Using Robust Methods. Math Geosci 40 233-248 +} +\seealso{ +Another implementation can be found in R package + \code{robCompositions}. +} +\author{ +René Lehmann and Johannes Ranke +} +\keyword{manip} diff --git a/man/logLik.mkinfit.Rd b/man/logLik.mkinfit.Rd index 5e910c2e..bb2c2957 100644 --- a/man/logLik.mkinfit.Rd +++ b/man/logLik.mkinfit.Rd @@ -1,39 +1,34 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/logLik.mkinfit.R \name{logLik.mkinfit} \alias{logLik.mkinfit} -\title{ - Calculated the log-likelihood of a fitted mkinfit object -} -\description{ - This function simply calculates the product of the likelihood densities - calculated using \code{\link{dnorm}}, i.e. assuming normal distribution, - with of the mean predicted by the degradation model, and the - standard deviation predicted by the error model. - - The total number of estimated parameters returned with the value - of the likelihood is calculated as the sum of fitted degradation - model parameters and the fitted error model parameters. -} +\title{Calculated the log-likelihood of a fitted mkinfit object} \usage{ - \method{logLik}{mkinfit}(object, ...) +\method{logLik}{mkinfit}(object, ...) } \arguments{ - \item{object}{ - An object of class \code{\link{mkinfit}}. - } - \item{\dots}{ - For compatibility with the generic method - } +\item{object}{An object of class \code{\link{mkinfit}}.} + +\item{\dots}{For compatibility with the generic method} } \value{ - An object of class \code{\link{logLik}} with the number of - estimated parameters (degradation model parameters plus variance - model parameters) as attribute. +An object of class \code{\link{logLik}} with the number of estimated + parameters (degradation model parameters plus variance model parameters) + as attribute. } -\seealso{ - Compare the AIC of columns of \code{\link{mmkin}} objects using - \code{\link{AIC.mmkin}}. +\description{ +This function simply calculates the product of the likelihood densities +calculated using \code{\link{dnorm}}, i.e. assuming normal distribution, +with of the mean predicted by the degradation model, and the standard +deviation predicted by the error model. +} +\details{ +The total number of estimated parameters returned with the value of the +likelihood is calculated as the sum of fitted degradation model parameters +and the fitted error model parameters. } \examples{ + \dontrun{ sfo_sfo <- mkinmod( parent = mkinsub("SFO", to = "m1"), @@ -45,7 +40,12 @@ f_tc <- mkinfit(sfo_sfo, d_t, error_model = "tc", quiet = TRUE) AIC(f_nw, f_obs, f_tc) } + +} +\seealso{ +Compare the AIC of columns of \code{\link{mmkin}} objects using + \code{\link{AIC.mmkin}}. } \author{ - Johannes Ranke +Johannes Ranke } diff --git a/man/logistic.solution.Rd b/man/logistic.solution.Rd index 05b6c0aa..def776aa 100644 --- a/man/logistic.solution.Rd +++ b/man/logistic.solution.Rd @@ -1,36 +1,35 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/logistic.solution.R \name{logistic.solution} \alias{logistic.solution} -\title{ Logistic kinetics } -\description{ - Function describing exponential decline from a defined starting value, with - an increasing rate constant, supposedly caused by microbial growth -} +\title{Logistic kinetics} \usage{ logistic.solution(t, parent.0, kmax, k0, r) } \arguments{ - \item{t}{ Time. } - \item{parent.0}{ Starting value for the response variable at time zero. } - \item{kmax}{ Maximum rate constant. } - \item{k0}{ Minumum rate constant effective at time zero. } - \item{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}. +\item{t}{Time.} + +\item{parent.0}{Starting value for the response variable at time zero.} + +\item{kmax}{Maximum rate constant.} + +\item{k0}{Minumum rate constant effective at time zero.} + +\item{r}{Growth rate of the increase in the rate constant.} } \value{ - The value of the response variable at time \code{t}. +The value of the response variable at time \code{t}. } -\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} +\description{ +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}. } \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), @@ -64,5 +63,12 @@ logistic.solution(t, parent.0, kmax, k0, r) plot_sep(m) summary(m)$bpar endpoints(m)$distimes + +} +\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} } -\keyword{ manip } diff --git a/man/max_twa_parent.Rd b/man/max_twa_parent.Rd index c601b768..7c9f4861 100644 --- a/man/max_twa_parent.Rd +++ b/man/max_twa_parent.Rd @@ -1,80 +1,76 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/max_twa_parent.R \name{max_twa_parent} \alias{max_twa_parent} \alias{max_twa_sfo} \alias{max_twa_fomc} \alias{max_twa_dfop} \alias{max_twa_hs} -\title{ - Function to calculate maximum time weighted average concentrations from kinetic models fitted with mkinfit -} -\description{ -This function calculates maximum moving window time weighted average concentrations -(TWAs) for kinetic models fitted with \code{\link{mkinfit}}. Currently, only -calculations for the parent are implemented for the SFO, FOMC, DFOP and HS models, -using the analytical formulas given in the PEC soil section of the FOCUS -guidance.} +\title{Function to calculate maximum time weighted average concentrations from +kinetic models fitted with mkinfit} \usage{ - max_twa_parent(fit, windows) - max_twa_sfo(M0 = 1, k, t) - max_twa_fomc(M0 = 1, alpha, beta, t) - max_twa_dfop(M0 = 1, k1, k2, g, t) - max_twa_hs(M0 = 1, k1, k2, tb, t) +max_twa_parent(fit, windows) + +max_twa_sfo(M0 = 1, k, t) + +max_twa_fomc(M0 = 1, alpha, beta, t) + +max_twa_dfop(M0 = 1, k1, k2, g, t) + +max_twa_hs(M0 = 1, k1, k2, tb, t) } \arguments{ - \item{fit}{ - An object of class \code{\link{mkinfit}}. - } - \item{windows}{ - The width of the time windows for which the TWAs should be calculated. - } - \item{M0}{ - The initial concentration for which the maximum time weighted - average over the decline curve should be calculated. The default - is to use a value of 1, which means that a relative maximum time - weighted average factor (f_twa) is calculated. - } - \item{k}{ - The rate constant in the case of SFO kinetics. - } - \item{t}{ - The width of the time window. - } - \item{alpha}{ - Parameter of the FOMC model. - } - \item{beta}{ - Parameter of the FOMC model. - } - \item{k1}{ - The first rate constant of the DFOP or the HS kinetics. - } - \item{k2}{ - The second rate constant of the DFOP or the HS kinetics. - } - \item{g}{ - Parameter of the DFOP model. - } - \item{tb}{ - Parameter of the HS model. - } +\item{fit}{An object of class \code{\link{mkinfit}}.} + +\item{windows}{The width of the time windows for which the TWAs should be +calculated.} + +\item{M0}{The initial concentration for which the maximum time weighted +average over the decline curve should be calculated. The default is to use +a value of 1, which means that a relative maximum time weighted average +factor (f_twa) is calculated.} + +\item{k}{The rate constant in the case of SFO kinetics.} + +\item{t}{The width of the time window.} + +\item{alpha}{Parameter of the FOMC model.} + +\item{beta}{Parameter of the FOMC model.} + +\item{k1}{The first rate constant of the DFOP or the HS kinetics.} + +\item{k2}{The second rate constant of the DFOP or the HS kinetics.} + +\item{g}{Parameter of the DFOP model.} + +\item{tb}{Parameter of the HS model.} } \value{ - For \code{max_twa_parent}, a numeric vector, named using the \code{windows} argument. - For the other functions, a numeric vector of length one (also known as 'a - number'). +For \code{max_twa_parent}, a numeric vector, named using the + \code{windows} argument. For the other functions, a numeric vector of + length one (also known as 'a number'). +} +\description{ +This function calculates maximum moving window time weighted average +concentrations (TWAs) for kinetic models fitted with \code{\link{mkinfit}}. +Currently, only calculations for the parent are implemented for the SFO, +FOMC, DFOP and HS models, using the analytical formulas given in the PEC +soil section of the FOCUS guidance. } \examples{ + fit <- mkinfit("FOMC", FOCUS_2006_C, quiet = TRUE) max_twa_parent(fit, c(7, 21)) + } \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, +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} } \author{ - Johannes Ranke +Johannes Ranke } -\keyword{ manip } diff --git a/man/mkin_long_to_wide.Rd b/man/mkin_long_to_wide.Rd index c83f7c78..e76709b9 100644 --- a/man/mkin_long_to_wide.Rd +++ b/man/mkin_long_to_wide.Rd @@ -1,36 +1,34 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/mkin_long_to_wide.R \name{mkin_long_to_wide} \alias{mkin_long_to_wide} -\title{ - Convert a dataframe from long to wide format -} +\title{Convert a dataframe from long to wide format} \usage{ mkin_long_to_wide(long_data, time = "time", outtime = "time") } -\description{ - This function takes a dataframe in the long form, i.e. with a row - for each observed value, and converts it into a dataframe with one - independent variable and several dependent variables as columns. -} \arguments{ - \item{long_data}{ - The dataframe must contain one variable called "time" with the time values specified by the - \code{time} argument, one column called "name" with the grouping of the observed values, and - finally one column of observed values called "value". -} - \item{time}{ - The name of the time variable in the long input data. -} - \item{outtime}{ - The name of the time variable in the wide output data. -} +\item{long_data}{The dataframe must contain one variable called "time" with +the time values specified by the \code{time} argument, one column called +"name" with the grouping of the observed values, and finally one column of +observed values called "value".} + +\item{time}{The name of the time variable in the long input data.} + +\item{outtime}{The name of the time variable in the wide output data.} } \value{ - Dataframe in wide format. +Dataframe in wide format. } -\author{ - Johannes Ranke +\description{ +This function takes a dataframe in the long form, i.e. with a row for each +observed value, and converts it into a dataframe with one independent +variable and several dependent variables as columns. } \examples{ + mkin_long_to_wide(FOCUS_2006_D) + +} +\author{ +Johannes Ranke } -\keyword{ manip } diff --git a/man/mkin_wide_to_long.Rd b/man/mkin_wide_to_long.Rd index dc523755..402911d7 100644 --- a/man/mkin_wide_to_long.Rd +++ b/man/mkin_wide_to_long.Rd @@ -1,32 +1,33 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/mkin_wide_to_long.R \name{mkin_wide_to_long} \alias{mkin_wide_to_long} -\title{ - Convert a dataframe with observations over time into long format -} +\title{Convert a dataframe with observations over time into long format} \usage{ mkin_wide_to_long(wide_data, time = "t") } -\description{ - This function simply takes a dataframe with one independent variable and several - dependent variable and converts it into the long form as required by \code{\link{mkinfit}}. -} \arguments{ - \item{wide_data}{ - The dataframe must contain one variable with the time values specified by the - \code{time} argument and usually more than one column of observed values. -} - \item{time}{ - The name of the time variable. -} +\item{wide_data}{The dataframe must contain one variable with the time +values specified by the \code{time} argument and usually more than one +column of observed values.} + +\item{time}{The name of the time variable.} } \value{ - Dataframe in long format as needed for \code{\link{mkinfit}}. +Dataframe in long format as needed for \code{\link{mkinfit}}. } -\author{ - Johannes Ranke +\description{ +This function simply takes a dataframe with one independent variable and +several dependent variable and converts it into the long form as required by +\code{\link{mkinfit}}. } \examples{ + wide <- data.frame(t = c(1,2,3), x = c(1,4,7), y = c(3,4,5)) mkin_wide_to_long(wide) + +} +\author{ +Johannes Ranke } -\keyword{ manip } +\keyword{manip} diff --git a/man/mkinds.Rd b/man/mkinds.Rd index 239ab328..0ea562ed 100644 --- a/man/mkinds.Rd +++ b/man/mkinds.Rd @@ -1,3 +1,5 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/mkinds.R \docType{class} \name{mkinds} \alias{mkinds} @@ -11,24 +13,26 @@ A dataset class for mkin } \section{Fields}{ -\describe{ -\item{\code{title}}{A full title for the dataset} -\item{\code{sampling}}{times The sampling times} +\describe{ \item{list("title")}{A full title for the dataset} -\item{\code{time_unit}}{The time unit} +\item{list("sampling")}{times The sampling times} -\item{\code{observed}}{Names of the observed compounds} +\item{list("time_unit")}{The time unit} -\item{\code{unit}}{The unit of the observations} +\item{list("observed")}{Names of the observed compounds} -\item{\code{replicates}}{The number of replicates} +\item{list("unit")}{The unit of the observations} + +\item{list("replicates")}{The number of replicates} + +\item{list("data")}{A dataframe with at least the columns name, time and +value in order to be compatible with mkinfit} } +} -\item{\code{data}}{A dataframe with at least the columns name, time and value -in order to be compatible with mkinfit} -}} \examples{ + mds <- mkinds$new("FOCUS A", FOCUS_2006_A) + } \keyword{datasets} - diff --git a/man/mkinerrmin.Rd b/man/mkinerrmin.Rd index 25aba7c0..be929130 100644 --- a/man/mkinerrmin.Rd +++ b/man/mkinerrmin.Rd @@ -1,54 +1,52 @@ -\name{mkinerrmin} -\alias{mkinerrmin} -\title{ -Calculate the minimum error to assume in order to pass the variance test -} -\description{ -This function finds the smallest relative error still resulting in passing the -chi-squared test as defined in the FOCUS kinetics report from 2006. -} -\usage{ -mkinerrmin(fit, alpha = 0.05) -} -\arguments{ - \item{fit}{ - an object of class \code{\link{mkinfit}}. - } - \item{alpha}{ - The confidence level chosen for the chi-squared test. -} -} -\value{ - A dataframe with the following components: - \item{err.min}{The relative error, expressed as a fraction.} - \item{n.optim}{The number of optimised parameters attributed to the data series.} - \item{df}{The number of remaining degrees of freedom for the chi2 error level - calculations. Note that mean values are used for the chi2 statistic and - therefore every time point with observed values in the series only counts - one time.} - The dataframe has one row for the total dataset and one further row for - each observed state variable in the model. -} -\details{ - This function is used internally by \code{\link{summary.mkinfit}}. -} -\examples{ -SFO_SFO = mkinmod(parent = mkinsub("SFO", to = "m1"), - m1 = mkinsub("SFO"), - use_of_ff = "max") - -fit_FOCUS_D = mkinfit(SFO_SFO, FOCUS_2006_D, quiet = TRUE) -round(mkinerrmin(fit_FOCUS_D), 4) -\dontrun{ - fit_FOCUS_E = mkinfit(SFO_SFO, FOCUS_2006_E, quiet = TRUE) - round(mkinerrmin(fit_FOCUS_E), 4) -} -} -\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} -} -\keyword{ manip } +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/mkinerrmin.R +\name{mkinerrmin} +\alias{mkinerrmin} +\title{Calculate the minimum error to assume in order to pass the variance test} +\usage{ +mkinerrmin(fit, alpha = 0.05) +} +\arguments{ +\item{fit}{an object of class \code{\link{mkinfit}}.} + +\item{alpha}{The confidence level chosen for the chi-squared test.} +} +\value{ +A dataframe with the following components: \item{err.min}{The +relative error, expressed as a fraction.} \item{n.optim}{The number of +optimised parameters attributed to the data series.} \item{df}{The number of +remaining degrees of freedom for the chi2 error level calculations. Note +that mean values are used for the chi2 statistic and therefore every time +point with observed values in the series only counts one time.} The +dataframe has one row for the total dataset and one further row for each +observed state variable in the model. +} +\description{ +This function finds the smallest relative error still resulting in passing +the chi-squared test as defined in the FOCUS kinetics report from 2006. +} +\details{ +This function is used internally by \code{\link{summary.mkinfit}}. +} +\examples{ + +SFO_SFO = mkinmod(parent = mkinsub("SFO", to = "m1"), + m1 = mkinsub("SFO"), + use_of_ff = "max") + +fit_FOCUS_D = mkinfit(SFO_SFO, FOCUS_2006_D, quiet = TRUE) +round(mkinerrmin(fit_FOCUS_D), 4) +\dontrun{ + fit_FOCUS_E = mkinfit(SFO_SFO, FOCUS_2006_E, quiet = TRUE) + round(mkinerrmin(fit_FOCUS_E), 4) +} + +} +\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} +} +\keyword{manip} diff --git a/man/mkinerrplot.Rd b/man/mkinerrplot.Rd index 37338d01..3c53e7f8 100644 --- a/man/mkinerrplot.Rd +++ b/man/mkinerrplot.Rd @@ -1,81 +1,69 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/mkinerrplot.R \name{mkinerrplot} \alias{mkinerrplot} -\title{ - Function to plot squared residuals and the error model for an mkin object -} -\description{ - This function plots the squared residuals for the specified subset of the - observed variables from an mkinfit object. In addition, one or more - dashed line(s) show the fitted error model. - A combined plot of the fitted model and this error model plot can be - obtained with \code{\link{plot.mkinfit}} - using the argument \code{show_errplot = TRUE}. -} +\title{Function to plot squared residuals and the error model for an mkin object} \usage{ - mkinerrplot(object, - obs_vars = names(object$mkinmod$map), - xlim = c(0, 1.1 * max(object$data$predicted)), - xlab = "Predicted", ylab = "Squared residual", - maxy = "auto", legend= TRUE, lpos = "topright", - col_obs = "auto", pch_obs = "auto", - frame = TRUE, - ...) +mkinerrplot(object, obs_vars = names(object$mkinmod$map), xlim = c(0, + 1.1 * max(object$data$predicted)), xlab = "Predicted", + ylab = "Squared residual", maxy = "auto", legend = TRUE, + lpos = "topright", col_obs = "auto", pch_obs = "auto", + frame = TRUE, ...) } \arguments{ - \item{object}{ - A fit represented in an \code{\link{mkinfit}} object. - } - \item{obs_vars}{ - A character vector of names of the observed variables for which residuals - should be plotted. Defaults to all observed variables in the model - } - \item{xlim}{ - plot range in x direction. - } - \item{xlab}{ - Label for the x axis. - } - \item{ylab}{ - Label for the y axis. - } - \item{maxy}{ - Maximum value of the residuals. This is used for the scaling of - the y axis and defaults to "auto". - } - \item{legend}{ - Should a legend be plotted? - } - \item{lpos}{ - Where should the legend be placed? Default is "topright". Will be passed on to - \code{\link{legend}}. - } - \item{col_obs}{ - Colors for the observed variables. - } - \item{pch_obs}{ - Symbols to be used for the observed variables. - } - \item{frame}{ - Should a frame be drawn around the plots? - } - \item{\dots}{ - further arguments passed to \code{\link{plot}}. - } +\item{object}{A fit represented in an \code{\link{mkinfit}} object.} + +\item{obs_vars}{A character vector of names of the observed variables for +which residuals should be plotted. Defaults to all observed variables in +the model} + +\item{xlim}{plot range in x direction.} + +\item{xlab}{Label for the x axis.} + +\item{ylab}{Label for the y axis.} + +\item{maxy}{Maximum value of the residuals. This is used for the scaling of +the y axis and defaults to "auto".} + +\item{legend}{Should a legend be plotted?} + +\item{lpos}{Where should the legend be placed? Default is "topright". Will +be passed on to \code{\link{legend}}.} + +\item{col_obs}{Colors for the observed variables.} + +\item{pch_obs}{Symbols to be used for the observed variables.} + +\item{frame}{Should a frame be drawn around the plots?} + +\item{\dots}{further arguments passed to \code{\link{plot}}.} } \value{ - Nothing is returned by this function, as it is called for its side effect, namely to produce a plot. +Nothing is returned by this function, as it is called for its side + effect, namely to produce a plot. } -\author{ - Johannes Ranke +\description{ +This function plots the squared residuals for the specified subset of the +observed variables from an mkinfit object. In addition, one or more dashed +line(s) show the fitted error model. A combined plot of the fitted model +and this error model plot can be obtained with \code{\link{plot.mkinfit}} +using the argument \code{show_errplot = TRUE}. } -\seealso{ - \code{\link{mkinplot}}, for a way to plot the data and the fitted lines of the - mkinfit object. } \examples{ + \dontrun{ model <- mkinmod(parent = mkinsub("SFO", "m1"), m1 = mkinsub("SFO")) fit <- mkinfit(model, FOCUS_2006_D, error_model = "tc", quiet = TRUE) mkinerrplot(fit) } + +} +\seealso{ +\code{\link{mkinplot}}, for a way to plot the data and the fitted + lines of the mkinfit object. +} +\author{ +Johannes Ranke } -\keyword{ hplot } +\keyword{hplot} diff --git a/man/mkinfit.Rd b/man/mkinfit.Rd index 09af4918..d9afb753 100644 --- a/man/mkinfit.Rd +++ b/man/mkinfit.Rd @@ -1,253 +1,214 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/mkinfit.R \name{mkinfit} \alias{mkinfit} -\title{ - Fit a kinetic model to data with one or more state variables -} -\description{ - This function maximises the likelihood of the observed data using - the Port algorithm \code{\link{nlminb}}, and the specified initial or fixed - parameters and starting values. In each step of the optimsation, the kinetic - model is solved using the function \code{\link{mkinpredict}}. The parameters - of the selected error model are fitted simultaneously with the degradation - model parameters, as both of them are arguments of the likelihood function. - - Per default, parameters in the kinetic models are internally transformed in - order to better satisfy the assumption of a normal distribution of their - estimators. +\title{Fit a kinetic model to data with one or more state variables} +\source{ +Rocke, David M. und Lorenzato, Stefan (1995) A two-component model + for measurement error in analytical chemistry. Technometrics 37(2), 176-184. } \usage{ -mkinfit(mkinmod, observed, - parms.ini = "auto", - state.ini = "auto", - err.ini = "auto", - fixed_parms = NULL, fixed_initials = names(mkinmod$diffs)[-1], - from_max_mean = FALSE, +mkinfit(mkinmod, observed, parms.ini = "auto", state.ini = "auto", + err.ini = "auto", fixed_parms = NULL, + fixed_initials = names(mkinmod$diffs)[-1], from_max_mean = FALSE, solution_type = c("auto", "analytical", "eigen", "deSolve"), - method.ode = "lsoda", - use_compiled = "auto", + method.ode = "lsoda", use_compiled = "auto", control = list(eval.max = 300, iter.max = 200), - transform_rates = TRUE, - transform_fractions = TRUE, - quiet = FALSE, - atol = 1e-8, rtol = 1e-10, n.outtimes = 100, + transform_rates = TRUE, transform_fractions = TRUE, quiet = FALSE, + atol = 1e-08, rtol = 1e-10, n.outtimes = 100, error_model = c("const", "obs", "tc"), - error_model_algorithm = c("auto", "d_3", "direct", "twostep", "threestep", - "fourstep", "IRLS", "OLS"), - reweight.tol = 1e-8, reweight.max.iter = 10, - trace_parms = FALSE, ...) + error_model_algorithm = c("auto", "d_3", "direct", "twostep", + "threestep", "fourstep", "IRLS", "OLS"), reweight.tol = 1e-08, + reweight.max.iter = 10, trace_parms = FALSE, ...) } \arguments{ - \item{mkinmod}{ - A list of class \code{\link{mkinmod}}, containing the kinetic model to be - fitted to the data, or one of the shorthand names ("SFO", "FOMC", "DFOP", - "HS", "SFORB", "IORE"). If a shorthand name is given, a parent only degradation - model is generated for the variable with the highest value in - \code{observed}. - } - \item{observed}{ - A dataframe with the observed data. The first column called "name" must - contain the name of the observed variable for each data point. The second - column must contain the times of observation, named "time". The third - column must be named "value" and contain the observed values. Zero values - in the "value" column will be removed, with a warning, in order to - avoid problems with fitting the two-component error model. This is not - expected to be a problem, because in general, values of zero are not - observed in degradation data, because there is a lower limit of detection. - } - \item{parms.ini}{ - A named vector of initial values for the parameters, including parameters - to be optimised and potentially also fixed parameters as indicated by - \code{fixed_parms}. If set to "auto", initial values for rate constants - are set to default values. Using parameter names that are not in the model - gives an error. - - It is possible to only specify a subset of the parameters that the model - needs. You can use the parameter lists "bparms.ode" from a previously - fitted model, which contains the differential equation parameters from this - model. This works nicely if the models are nested. An example is given - below. - } - \item{state.ini}{ - A named vector of initial values for the state variables of the model. In - case the observed variables are represented by more than one model - variable, the names will differ from the names of the observed variables - (see \code{map} component of \code{\link{mkinmod}}). The default is to set - the initial value of the first model variable to the mean of the time zero - values for the variable with the maximum observed value, and all others to 0. - If this variable has no time zero observations, its initial value is set to 100. - } - \item{err.ini}{ - A named vector of initial values for the error model parameters to be - optimised. If set to "auto", initial values are set to default values. - Otherwise, inital values for all error model parameters must be - given. - } - \item{fixed_parms}{ - The names of parameters that should not be optimised but rather kept at the - values specified in \code{parms.ini}. - } - \item{fixed_initials}{ - The names of model variables for which the initial state at time 0 should - be excluded from the optimisation. Defaults to all state variables except - for the first one. - } - \item{from_max_mean}{ - If this is set to TRUE, and the model has only one observed variable, then - data before the time of the maximum observed value (after averaging for each - sampling time) are discarded, and this time is subtracted from all - remaining time values, so the time of the maximum observed mean value is - the new time zero. - } - \item{solution_type}{ - If set to "eigen", the solution of the system of differential equations is - based on the spectral decomposition of the coefficient matrix in cases that - this is possible. If set to "deSolve", a numerical ode solver from package - \code{\link{deSolve}} is used. If set to "analytical", an analytical - solution of the model is used. This is only implemented for simple - degradation experiments with only one state variable, i.e. with no - metabolites. The default is "auto", which uses "analytical" if possible, - otherwise "deSolve" if a compiler is present, and "eigen" if no - compiler is present and the model can be expressed using eigenvalues and - eigenvectors. This argument is passed on to the helper function - \code{\link{mkinpredict}}. - } - \item{method.ode}{ - The solution method passed via \code{\link{mkinpredict}} to - \code{\link{ode}} in case the solution type is "deSolve". The default - "lsoda" is performant, but sometimes fails to converge. - } - \item{use_compiled}{ - If set to \code{FALSE}, no compiled version of the \code{\link{mkinmod}} - model is used in the calls to \code{\link{mkinpredict}} even if a compiled - version is present. - } - \item{control}{ - A list of control arguments passed to \code{\link{nlminb}}. - } - \item{transform_rates}{ - Boolean specifying if kinetic rate constants should be transformed in the - model specification used in the fitting for better compliance with the - assumption of normal distribution of the estimator. If TRUE, also - alpha and beta parameters of the FOMC model are log-transformed, as well - as k1 and k2 rate constants for the DFOP and HS models and the break point - tb of the HS model. If FALSE, zero is used as a lower bound for the rates - in the optimisation. - } - \item{transform_fractions}{ - Boolean specifying if formation fractions constants should be transformed in the - model specification used in the fitting for better compliance with the - assumption of normal distribution of the estimator. The default (TRUE) is - to do transformations. If TRUE, the g parameter of the DFOP and HS - models are also transformed, as they can also be seen as compositional - data. The transformation used for these transformations is the - \code{\link{ilr}} transformation. - } - \item{quiet}{ - Suppress printing out the current value of the negative log-likelihood - after each improvement? - } - \item{atol}{ - Absolute error tolerance, passed to \code{\link{ode}}. Default is 1e-8, - lower than in \code{\link{lsoda}}. - } - \item{rtol}{ - Absolute error tolerance, passed to \code{\link{ode}}. Default is 1e-10, - much lower than in \code{\link{lsoda}}. - } - \item{n.outtimes}{ - The length of the dataseries that is produced by the model prediction - function \code{\link{mkinpredict}}. This impacts the accuracy of - the numerical solver if that is used (see \code{solution_type} argument. - The default value is 100. - } - \item{error_model}{ - If the error model is "const", a constant standard deviation - is assumed. - - If the error model is "obs", each observed variable is assumed to have its - own variance. - - If the error model is "tc" (two-component error model), a two component - error model similar to the one described by Rocke and Lorenzato (1995) is - used for setting up the likelihood function. Note that this model deviates - from the model by Rocke and Lorenzato, as their model implies that the - errors follow a lognormal distribution for large values, not a normal - distribution as assumed by this method. - } - \item{error_model_algorithm}{ - If "auto", the selected algorithm depends on the error model. - If the error model is "const", unweighted nonlinear least squares fitting - ("OLS") is selected. If the error model is "obs", or "tc", the "d_3" - algorithm is selected. - - The algorithm "d_3" will directly minimize the negative - log-likelihood and - independently - also use the three step algorithm - described below. The fit with the higher likelihood is returned. - - The algorithm "direct" will directly minimize the negative - log-likelihood. - - The algorithm "twostep" will minimize the negative log-likelihood - after an initial unweighted least squares optimisation step. - - The algorithm "threestep" starts with unweighted least squares, - then optimizes only the error model using the degradation model - parameters found, and then minimizes the negative log-likelihood - with free degradation and error model parameters. - - The algorithm "fourstep" starts with unweighted least squares, - then optimizes only the error model using the degradation model - parameters found, then optimizes the degradation model again - with fixed error model parameters, and finally minimizes the negative - log-likelihood with free degradation and error model parameters. - - The algorithm "IRLS" (Iteratively Reweighted Least Squares) starts with - unweighted least squares, and then iterates optimization of the error model - parameters and subsequent - optimization of the degradation model using those error model parameters, - until the error model parameters converge. - } - \item{reweight.tol}{ - Tolerance for the convergence criterion calculated from the error model - parameters in IRLS fits. - } - \item{reweight.max.iter}{ - Maximum number of iterations in IRLS fits. - } - \item{trace_parms}{ - Should a trace of the parameter values be listed? - } - \item{\dots}{ - Further arguments that will be passed on to \code{\link{deSolve}}. - } +\item{mkinmod}{A list of class \code{\link{mkinmod}}, containing the kinetic +model to be fitted to the data, or one of the shorthand names ("SFO", +"FOMC", "DFOP", "HS", "SFORB", "IORE"). If a shorthand name is given, a +parent only degradation model is generated for the variable with the +highest value in \code{observed}.} + +\item{observed}{A dataframe with the observed data. The first column called +"name" must contain the name of the observed variable for each data point. +The second column must contain the times of observation, named "time". +The third column must be named "value" and contain the observed values. +Zero values in the "value" column will be removed, with a warning, in +order to avoid problems with fitting the two-component error model. This +is not expected to be a problem, because in general, values of zero are +not observed in degradation data, because there is a lower limit of +detection.} + +\item{parms.ini}{A named vector of initial values for the parameters, + including parameters to be optimised and potentially also fixed parameters + as indicated by \code{fixed_parms}. If set to "auto", initial values for + rate constants are set to default values. Using parameter names that are + not in the model gives an error. + + It is possible to only specify a subset of the parameters that the model + needs. You can use the parameter lists "bparms.ode" from a previously + fitted model, which contains the differential equation parameters from + this model. This works nicely if the models are nested. An example is + given below.} + +\item{state.ini}{A named vector of initial values for the state variables of +the model. In case the observed variables are represented by more than one +model variable, the names will differ from the names of the observed +variables (see \code{map} component of \code{\link{mkinmod}}). The default +is to set the initial value of the first model variable to the mean of the +time zero values for the variable with the maximum observed value, and all +others to 0. If this variable has no time zero observations, its initial +value is set to 100.} + +\item{err.ini}{A named vector of initial values for the error model +parameters to be optimised. If set to "auto", initial values are set to +default values. Otherwise, inital values for all error model parameters +must be given.} + +\item{fixed_parms}{The names of parameters that should not be optimised but +rather kept at the values specified in \code{parms.ini}.} + +\item{fixed_initials}{The names of model variables for which the initial +state at time 0 should be excluded from the optimisation. Defaults to all +state variables except for the first one.} + +\item{from_max_mean}{If this is set to TRUE, and the model has only one +observed variable, then data before the time of the maximum observed value +(after averaging for each sampling time) are discarded, and this time is +subtracted from all remaining time values, so the time of the maximum +observed mean value is the new time zero.} + +\item{solution_type}{If set to "eigen", the solution of the system of +differential equations is based on the spectral decomposition of the +coefficient matrix in cases that this is possible. If set to "deSolve", a +numerical ode solver from package \code{\link{deSolve}} is used. If set to +"analytical", an analytical solution of the model is used. This is only +implemented for simple degradation experiments with only one state +variable, i.e. with no metabolites. The default is "auto", which uses +"analytical" if possible, otherwise "deSolve" if a compiler is present, +and "eigen" if no compiler is present and the model can be expressed using +eigenvalues and eigenvectors. This argument is passed on to the helper +function \code{\link{mkinpredict}}.} + +\item{method.ode}{The solution method passed via \code{\link{mkinpredict}} +to \code{\link{ode}} in case the solution type is "deSolve". The default +"lsoda" is performant, but sometimes fails to converge.} + +\item{use_compiled}{If set to \code{FALSE}, no compiled version of the +\code{\link{mkinmod}} model is used in the calls to +\code{\link{mkinpredict}} even if a compiled version is present.} + +\item{control}{A list of control arguments passed to \code{\link{nlminb}}.} + +\item{transform_rates}{Boolean specifying if kinetic rate constants should +be transformed in the model specification used in the fitting for better +compliance with the assumption of normal distribution of the estimator. If +TRUE, also alpha and beta parameters of the FOMC model are +log-transformed, as well as k1 and k2 rate constants for the DFOP and HS +models and the break point tb of the HS model. If FALSE, zero is used as +a lower bound for the rates in the optimisation.} + +\item{transform_fractions}{Boolean specifying if formation fractions +constants should be transformed in the model specification used in the +fitting for better compliance with the assumption of normal distribution +of the estimator. The default (TRUE) is to do transformations. If TRUE, +the g parameter of the DFOP and HS models are also transformed, as they +can also be seen as compositional data. The transformation used for these +transformations is the \code{\link{ilr}} transformation.} + +\item{quiet}{Suppress printing out the current value of the negative +log-likelihood after each improvement?} + +\item{atol}{Absolute error tolerance, passed to \code{\link{ode}}. Default +is 1e-8, lower than in \code{\link{lsoda}}.} + +\item{rtol}{Absolute error tolerance, passed to \code{\link{ode}}. Default +is 1e-10, much lower than in \code{\link{lsoda}}.} + +\item{n.outtimes}{The length of the dataseries that is produced by the model +prediction function \code{\link{mkinpredict}}. This impacts the accuracy +of the numerical solver if that is used (see \code{solution_type} +argument. The default value is 100.} + +\item{error_model}{If the error model is "const", a constant standard + deviation is assumed. + + If the error model is "obs", each observed variable is assumed to have its + own variance. + + If the error model is "tc" (two-component error model), a two component + error model similar to the one described by Rocke and Lorenzato (1995) is + used for setting up the likelihood function. Note that this model + deviates from the model by Rocke and Lorenzato, as their model implies + that the errors follow a lognormal distribution for large values, not a + normal distribution as assumed by this method.} + +\item{error_model_algorithm}{If "auto", the selected algorithm depends on + the error model. If the error model is "const", unweighted nonlinear + least squares fitting ("OLS") is selected. If the error model is "obs", or + "tc", the "d_3" algorithm is selected. + + The algorithm "d_3" will directly minimize the negative log-likelihood and + - independently - also use the three step algorithm described below. The + fit with the higher likelihood is returned. + + The algorithm "direct" will directly minimize the negative log-likelihood. + + The algorithm "twostep" will minimize the negative log-likelihood after an + initial unweighted least squares optimisation step. + + The algorithm "threestep" starts with unweighted least squares, then + optimizes only the error model using the degradation model parameters + found, and then minimizes the negative log-likelihood with free + degradation and error model parameters. + + The algorithm "fourstep" starts with unweighted least squares, then + optimizes only the error model using the degradation model parameters + found, then optimizes the degradation model again with fixed error model + parameters, and finally minimizes the negative log-likelihood with free + degradation and error model parameters. + + The algorithm "IRLS" (Iteratively Reweighted Least Squares) starts with + unweighted least squares, and then iterates optimization of the error + model parameters and subsequent optimization of the degradation model + using those error model parameters, until the error model parameters + converge.} + +\item{reweight.tol}{Tolerance for the convergence criterion calculated from +the error model parameters in IRLS fits.} + +\item{reweight.max.iter}{Maximum number of iterations in IRLS fits.} + +\item{trace_parms}{Should a trace of the parameter values be listed?} + +\item{\dots}{Further arguments that will be passed on to +\code{\link{deSolve}}.} } \value{ - A list with "mkinfit" in the class attribute. A summary can be obtained by - \code{\link{summary.mkinfit}}. +A list with "mkinfit" in the class attribute. A summary can be + obtained by \code{\link{summary.mkinfit}}. } -\seealso{ - Plotting methods \code{\link{plot.mkinfit}} and \code{\link{mkinparplot}}. - - Comparisons of models fitted to the same data can be made using \code{\link{AIC}} - by virtue of the method \code{\link{logLik.mkinfit}}. - - Fitting of several models to several datasets in a single call to - \code{\link{mmkin}}. +\description{ +This function maximises the likelihood of the observed data using the Port +algorithm \code{\link{nlminb}}, and the specified initial or fixed +parameters and starting values. In each step of the optimsation, the +kinetic model is solved using the function \code{\link{mkinpredict}}. The +parameters of the selected error model are fitted simultaneously with the +degradation model parameters, as both of them are arguments of the +likelihood function. +} +\details{ +Per default, parameters in the kinetic models are internally transformed in +order to better satisfy the assumption of a normal distribution of their +estimators. } \note{ - When using the "IORE" submodel for metabolites, fitting with +When using the "IORE" submodel for metabolites, fitting with "transform_rates = TRUE" (the default) often leads to failures of the numerical ODE solver. In this situation it may help to switch off the internal rate transformation. } -\source{ - Rocke, David M. und Lorenzato, Stefan (1995) A two-component model for - measurement error in analytical chemistry. Technometrics 37(2), 176-184. -} -\author{ - Johannes Ranke -} \examples{ + # Use shorthand notation for parent only degradation fit <- mkinfit("FOMC", FOCUS_2006_C, quiet = TRUE) summary(fit) @@ -307,5 +268,18 @@ f.tc <- mkinfit(SFO_SFO.ff, FOCUS_2006_D, error_model = "tc", quiet = TRUE) summary(f.tc) } + +} +\seealso{ +Plotting methods \code{\link{plot.mkinfit}} and + \code{\link{mkinparplot}}. + + Comparisons of models fitted to the same data can be made using + \code{\link{AIC}} by virtue of the method \code{\link{logLik.mkinfit}}. + + Fitting of several models to several datasets in a single call to + \code{\link{mmkin}}. +} +\author{ +Johannes Ranke } -\keyword{ optimize } diff --git a/man/mkinmod.Rd b/man/mkinmod.Rd index 62b02775..91f285e2 100644 --- a/man/mkinmod.Rd +++ b/man/mkinmod.Rd @@ -1,115 +1,123 @@ -\name{mkinmod} -\alias{mkinmod} -\title{ - Function to set up a kinetic model with one or more state variables -} -\description{ - The function usually takes several expressions, each assigning a compound name to - a list, specifying the kinetic model type and reaction or transfer to other - observed compartments. Instead of specifying several expressions, a list - of lists can be given in the speclist argument. - - For the definition of model types and their parameters, the equations given - in the FOCUS and NAFTA guidance documents are used. -} -\usage{ -mkinmod(..., use_of_ff = "min", speclist = NULL, quiet = FALSE, verbose = FALSE) -} -\arguments{ - \item{...}{ - For each observed variable, a list has to be specified as an argument, containing - at least a component \code{type}, specifying the type of kinetics to use - for the variable. Currently, single first order kinetics "SFO", - indeterminate order rate equation kinetics "IORE", or - single first order with reversible binding "SFORB" are implemented for all - variables, while - "FOMC", "DFOP" and "HS" can additionally be chosen for the first - variable which is assumed to be the source compartment. - Additionally, each component of the list can include a character vector \code{to}, - specifying names of variables to which a transfer is to be assumed in the - model. - If the argument \code{use_of_ff} is set to "min" (default) and the model for - the compartment is "SFO" or "SFORB", an additional component of the list - can be "sink=FALSE" effectively fixing the flux to sink to zero. - } - \item{use_of_ff}{ - Specification of the use of formation fractions in the model equations and, if - applicable, the coefficient matrix. If "min", a minimum use of formation - fractions is made in order to avoid fitting the product of formation fractions - and rate constants. If "max", formation fractions are always used. - } - \item{speclist}{ - The specification of the observed variables and their submodel types and - pathways can be given as a single list using this argument. Default is NULL. - } - \item{quiet}{ - Should messages be suppressed? - } - \item{verbose}{ - If \code{TRUE}, passed to \code{\link{cfunction}} if applicable to give - detailed information about the C function being built. - } -} -\value{ - A list of class \code{mkinmod} for use with \code{\link{mkinfit}}, containing - \item{diffs}{ A vector of string representations of differential equations, - one for each modelling variable. } - \item{parms}{ A vector of parameter names occurring in the differential equations. } - \item{map}{ A list containing named character vectors for each observed variable, specifying - the modelling variables by which it is represented. } - \item{use_of_ff}{ The content of \code{use_of_ff} is passed on in this list component. } - \item{coefmat}{ The coefficient matrix, if the system of differential equations can be - represented by one. } -} -\note{ - The IORE submodel is not well tested (yet). When using this model for metabolites, - you may want to read the second note in the help page to - \code{\link{mkinfit}}. -} -\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} - - NAFTA Technical Working Group on Pesticides (not dated) Guidance for - Evaluating and Calculating Degradation Kinetics in Environmental - Media -} -\author{ - Johannes Ranke -} -\examples{ -# Specify the SFO model (this is not needed any more, as we can now mkinfit("SFO", ...) -SFO <- mkinmod(parent = list(type = "SFO")) - -# One parent compound, one metabolite, both single first order -SFO_SFO <- mkinmod( - parent = mkinsub("SFO", "m1"), - m1 = mkinsub("SFO")) - -\dontrun{ -# The above model used to be specified like this, before the advent of mkinsub() -SFO_SFO <- mkinmod( - parent = list(type = "SFO", to = "m1"), - m1 = list(type = "SFO")) - -# Show details of creating the C function -SFO_SFO <- mkinmod( - parent = mkinsub("SFO", "m1"), - m1 = mkinsub("SFO"), verbose = TRUE) - -# If we have several parallel metabolites -# (compare tests/testthat/test_synthetic_data_for_UBA_2014.R) -m_synth_DFOP_par <- mkinmod(parent = mkinsub("DFOP", c("M1", "M2")), - M1 = mkinsub("SFO"), - M2 = mkinsub("SFO"), - use_of_ff = "max", quiet = TRUE) - -fit_DFOP_par_c <- mkinfit(m_synth_DFOP_par, - synthetic_data_for_UBA_2014[[12]]$data, - quiet = TRUE) -} -} -\keyword{ models } +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/mkinmod.R +\name{mkinmod} +\alias{mkinmod} +\title{Function to set up a kinetic model with one or more state variables} +\usage{ +mkinmod(..., use_of_ff = "min", speclist = NULL, quiet = FALSE, + verbose = FALSE) +} +\arguments{ +\item{...}{For each observed variable, a list has to be specified as an +argument, containing at least a component \code{type}, specifying the type +of kinetics to use for the variable. Currently, single first order +kinetics "SFO", indeterminate order rate equation kinetics "IORE", or +single first order with reversible binding "SFORB" are implemented for all +variables, while "FOMC", "DFOP" and "HS" can additionally be chosen for +the first variable which is assumed to be the source compartment. +Additionally, each component of the list can include a character vector +\code{to}, specifying names of variables to which a transfer is to be +assumed in the model. If the argument \code{use_of_ff} is set to "min" +(default) and the model for the compartment is "SFO" or "SFORB", an +additional component of the list can be "sink=FALSE" effectively fixing +the flux to sink to zero.} + +\item{use_of_ff}{Specification of the use of formation fractions in the +model equations and, if applicable, the coefficient matrix. If "min", a +minimum use of formation fractions is made in order to avoid fitting the +product of formation fractions and rate constants. If "max", formation +fractions are always used.} + +\item{speclist}{The specification of the observed variables and their +submodel types and pathways can be given as a single list using this +argument. Default is NULL.} + +\item{quiet}{Should messages be suppressed?} + +\item{verbose}{If \code{TRUE}, passed to \code{\link{cfunction}} if +applicable to give detailed information about the C function being built.} +} +\value{ +A list of class \code{mkinmod} for use with \code{\link{mkinfit}}, + containing, among others, + \item{diffs}{ + A vector of string representations of differential equations, one for + each modelling variable. + } + \item{map}{ + A list containing named character vectors for each observed variable, + specifying the modelling variables by which it is represented. + } + \item{use_of_ff}{ + The content of \code{use_of_ff} is passed on in this list component. + } + \item{coefmat}{ + The coefficient matrix, if the system of differential equations can be + represented by one. + } + \item{ll}{ + The likelihood function, taking the parameter vector as the first argument. + } +} +\description{ +The function usually takes several expressions, each assigning a compound +name to a list, specifying the kinetic model type and reaction or transfer +to other observed compartments. Instead of specifying several expressions, a +list of lists can be given in the speclist argument. +} +\details{ +For the definition of model types and their parameters, the equations given +in the FOCUS and NAFTA guidance documents are used. +} +\note{ +The IORE submodel is not well tested for metabolites. When using this + model for metabolites, you may want to read the second note in the help + page to \code{\link{mkinfit}}. +} +\examples{ + +# Specify the SFO model (this is not needed any more, as we can now mkinfit("SFO", ...) +SFO <- mkinmod(parent = list(type = "SFO")) + +# One parent compound, one metabolite, both single first order +SFO_SFO <- mkinmod( + parent = mkinsub("SFO", "m1"), + m1 = mkinsub("SFO")) + +\dontrun{ +# The above model used to be specified like this, before the advent of mkinsub() +SFO_SFO <- mkinmod( + parent = list(type = "SFO", to = "m1"), + m1 = list(type = "SFO")) + +# Show details of creating the C function +SFO_SFO <- mkinmod( + parent = mkinsub("SFO", "m1"), + m1 = mkinsub("SFO"), verbose = TRUE) + +# If we have several parallel metabolites +# (compare tests/testthat/test_synthetic_data_for_UBA_2014.R) +m_synth_DFOP_par <- mkinmod(parent = mkinsub("DFOP", c("M1", "M2")), + M1 = mkinsub("SFO"), + M2 = mkinsub("SFO"), + use_of_ff = "max", quiet = TRUE) + +fit_DFOP_par_c <- mkinfit(m_synth_DFOP_par, + synthetic_data_for_UBA_2014[[12]]$data, + quiet = TRUE) +} + +} +\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} + + NAFTA Technical Working Group on Pesticides (not dated) Guidance for + Evaluating and Calculating Degradation Kinetics in Environmental Media +} +\author{ +Johannes Ranke +} diff --git a/man/mkinparplot.Rd b/man/mkinparplot.Rd index a880151d..975a0203 100644 --- a/man/mkinparplot.Rd +++ b/man/mkinparplot.Rd @@ -1,34 +1,33 @@ -\name{mkinparplot} -\alias{mkinparplot} -\title{ - Function to plot the confidence intervals obtained using mkinfit -} -\description{ - This function plots the confidence intervals for the parameters - fitted using \code{\link{mkinfit}}. -} -\usage{ - mkinparplot(object) -} -\arguments{ - \item{object}{ - A fit represented in an \code{\link{mkinfit}} object. - } -} -\value{ - Nothing is returned by this function, as it is called for its side effect, namely to produce a plot. -} -\author{ - Johannes Ranke -} - -\examples{ -\dontrun{ -model <- mkinmod( - T245 = mkinsub("SFO", to = c("phenol"), sink = FALSE), - phenol = mkinsub("SFO", to = c("anisole")), - anisole = mkinsub("SFO"), use_of_ff = "max") -fit <- mkinfit(model, subset(mccall81_245T, soil == "Commerce"), quiet = TRUE) -mkinparplot(fit) -}} -\keyword{ hplot } +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/mkinparplot.R +\name{mkinparplot} +\alias{mkinparplot} +\title{Function to plot the confidence intervals obtained using mkinfit} +\usage{ +mkinparplot(object) +} +\arguments{ +\item{object}{A fit represented in an \code{\link{mkinfit}} object.} +} +\value{ +Nothing is returned by this function, as it is called for its side + effect, namely to produce a plot. +} +\description{ +This function plots the confidence intervals for the parameters fitted using +\code{\link{mkinfit}}. +} +\examples{ + +\dontrun{ +model <- mkinmod( + T245 = mkinsub("SFO", to = c("phenol"), sink = FALSE), + phenol = mkinsub("SFO", to = c("anisole")), + anisole = mkinsub("SFO"), use_of_ff = "max") +fit <- mkinfit(model, subset(mccall81_245T, soil == "Commerce"), quiet = TRUE) +mkinparplot(fit) +} +} +\author{ +Johannes Ranke +} diff --git a/man/mkinplot.Rd b/man/mkinplot.Rd index 50654004..3eade395 100644 --- a/man/mkinplot.Rd +++ b/man/mkinplot.Rd @@ -1,25 +1,23 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/plot.mkinfit.R \name{mkinplot} \alias{mkinplot} -\title{ - Plot the observed data and the fitted model of an mkinfit object -} -\description{ - Deprecated function. It now only calls the plot method \code{\link{plot.mkinfit}}. -} +\title{Plot the observed data and the fitted model of an mkinfit object} \usage{ - mkinplot(fit, ...) +mkinplot(fit, ...) } \arguments{ - \item{fit}{ - an object of class \code{\link{mkinfit}}. - } - \item{\dots}{ - further arguments passed to \code{\link{plot.mkinfit}}. -} +\item{fit}{an object of class \code{\link{mkinfit}}.} + +\item{\dots}{further arguments passed to \code{\link{plot.mkinfit}}.} } \value{ - The function is called for its side effect. +The function is called for its side effect. +} +\description{ +Deprecated function. It now only calls the plot method +\code{\link{plot.mkinfit}}. } \author{ - Johannes Ranke +Johannes Ranke } diff --git a/man/mkinpredict.Rd b/man/mkinpredict.Rd index 24b918dc..53f02dea 100644 --- a/man/mkinpredict.Rd +++ b/man/mkinpredict.Rd @@ -1,78 +1,80 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/mkinpredict.R \name{mkinpredict} \alias{mkinpredict} \alias{mkinpredict.mkinmod} \alias{mkinpredict.mkinfit} -\title{ - Produce predictions from a kinetic model using specific parameters -} -\description{ - This function produces a time series for all the observed variables in a - kinetic model as specified by \code{\link{mkinmod}}, using a specific set of - kinetic parameters and initial values for the state variables. -} +\title{Produce predictions from a kinetic model using specific parameters} \usage{ - mkinpredict(x, odeparms, odeini, outtimes = seq(0, 120, by = 0.1), - solution_type = "deSolve", use_compiled = "auto", method.ode = "lsoda", - atol = 1e-08, rtol = 1e-10, map_output = TRUE, ...) +mkinpredict(x, odeparms, odeini, outtimes = seq(0, 120, by = 0.1), + solution_type = "deSolve", use_compiled = "auto", + method.ode = "lsoda", atol = 1e-08, rtol = 1e-10, + map_output = TRUE, ...) + +\method{mkinpredict}{mkinmod}(x, odeparms = c(k_parent_sink = 0.1), + odeini = c(parent = 100), outtimes = seq(0, 120, by = 0.1), + solution_type = "deSolve", use_compiled = "auto", + method.ode = "lsoda", atol = 1e-08, rtol = 1e-10, + map_output = TRUE, ...) + +\method{mkinpredict}{mkinfit}(x, odeparms = x$bparms.ode, + odeini = x$bparms.state, outtimes = seq(0, 120, by = 0.1), + solution_type = "deSolve", use_compiled = "auto", + method.ode = "lsoda", atol = 1e-08, rtol = 1e-10, + map_output = TRUE, ...) } \arguments{ - \item{x}{ - A kinetic model as produced by \code{\link{mkinmod}}, or a kinetic - fit as fitted by \code{\link{mkinfit}}. In the latter case, the fitted - parameters are used for the prediction. - } - \item{odeparms}{ - A numeric vector specifying the parameters used in the kinetic model, which - is generally defined as a set of ordinary differential equations. - } - \item{odeini}{ - A numeric vectory containing the initial values of the state variables of - the model. Note that the state variables can differ from the observed - variables, for example in the case of the SFORB model. - } - \item{outtimes}{ - A numeric vector specifying the time points for which model predictions - should be generated. - } - \item{solution_type}{ - The method that should be used for producing the predictions. This should - generally be "analytical" if there is only one observed variable, and - usually "deSolve" in the case of several observed variables. The third - possibility "eigen" is faster but not applicable to some models e.g. - using FOMC for the parent compound. - } - \item{method.ode}{ - The solution method passed via \code{\link{mkinpredict}} to - \code{\link{ode}} in case the solution type is "deSolve". The default - "lsoda" is performant, but sometimes fails to converge. - } - \item{use_compiled}{ - If set to \code{FALSE}, no compiled version of the \code{\link{mkinmod}} - model is used, even if is present. - } - \item{atol}{ - Absolute error tolerance, passed to \code{\link{ode}}. Default is 1e-8, - lower than in \code{\link{lsoda}}. - } - \item{rtol}{ - Absolute error tolerance, passed to \code{\link{ode}}. Default is 1e-10, - much lower than in \code{\link{lsoda}}. - } - \item{map_output}{ - Boolean to specify if the output should list values for the observed - variables (default) or for all state variables (if set to FALSE). - } - \item{\dots}{ - Further arguments passed to the ode solver in case such a solver is used. - } +\item{x}{A kinetic model as produced by \code{\link{mkinmod}}, or a kinetic +fit as fitted by \code{\link{mkinfit}}. In the latter case, the fitted +parameters are used for the prediction.} + +\item{odeparms}{A numeric vector specifying the parameters used in the +kinetic model, which is generally defined as a set of ordinary +differential equations.} + +\item{odeini}{A numeric vectory containing the initial values of the state +variables of the model. Note that the state variables can differ from the +observed variables, for example in the case of the SFORB model.} + +\item{outtimes}{A numeric vector specifying the time points for which model +predictions should be generated.} + +\item{solution_type}{The method that should be used for producing the +predictions. This should generally be "analytical" if there is only one +observed variable, and usually "deSolve" in the case of several observed +variables. The third possibility "eigen" is faster but not applicable to +some models e.g. using FOMC for the parent compound.} + +\item{use_compiled}{If set to \code{FALSE}, no compiled version of the +\code{\link{mkinmod}} model is used, even if is present.} + +\item{method.ode}{The solution method passed via \code{\link{mkinpredict}} +to \code{\link{ode}} in case the solution type is "deSolve". The default +"lsoda" is performant, but sometimes fails to converge.} + +\item{atol}{Absolute error tolerance, passed to \code{\link{ode}}. Default +is 1e-8, lower than in \code{\link{lsoda}}.} + +\item{rtol}{Absolute error tolerance, passed to \code{\link{ode}}. Default +is 1e-10, much lower than in \code{\link{lsoda}}.} + +\item{map_output}{Boolean to specify if the output should list values for +the observed variables (default) or for all state variables (if set to +FALSE).} + +\item{\dots}{Further arguments passed to the ode solver in case such a +solver is used.} } \value{ - A matrix in the same format as the output of \code{\link{ode}}. +A matrix in the same format as the output of \code{\link{ode}}. } -\author{ - Johannes Ranke +\description{ +This function produces a time series for all the observed variables in a +kinetic model as specified by \code{\link{mkinmod}}, using a specific set of +kinetic parameters and initial values for the state variables. } \examples{ + SFO <- mkinmod(degradinol = mkinsub("SFO")) # Compare solution types mkinpredict(SFO, c(k_degradinol_sink = 0.3), c(degradinol = 100), 0:20, @@ -124,5 +126,8 @@ f <- mkinfit(SFO_SFO, FOCUS_2006_C) head(mkinpredict(f)) } + +} +\author{ +Johannes Ranke } -\keyword{ manip } diff --git a/man/mkinresplot.Rd b/man/mkinresplot.Rd index e788d836..27e1322f 100644 --- a/man/mkinresplot.Rd +++ b/man/mkinresplot.Rd @@ -1,76 +1,65 @@ -\name{mkinresplot} -\alias{mkinresplot} -\title{ - Function to plot residuals stored in an mkin object -} -\description{ - This function plots the residuals for the specified subset of the - observed variables from an mkinfit object. A combined plot of the fitted - model and the residuals can be obtained using \code{\link{plot.mkinfit}} - using the argument \code{show_residuals = TRUE}. -} -\usage{ - mkinresplot(object, - obs_vars = names(object$mkinmod$map), - xlim = c(0, 1.1 * max(object$data$time)), - xlab = "Time", ylab = "Residual", - maxabs = "auto", legend = TRUE, lpos = "topright", - col_obs = "auto", pch_obs = "auto", - frame = TRUE, - ...) -} -\arguments{ - \item{object}{ - A fit represented in an \code{\link{mkinfit}} object. - } - \item{obs_vars}{ - A character vector of names of the observed variables for which residuals - should be plotted. Defaults to all observed variables in the model - } - \item{xlim}{ - plot range in x direction. - } - \item{xlab}{ - Label for the x axis. Defaults to "Time [days]". - } - \item{ylab}{ - Label for the y axis. Defaults to "Residual [\% of applied radioactivity]". - } - \item{maxabs}{ - Maximum absolute value of the residuals. This is used for the scaling of - the y axis and defaults to "auto". - } - \item{legend}{ - Should a legend be plotted? Defaults to "TRUE". - } - \item{lpos}{ - Where should the legend be placed? Default is "topright". Will be passed on to - \code{\link{legend}}. } - \item{col_obs}{ - Colors for the observed variables. - } - \item{pch_obs}{ - Symbols to be used for the observed variables. - } - \item{frame}{ - Should a frame be drawn around the plots? - } - \item{\dots}{ - further arguments passed to \code{\link{plot}}. - } -} -\value{ - Nothing is returned by this function, as it is called for its side effect, namely to produce a plot. -} -\author{ - Johannes Ranke -} -\seealso{ - \code{\link{mkinplot}}, for a way to plot the data and the fitted lines of the - mkinfit object. } -\examples{ -model <- mkinmod(parent = mkinsub("SFO", "m1"), m1 = mkinsub("SFO")) -fit <- mkinfit(model, FOCUS_2006_D, quiet = TRUE) -mkinresplot(fit, "m1") -} -\keyword{ hplot } +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/mkinresplot.R +\name{mkinresplot} +\alias{mkinresplot} +\title{Function to plot residuals stored in an mkin object} +\usage{ +mkinresplot(object, obs_vars = names(object$mkinmod$map), xlim = c(0, + 1.1 * max(object$data$time)), xlab = "Time", ylab = "Residual", + maxabs = "auto", legend = TRUE, lpos = "topright", + col_obs = "auto", pch_obs = "auto", frame = TRUE, ...) +} +\arguments{ +\item{object}{A fit represented in an \code{\link{mkinfit}} object.} + +\item{obs_vars}{A character vector of names of the observed variables for +which residuals should be plotted. Defaults to all observed variables in +the model} + +\item{xlim}{plot range in x direction.} + +\item{xlab}{Label for the x axis. Defaults to "Time [days]".} + +\item{ylab}{Label for the y axis. Defaults to "Residual [\% of applied +radioactivity]".} + +\item{maxabs}{Maximum absolute value of the residuals. This is used for the +scaling of the y axis and defaults to "auto".} + +\item{legend}{Should a legend be plotted? Defaults to "TRUE".} + +\item{lpos}{Where should the legend be placed? Default is "topright". Will +be passed on to \code{\link{legend}}.} + +\item{col_obs}{Colors for the observed variables.} + +\item{pch_obs}{Symbols to be used for the observed variables.} + +\item{frame}{Should a frame be drawn around the plots?} + +\item{\dots}{further arguments passed to \code{\link{plot}}.} +} +\value{ +Nothing is returned by this function, as it is called for its side + effect, namely to produce a plot. +} +\description{ +This function plots the residuals for the specified subset of the observed +variables from an mkinfit object. A combined plot of the fitted model and +the residuals can be obtained using \code{\link{plot.mkinfit}} using the +argument \code{show_residuals = TRUE}. +} +\examples{ + +model <- mkinmod(parent = mkinsub("SFO", "m1"), m1 = mkinsub("SFO")) +fit <- mkinfit(model, FOCUS_2006_D, quiet = TRUE) +mkinresplot(fit, "m1") + +} +\seealso{ +\code{\link{mkinplot}}, for a way to plot the data and the fitted + lines of the mkinfit object. +} +\author{ +Johannes Ranke +} diff --git a/man/mkinsub.Rd b/man/mkinsub.Rd index 84e38e21..6522a37e 100644 --- a/man/mkinsub.Rd +++ b/man/mkinsub.Rd @@ -1,42 +1,35 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/mkinsub.R \name{mkinsub} \alias{mkinsub} -\title{ - Function to set up a kinetic submodel for one state variable -} -\description{ - This is a convenience function to set up the lists used as arguments for - \code{\link{mkinmod}}. -} +\title{Function to set up a kinetic submodel for one state variable} \usage{ mkinsub(submodel, to = NULL, sink = TRUE, full_name = NA) } \arguments{ - \item{submodel}{ - Character vector of length one to specify the submodel type. See - \code{\link{mkinmod}} for the list of allowed submodel names. - } - \item{to}{ - Vector of the names of the state variable to which a transformation - shall be included in the model. - } - \item{sink}{ - Should a pathway to sink be included in the model in addition to the - pathways to other state variables? - } - \item{full_name}{ - An optional name to be used e.g. for plotting fits performed with the model. - You can use non-ASCII characters here, but then your R code will not be - portable, \emph{i.e.} may produce unintended plot results on other - operating systems or system configurations. - } +\item{submodel}{Character vector of length one to specify the submodel type. +See \code{\link{mkinmod}} for the list of allowed submodel names.} + +\item{to}{Vector of the names of the state variable to which a +transformation shall be included in the model.} + +\item{sink}{Should a pathway to sink be included in the model in addition to +the pathways to other state variables?} + +\item{full_name}{An optional name to be used e.g. for plotting fits +performed with the model. You can use non-ASCII characters here, but then +your R code will not be portable, \emph{i.e.} may produce unintended plot +results on other operating systems or system configurations.} } \value{ - A list for use with \code{\link{mkinmod}}. +A list for use with \code{\link{mkinmod}}. } -\author{ - Johannes Ranke +\description{ +This is a convenience function to set up the lists used as arguments for +\code{\link{mkinmod}}. } \examples{ + # One parent compound, one metabolite, both single first order. SFO_SFO <- mkinmod( parent = list(type = "SFO", to = "m1"), @@ -51,5 +44,8 @@ SFO_SFO.2 <- mkinmod( SFO_SFO.2 <- mkinmod( parent = mkinsub("SFO", "m1", full_name = "Test compound"), m1 = mkinsub("SFO", full_name = "Metabolite M1")) -} +} +\author{ +Johannes Ranke +} diff --git a/man/mmkin.Rd b/man/mmkin.Rd index e871d78b..a763fcdf 100644 --- a/man/mmkin.Rd +++ b/man/mmkin.Rd @@ -1,51 +1,41 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/mmkin.R \name{mmkin} \alias{mmkin} -\title{ - Fit one or more kinetic models with one or more state variables to one or more datasets -} -\description{ - This function calls \code{\link{mkinfit}} on all combinations of models and datasets - specified in its first two arguments. -} +\title{Fit one or more kinetic models with one or more state variables to one or +more datasets} \usage{ -mmkin(models, datasets, - cores = round(detectCores()/2), cluster = NULL, ...) +mmkin(models = c("SFO", "FOMC", "DFOP"), datasets, + cores = round(detectCores()/2), cluster = NULL, ...) } \arguments{ - \item{models}{ - Either a character vector of shorthand names ("SFO", "FOMC", "DFOP", - "HS", "SFORB"), or an optionally named list of \code{\link{mkinmod}} - objects. - } - \item{datasets}{ - An optionally named list of datasets suitable as observed data for - \code{\link{mkinfit}}. - } - \item{cores}{ - The number of cores to be used for multicore processing. This is only - used when the \code{cluster} argument is \code{NULL}. On Windows machines, - cores > 1 is not supported, you need to use the \code{cluster} argument - to use multiple logical processors. - } - \item{cluster}{ - A cluster as returned by \code{\link{makeCluster}} to be used for parallel - execution. - } - \item{\dots}{ - Further arguments that will be passed to \code{\link{mkinfit}}. - } +\item{models}{Either a character vector of shorthand names like +\code{c("SFO", "FOMC", "DFOP", "HS", "SFORB")}, or an optionally named +list of \code{\link{mkinmod}} objects.} + +\item{datasets}{An optionally named list of datasets suitable as observed +data for \code{\link{mkinfit}}.} + +\item{cores}{The number of cores to be used for multicore processing. This +is only used when the \code{cluster} argument is \code{NULL}. On Windows +machines, cores > 1 is not supported, you need to use the \code{cluster} +argument to use multiple logical processors.} + +\item{cluster}{A cluster as returned by \code{\link{makeCluster}} to be used +for parallel execution.} + +\item{\dots}{Further arguments that will be passed to \code{\link{mkinfit}}.} } \value{ - A matrix of \code{\link{mkinfit}} objects that can be indexed using the model - and dataset names as row and column indices. -} -\seealso{ - \code{\link{[.mmkin}} for subsetting, \code{\link{plot.mmkin}} for plotting. +A matrix of \code{\link{mkinfit}} objects that can be indexed using + the model and dataset names as row and column indices. } -\author{ - Johannes Ranke +\description{ +This function calls \code{\link{mkinfit}} on all combinations of models and +datasets specified in its first two arguments. } \examples{ + \dontrun{ m_synth_SFO_lin <- mkinmod(parent = mkinsub("SFO", "M1"), M1 = mkinsub("SFO", "M2"), @@ -79,5 +69,13 @@ plot_sep(fits.0[[1, 1]]) # allow to plot the observed variables separately plot(fits.0[1, 1]) } + +} +\seealso{ +\code{\link{[.mmkin}} for subsetting, \code{\link{plot.mmkin}} for + plotting. +} +\author{ +Johannes Ranke } -\keyword{ optimize } +\keyword{optimize} diff --git a/man/nafta.Rd b/man/nafta.Rd index 6917d0e9..49c13afc 100644 --- a/man/nafta.Rd +++ b/man/nafta.Rd @@ -1,52 +1,65 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/nafta.R \name{nafta} \alias{nafta} -\title{ -Evaluate parent kinetics using the NAFTA guidance +\alias{print.nafta} +\title{Evaluate parent kinetics using the NAFTA guidance} +\source{ +NAFTA (2011) Guidance for evaluating and calculating degradation + kinetics in environmental media. NAFTA Technical Working Group on + Pesticides + \url{https://www.epa.gov/pesticide-science-and-assessing-pesticide-risks/guidance-evaluating-and-calculating-degradation} + accessed 2019-02-22 + + US EPA (2015) Standard Operating Procedure for Using the NAFTA Guidance to + Calculate Representative Half-life Values and Characterizing Pesticide + Degradation + \url{https://www.epa.gov/pesticide-science-and-assessing-pesticide-risks/standard-operating-procedure-using-nafta-guidance} } \usage{ -nafta(ds, title = NA, quiet = FALSE, \dots) -} -\description{ - The function fits the SFO, IORE and DFOP models using - \code{\link{mmkin}} and returns an object of class - \code{nafta} that has methods for printing and plotting. +nafta(ds, title = NA, quiet = FALSE, ...) + +\method{print}{nafta}(x, quiet = TRUE, digits = 3, ...) } \arguments{ - \item{ds}{ - A dataframe that must contain one variable called "time" with the time - values specified by the \code{time} argument, one column called "name" with - the grouping of the observed values, and finally one column of observed - values called "value". - } - \item{title}{ Optional title of the dataset } - \item{quiet}{ Should the evaluation text be shown? } - \item{\dots}{ - Further arguments passed to \code{\link{mmkin}}. - } +\item{ds}{A dataframe that must contain one variable called "time" with the +time values specified by the \code{time} argument, one column called +"name" with the grouping of the observed values, and finally one column of +observed values called "value".} + +\item{title}{Optional title of the dataset} + +\item{quiet}{Should the evaluation text be shown?} +\item{\dots}{Further arguments passed to \code{\link{mmkin}} (not for the +printing method).} + +\item{x}{An \code{\link{nafta}} object.} + +\item{digits}{Number of digits to be used for printing parameters and +dissipation times.} } \value{ - An list of class \code{nafta}. The list element named "mmkin" is the - \code{\link{mmkin}} object containing the fits of the three models. - The list element named "title" contains the title of the dataset used. - The list element "data" contains the dataset used in the fits. +An list of class \code{nafta}. The list element named "mmkin" is the + \code{\link{mmkin}} object containing the fits of the three models. The + list element named "title" contains the title of the dataset used. The + list element "data" contains the dataset used in the fits. } -\source{ - NAFTA (2011) Guidance for evaluating and calculating degradation kinetics - in environmental media. NAFTA Technical Working Group on Pesticides - \url{https://www.epa.gov/pesticide-science-and-assessing-pesticide-risks/guidance-evaluating-and-calculating-degradation} - accessed 2019-02-22 +\description{ +The function fits the SFO, IORE and DFOP models using \code{\link{mmkin}} +and returns an object of class \code{nafta} that has methods for printing +and plotting. - US EPA (2015) Standard Operating Procedure for Using the NAFTA Guidance to - Calculate Representative Half-life Values and Characterizing Pesticide - Degradation - \url{https://www.epa.gov/pesticide-science-and-assessing-pesticide-risks/standard-operating-procedure-using-nafta-guidance} +Print nafta objects. The results for the three models are printed in the +order of increasing model complexity, i.e. SFO, then IORE, and finally DFOP. } \examples{ + nafta_evaluation <- nafta(NAFTA_SOP_Appendix_D, cores = 1) print(nafta_evaluation) plot(nafta_evaluation) + } \author{ - Johannes Ranke +Johannes Ranke } diff --git a/man/plot.mkinfit.Rd b/man/plot.mkinfit.Rd index fac5663a..3834eaf5 100644 --- a/man/plot.mkinfit.Rd +++ b/man/plot.mkinfit.Rd @@ -1,130 +1,110 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/plot.mkinfit.R \name{plot.mkinfit} \alias{plot.mkinfit} \alias{plot_sep} \alias{plot_res} \alias{plot_err} -\title{ - Plot the observed data and the fitted model of an mkinfit object -} -\description{ - Solves the differential equations with the optimised and fixed parameters - from a previous successful call to \code{\link{mkinfit}} and plots - the observed data together with the solution of the fitted model. - - If the current plot device is a \code{\link[tikzDevice]{tikz}} device, - then latex is being used for the formatting of the chi2 error level, - if \code{show_errmin = TRUE}. -} +\title{Plot the observed data and the fitted model of an mkinfit object} \usage{ -\method{plot}{mkinfit}(x, fit = x, - obs_vars = names(fit$mkinmod$map), - xlab = "Time", ylab = "Observed", - xlim = range(fit$data$time), - ylim = "default", - col_obs = 1:length(obs_vars), pch_obs = col_obs, - lty_obs = rep(1, length(obs_vars)), - add = FALSE, legend = !add, - show_residuals = FALSE, - show_errplot = FALSE, - maxabs = "auto", - sep_obs = FALSE, rel.height.middle = 0.9, - row_layout = FALSE, - lpos = "topright", inset = c(0.05, 0.05), - show_errmin = FALSE, errmin_digits = 3, frame = TRUE, \dots) -plot_sep(fit, show_errmin = TRUE, \dots) -plot_res(fit, sep_obs = FALSE, show_errmin = sep_obs, \dots) -plot_err(fit, sep_obs = FALSE, show_errmin = sep_obs, \dots) +\method{plot}{mkinfit}(x, fit = x, obs_vars = names(fit$mkinmod$map), + xlab = "Time", ylab = "Observed", xlim = range(fit$data$time), + ylim = "default", col_obs = 1:length(obs_vars), pch_obs = col_obs, + lty_obs = rep(1, length(obs_vars)), add = FALSE, legend = !add, + show_residuals = FALSE, show_errplot = FALSE, maxabs = "auto", + sep_obs = FALSE, rel.height.middle = 0.9, row_layout = FALSE, + lpos = "topright", inset = c(0.05, 0.05), show_errmin = FALSE, + errmin_digits = 3, frame = TRUE, ...) + +plot_sep(fit, show_errmin = TRUE, ...) + +plot_res(fit, sep_obs = FALSE, show_errmin = sep_obs, ...) + +plot_err(fit, sep_obs = FALSE, show_errmin = sep_obs, ...) } \arguments{ - \item{x}{ - Alias for fit introduced for compatibility with the generic S3 method. - } - \item{fit}{ - An object of class \code{\link{mkinfit}}. - } - \item{obs_vars}{ - A character vector of names of the observed variables for which the - data and the model should be plotted. Defauls to all observed variables - in the model. - } - \item{xlab}{ - Label for the x axis. - } - \item{ylab}{ - Label for the y axis. - } - \item{xlim}{ - Plot range in x direction. - } - \item{ylim}{ - Plot range in y direction. - } - \item{col_obs}{ - Colors used for plotting the observed data and the corresponding model prediction lines. - } - \item{pch_obs}{ - Symbols to be used for plotting the data. - } - \item{lty_obs}{ - Line types to be used for the model predictions. - } - \item{add}{ - Should the plot be added to an existing plot? - } - \item{legend}{ - Should a legend be added to the plot? - } - \item{show_residuals}{ - Should residuals be shown? If only one plot of the fits is shown, the - residual plot is in the lower third of the plot. Otherwise, i.e. if - "sep_obs" is given, the residual plots will be located to the right of - the plots of the fitted curves. - } - \item{show_errplot}{ - Should squared residuals and the error model be shown? If only one plot of - the fits is shown, this plot is in the lower third of the plot. - Otherwise, i.e. if "sep_obs" is given, the residual plots will be located - to the right of the plots of the fitted curves. - } - \item{maxabs}{ - Maximum absolute value of the residuals. This is used for the scaling of - the y axis and defaults to "auto". - } - \item{sep_obs}{ - Should the observed variables be shown in separate subplots? If yes, residual plots - requested by "show_residuals" will be shown next to, not below the plot of the fits. - } - \item{rel.height.middle}{ - The relative height of the middle plot, if more than two rows of plots are shown. - } - \item{row_layout}{ - Should we use a row layout where the residual plot or the error model plot is shown - to the right? - } - \item{lpos}{ - Position(s) of the legend(s). Passed to \code{\link{legend}} as the first argument. - If not length one, this should be of the same length as the obs_var argument. - } - \item{inset}{ - Passed to \code{\link{legend}} if applicable. - } - \item{show_errmin}{ - Should the FOCUS chi2 error value be shown in the upper margin of the plot? - } - \item{errmin_digits}{ - The number of significant digits for rounding the FOCUS chi2 error percentage. - } - \item{frame}{ - Should a frame be drawn around the plots? - } - \item{\dots}{ - Further arguments passed to \code{\link{plot}}. - } +\item{x}{Alias for fit introduced for compatibility with the generic S3 +method.} + +\item{fit}{An object of class \code{\link{mkinfit}}.} + +\item{obs_vars}{A character vector of names of the observed variables for +which the data and the model should be plotted. Defauls to all observed +variables in the model.} + +\item{xlab}{Label for the x axis.} + +\item{ylab}{Label for the y axis.} + +\item{xlim}{Plot range in x direction.} + +\item{ylim}{Plot range in y direction.} + +\item{col_obs}{Colors used for plotting the observed data and the +corresponding model prediction lines.} + +\item{pch_obs}{Symbols to be used for plotting the data.} + +\item{lty_obs}{Line types to be used for the model predictions.} + +\item{add}{Should the plot be added to an existing plot?} + +\item{legend}{Should a legend be added to the plot?} + +\item{show_residuals}{Should residuals be shown? If only one plot of the +fits is shown, the residual plot is in the lower third of the plot. +Otherwise, i.e. if "sep_obs" is given, the residual plots will be located +to the right of the plots of the fitted curves.} + +\item{show_errplot}{Should squared residuals and the error model be shown? +If only one plot of the fits is shown, this plot is in the lower third of +the plot. Otherwise, i.e. if "sep_obs" is given, the residual plots will +be located to the right of the plots of the fitted curves.} + +\item{maxabs}{Maximum absolute value of the residuals. This is used for the +scaling of the y axis and defaults to "auto".} + +\item{sep_obs}{Should the observed variables be shown in separate subplots? +If yes, residual plots requested by "show_residuals" will be shown next +to, not below the plot of the fits.} + +\item{rel.height.middle}{The relative height of the middle plot, if more +than two rows of plots are shown.} + +\item{row_layout}{Should we use a row layout where the residual plot or the +error model plot is shown to the right?} + +\item{lpos}{Position(s) of the legend(s). Passed to \code{\link{legend}} as +the first argument. If not length one, this should be of the same length +as the obs_var argument.} + +\item{inset}{Passed to \code{\link{legend}} if applicable.} + +\item{show_errmin}{Should the FOCUS chi2 error value be shown in the upper +margin of the plot?} + +\item{errmin_digits}{The number of significant digits for rounding the FOCUS +chi2 error percentage.} + +\item{frame}{Should a frame be drawn around the plots?} + +\item{\dots}{Further arguments passed to \code{\link{plot}}.} } \value{ - The function is called for its side effect. +The function is called for its side effect. +} +\description{ +Solves the differential equations with the optimised and fixed parameters +from a previous successful call to \code{\link{mkinfit}} and plots the +observed data together with the solution of the fitted model. +} +\details{ +If the current plot device is a \code{\link[tikzDevice]{tikz}} device, then +latex is being used for the formatting of the chi2 error level, if +\code{show_errmin = TRUE}. } \examples{ + # One parent compound, one metabolite, both single first order, path from # parent to sink included \dontrun{ @@ -146,7 +126,8 @@ plot_sep(fit, lpos = c("topright", "bottomright")) plot(fit, sep_obs = TRUE, show_errplot = TRUE, lpos = c("topright", "bottomright"), show_errmin = TRUE) } + } \author{ - Johannes Ranke +Johannes Ranke } diff --git a/man/plot.mmkin.Rd b/man/plot.mmkin.Rd index 90b92d27..333998da 100644 --- a/man/plot.mmkin.Rd +++ b/man/plot.mmkin.Rd @@ -1,62 +1,58 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/plot.mmkin.R \name{plot.mmkin} \alias{plot.mmkin} -\title{ - Plot model fits (observed and fitted) and the residuals for a row or column of an mmkin object -} -\description{ - When x is a row selected from an mmkin object (\code{\link{[.mmkin}}), the same model - fitted for at least one dataset is shown. When it is a column, the fit of at least one model - to the same dataset is shown. - - If the current plot device is a \code{\link[tikzDevice]{tikz}} device, - then latex is being used for the formatting of the chi2 error level. -} +\title{Plot model fits (observed and fitted) and the residuals for a row or column +of an mmkin object} \usage{ \method{plot}{mmkin}(x, main = "auto", legends = 1, - resplot = c("time", "errmod"), show_errmin = TRUE, errmin_var = "All data", - errmin_digits = 3, cex = 0.7, rel.height.middle = 0.9, ...) + resplot = c("time", "errmod"), show_errmin = TRUE, + errmin_var = "All data", errmin_digits = 3, cex = 0.7, + rel.height.middle = 0.9, ...) } \arguments{ - \item{x}{ - An object of class \code{\link{mmkin}}, with either one row or one column. -} - \item{main}{ - The main title placed on the outer margin of the plot. -} - \item{legends}{ - An index for the fits for which legends should be shown. -} - \item{resplot}{ - Should the residuals plotted against time, using \code{\link{mkinresplot}}, - or as squared residuals against predicted values, with the error model, - using \code{\link{mkinerrplot}}. -} - \item{show_errmin}{ - Should the chi2 error level be shown on top of the plots to the left? - } - \item{errmin_var}{ - The variable for which the FOCUS chi2 error value should be shown. -} - \item{errmin_digits}{ - The number of significant digits for rounding the FOCUS chi2 error percentage. -} - \item{cex}{ - Passed to the plot functions and \code{\link{mtext}}. -} - \item{rel.height.middle}{ - The relative height of the middle plot, if more than two rows of plots are shown. -} - \item{\dots}{ - Further arguments passed to \code{\link{plot.mkinfit}} and \code{\link{mkinresplot}}. -} +\item{x}{An object of class \code{\link{mmkin}}, with either one row or one +column.} + +\item{main}{The main title placed on the outer margin of the plot.} + +\item{legends}{An index for the fits for which legends should be shown.} + +\item{resplot}{Should the residuals plotted against time, using +\code{\link{mkinresplot}}, or as squared residuals against predicted +values, with the error model, using \code{\link{mkinerrplot}}.} + +\item{show_errmin}{Should the chi2 error level be shown on top of the plots +to the left?} + +\item{errmin_var}{The variable for which the FOCUS chi2 error value should +be shown.} + +\item{errmin_digits}{The number of significant digits for rounding the FOCUS +chi2 error percentage.} + +\item{cex}{Passed to the plot functions and \code{\link{mtext}}.} + +\item{rel.height.middle}{The relative height of the middle plot, if more +than two rows of plots are shown.} + +\item{\dots}{Further arguments passed to \code{\link{plot.mkinfit}} and +\code{\link{mkinresplot}}.} } \value{ - The function is called for its side effect. +The function is called for its side effect. } -\author{ - Johannes Ranke +\description{ +When x is a row selected from an mmkin object (\code{\link{[.mmkin}}), the +same model fitted for at least one dataset is shown. When it is a column, +the fit of at least one model to the same dataset is shown. +} +\details{ +If the current plot device is a \code{\link[tikzDevice]{tikz}} device, then +latex is being used for the formatting of the chi2 error level. } \examples{ + \dontrun{ # Only use one core not to offend CRAN checks fits <- mmkin(c("FOMC", "HS"), @@ -73,4 +69,8 @@ # Show the error models plot(fits["FOMC", ], resplot = "errmod") } + +} +\author{ +Johannes Ranke } diff --git a/man/plot.nafta.Rd b/man/plot.nafta.Rd index 62bbcddf..e7a57de3 100644 --- a/man/plot.nafta.Rd +++ b/man/plot.nafta.Rd @@ -1,33 +1,30 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/nafta.R \name{plot.nafta} \alias{plot.nafta} -\title{ - Plot the results of the three models used in the NAFTA scheme. The plots - are ordered with increasing complexity of the model in this function - (SFO, then IORE, then DFOP). -} -\description{ - Calls \code{\link{plot.mmkin}}. -} +\title{Plot the results of the three models used in the NAFTA scheme.} \usage{ -\method{plot}{nafta}(x, legend = FALSE, main = "auto", \dots) +\method{plot}{nafta}(x, legend = FALSE, main = "auto", ...) } \arguments{ - \item{x}{ - An object of class \code{\link{nafta}}. - } - \item{legend}{ - Should a legend be added? - } - \item{main}{ - Possibility to override the main title of the plot. - } - \item{\dots}{ - Further arguments passed to \code{\link{plot.mmkin}}. - } +\item{x}{An object of class \code{\link{nafta}}.} + +\item{legend}{Should a legend be added?} + +\item{main}{Possibility to override the main title of the plot.} + +\item{\dots}{Further arguments passed to \code{\link{plot.mmkin}}.} } \value{ - The function is called for its side effect. +The function is called for its side effect. +} +\description{ +The plots are ordered with increasing complexity of the model in this +function (SFO, then IORE, then DFOP). +} +\details{ +Calls \code{\link{plot.mmkin}}. } \author{ - Johannes Ranke +Johannes Ranke } diff --git a/man/print.mkinds.Rd b/man/print.mkinds.Rd index e7acf30d..54dc5a12 100644 --- a/man/print.mkinds.Rd +++ b/man/print.mkinds.Rd @@ -1,19 +1,16 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/mkinds.R \name{print.mkinds} \alias{print.mkinds} -\title{ - Print mkinds objects -} -\description{ - Print mkinds objects. -} +\title{Print mkinds objects} \usage{ \method{print}{mkinds}(x, ...) } \arguments{ - \item{x}{ - An \code{\link{mkinds}} object. - } - \item{\dots}{ - Not used. - } +\item{x}{An \code{\link{mkinds}} object.} + +\item{\dots}{Not used.} +} +\description{ +Print mkinds objects. } diff --git a/man/print.mkinmod.Rd b/man/print.mkinmod.Rd index 24555def..4e44cde6 100644 --- a/man/print.mkinmod.Rd +++ b/man/print.mkinmod.Rd @@ -1,26 +1,26 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/mkinmod.R \name{print.mkinmod} \alias{print.mkinmod} -\title{ - Print mkinmod objects -} -\description{ - Print mkinmod objects in a way that the user finds his way to get to its components. -} +\title{Print mkinmod objects} \usage{ - \method{print}{mkinmod}(x, ...) +\method{print}{mkinmod}(x, ...) } \arguments{ - \item{x}{ - An \code{\link{mkinmod}} object. - } - \item{\dots}{ - Not used. - } +\item{x}{An \code{\link{mkinmod}} object.} + +\item{\dots}{Not used.} +} +\description{ +Print mkinmod objects in a way that the user finds his way to get to its +components. } \examples{ + m_synth_SFO_lin <- mkinmod(parent = list(type = "SFO", to = "M1"), M1 = list(type = "SFO", to = "M2"), M2 = list(type = "SFO"), use_of_ff = "max") - + print(m_synth_SFO_lin) + } diff --git a/man/print.nafta.Rd b/man/print.nafta.Rd deleted file mode 100644 index e42a619d..00000000 --- a/man/print.nafta.Rd +++ /dev/null @@ -1,27 +0,0 @@ -\name{print.nafta} -\alias{print.nafta} -\title{ - Print nafta objects -} -\description{ - Print nafta objects. The results for the three models - are printed in the order of increasing model complexity, - i.e. SFO, then IORE, and finally DFOP. -} -\usage{ - \method{print}{nafta}(x, quiet = TRUE, digits = 3, ...) -} -\arguments{ - \item{x}{ - An \code{\link{nafta}} object. - } - \item{quiet}{ - Should the evaluation text be shown? - } - \item{digits}{ - Number of digits to be used for printing parameters and dissipation times. - } - \item{\dots}{ - Not used. - } -} diff --git a/man/sigma_twocomp.Rd b/man/sigma_twocomp.Rd index 9e91fe78..3e7854f1 100644 --- a/man/sigma_twocomp.Rd +++ b/man/sigma_twocomp.Rd @@ -1,31 +1,38 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/sigma_twocomp.R \name{sigma_twocomp} \alias{sigma_twocomp} \title{Two component error model} -\description{ - Function describing the standard deviation of the measurement error - in dependence of the measured value \eqn{y}: - - \deqn{\sigma = \sqrt{ \sigma_{low}^2 + y^2 * {rsd}_{high}^2}} - {sigma = sqrt(sigma_low^2 + y^2 * rsd_high^2)} - - This is the error model used for example by Werner et al. (1978). The model - proposed by Rocke and Lorenzato (1995) can be written in this form as well, - but assumes approximate lognormal distribution of errors for high values of y. -} \usage{ sigma_twocomp(y, sigma_low, rsd_high) } \arguments{ - \item{y}{ The magnitude of the observed value } - \item{sigma_low}{ The asymptotic minimum of the standard deviation for low observed values } - \item{rsd_high}{ The coefficient describing the increase of the standard deviation with - the magnitude of the observed value } +\item{y}{The magnitude of the observed value} + +\item{sigma_low}{The asymptotic minimum of the standard deviation for low +observed values} + +\item{rsd_high}{The coefficient describing the increase of the standard +deviation with the magnitude of the observed value} } \value{ - The standard deviation of the response variable. +The standard deviation of the response variable. +} +\description{ +Function describing the standard deviation of the measurement error in +dependence of the measured value \eqn{y}: +} +\details{ +\deqn{\sigma = \sqrt{ \sigma_{low}^2 + y^2 * {rsd}_{high}^2}} sigma = +sqrt(sigma_low^2 + y^2 * rsd_high^2) + +This is the error model used for example by Werner et al. (1978). The model +proposed by Rocke and Lorenzato (1995) can be written in this form as well, +but assumes approximate lognormal distribution of errors for high values of +y. } \references{ - Werner, Mario, Brooks, Samuel H., and Knott, Lancaster B. (1978) +Werner, Mario, Brooks, Samuel H., and Knott, Lancaster B. (1978) Additive, Multiplicative, and Mixed Analytical Errors. Clinical Chemistry 24(11), 1895-1898. diff --git a/man/summary.mkinfit.Rd b/man/summary.mkinfit.Rd index cbc9098c..fcc1295f 100644 --- a/man/summary.mkinfit.Rd +++ b/man/summary.mkinfit.Rd @@ -1,75 +1,77 @@ -\name{summary.mkinfit} -\alias{summary.mkinfit} -\alias{print.summary.mkinfit} -\title{ - Summary method for class "mkinfit" -} -\description{ - Lists model equations, initial parameter values, optimised parameters with some - uncertainty statistics, the chi2 error levels calculated according to FOCUS - guidance (2006) as defined therein, formation fractions, DT50 values and - optionally the data, consisting of observed, predicted and residual values. -} -\usage{ -\method{summary}{mkinfit}(object, data = TRUE, distimes = TRUE, alpha = 0.05, ...) -\method{print}{summary.mkinfit}(x, digits = max(3, getOption("digits") - 3), ...) -} - -\arguments{ - \item{object}{ - an object of class \code{\link{mkinfit}}. -} - \item{x}{ - an object of class \code{summary.mkinfit}. -} - \item{data}{ - logical, indicating whether the data should be included in the summary. -} - \item{distimes}{ - logical, indicating whether DT50 and DT90 values should be included. -} - \item{alpha}{ - error level for confidence interval estimation from t distribution -} - \item{digits}{ - Number of digits to use for printing -} - \item{\dots}{ - optional arguments passed to methods like \code{print}. -} -} -\value{ - The summary function returns a list with components, among others - \item{version, Rversion}{The mkin and R versions used} - \item{date.fit, date.summary}{The dates where the fit and the summary were produced} - \item{use_of_ff}{Was maximum or minimum use made of formation fractions} - \item{residuals, residualVariance, sigma, modVariance, df}{As in summary.modFit} - \item{cov.unscaled, cov.scaled, info, niter, stopmess, par}{As in summary.modFit} - \item{bpar}{Optimised and backtransformed parameters} - \item{diffs }{The differential equations used in the model} - \item{data }{The data (see Description above).} - \item{start }{The starting values and bounds, if applicable, for optimised parameters.} - \item{fixed }{The values of fixed parameters.} - \item{errmin }{The chi2 error levels for each observed variable.} - \item{bparms.ode }{All backtransformed ODE parameters, for use as starting parameters for - related models.} - \item{errparms }{Error model parameters. } - \item{ff }{The estimated formation fractions derived from the fitted model.} - \item{distimes }{The DT50 and DT90 values for each observed variable.} - \item{SFORB}{If applicable, eigenvalues of SFORB components of the model.} - The print method is called for its side effect, i.e. printing the summary. -} -\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} -} -\author{ - Johannes Ranke -} -\examples{ - summary(mkinfit(mkinmod(parent = mkinsub("SFO")), FOCUS_2006_A, quiet = TRUE)) -} -\keyword{ utilities } +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/summary.mkinfit.R +\name{summary.mkinfit} +\alias{summary.mkinfit} +\alias{print.summary.mkinfit} +\title{Summary method for class "mkinfit"} +\usage{ +\method{summary}{mkinfit}(object, data = TRUE, distimes = TRUE, + alpha = 0.05, ...) + +\method{print}{summary.mkinfit}(x, digits = max(3, getOption("digits") - + 3), ...) +} +\arguments{ +\item{object}{an object of class \code{\link{mkinfit}}.} + +\item{data}{logical, indicating whether the data should be included in the +summary.} + +\item{distimes}{logical, indicating whether DT50 and DT90 values should be +included.} + +\item{alpha}{error level for confidence interval estimation from t +distribution} + +\item{\dots}{optional arguments passed to methods like \code{print}.} + +\item{x}{an object of class \code{summary.mkinfit}.} + +\item{digits}{Number of digits to use for printing} +} +\value{ +The summary function returns a list with components, among others + \item{version, Rversion}{The mkin and R versions used} + \item{date.fit, date.summary}{The dates where the fit and the summary were + produced} + \item{diffs}{The differential equations used in the model} + \item{use_of_ff}{Was maximum or minimum use made of formation fractions} + \item{bpar}{Optimised and backtransformed + parameters} + \item{data}{The data (see Description above).} + \item{start}{The starting values and bounds, if applicable, for optimised + parameters.} + \item{fixed}{The values of fixed parameters.} + \item{errmin }{The chi2 error levels for + each observed variable.} + \item{bparms.ode}{All backtransformed ODE + parameters, for use as starting parameters for related models.} + \item{errparms}{Error model parameters.} + \item{ff}{The estimated formation fractions derived from the fitted + model.} + \item{distimes}{The DT50 and DT90 values for each observed variable.} + \item{SFORB}{If applicable, eigenvalues of SFORB components of the model.} + The print method is called for its side effect, i.e. printing the summary. +} +\description{ +Lists model equations, initial parameter values, optimised parameters with +some uncertainty statistics, the chi2 error levels calculated according to +FOCUS guidance (2006) as defined therein, formation fractions, DT50 values +and optionally the data, consisting of observed, predicted and residual +values. +} +\examples{ + + summary(mkinfit(mkinmod(parent = mkinsub("SFO")), FOCUS_2006_A, quiet = TRUE)) + +} +\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} +} +\author{ +Johannes Ranke +} diff --git a/man/transform_odeparms.Rd b/man/transform_odeparms.Rd index 006897d6..5c8c90ba 100644 --- a/man/transform_odeparms.Rd +++ b/man/transform_odeparms.Rd @@ -1,66 +1,67 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/transform_odeparms.R \name{transform_odeparms} \alias{transform_odeparms} \alias{backtransform_odeparms} -\title{ - Functions to transform and backtransform kinetic parameters for fitting -} -\description{ - The transformations are intended to map parameters that should only take - on restricted values to the full scale of real numbers. For kinetic rate - constants and other paramters that can only take on positive values, a - simple log transformation is used. For compositional parameters, such as - the formations fractions that should always sum up to 1 and can not be - negative, the \code{\link{ilr}} transformation is used. - - The transformation of sets of formation fractions is fragile, as it supposes - the same ordering of the components in forward and backward transformation. - This is no problem for the internal use in \code{\link{mkinfit}}. -} +\title{Functions to transform and backtransform kinetic parameters for fitting} \usage{ -transform_odeparms(parms, mkinmod, - transform_rates = TRUE, transform_fractions = TRUE) -backtransform_odeparms(transparms, mkinmod, - transform_rates = TRUE, transform_fractions = TRUE) +transform_odeparms(parms, mkinmod, transform_rates = TRUE, + transform_fractions = TRUE) + +backtransform_odeparms(transparms, mkinmod, transform_rates = TRUE, + transform_fractions = TRUE) } \arguments{ - \item{parms}{ - Parameters of kinetic models as used in the differential equations. - } - \item{transparms}{ - Transformed parameters of kinetic models as used in the fitting procedure. - } - \item{mkinmod}{ - The kinetic model of class \code{\link{mkinmod}}, containing the names of - the model variables that are needed for grouping the formation fractions - before \code{\link{ilr}} transformation, the parameter names and - the information if the pathway to sink is included in the model. - } - \item{transform_rates}{ - Boolean specifying if kinetic rate constants should be transformed in the - model specification used in the fitting for better compliance with the - assumption of normal distribution of the estimator. If TRUE, also - alpha and beta parameters of the FOMC model are log-transformed, as well - as k1 and k2 rate constants for the DFOP and HS models and the break point tb - of the HS model. - } - \item{transform_fractions}{ - Boolean specifying if formation fractions constants should be transformed in the - model specification used in the fitting for better compliance with the - assumption of normal distribution of the estimator. The default (TRUE) is - to do transformations. The g parameter of the DFOP and HS models are also - transformed, as they can also be seen as compositional data. The - transformation used for these transformations is the \code{\link{ilr}} - transformation. - } +\item{parms}{Parameters of kinetic models as used in the differential +equations.} + +\item{mkinmod}{The kinetic model of class \code{\link{mkinmod}}, containing +the names of the model variables that are needed for grouping the +formation fractions before \code{\link{ilr}} transformation, the parameter +names and the information if the pathway to sink is included in the model.} + +\item{transform_rates}{Boolean specifying if kinetic rate constants should +be transformed in the model specification used in the fitting for better +compliance with the assumption of normal distribution of the estimator. If +TRUE, also alpha and beta parameters of the FOMC model are +log-transformed, as well as k1 and k2 rate constants for the DFOP and HS +models and the break point tb of the HS model.} + +\item{transform_fractions}{Boolean specifying if formation fractions +constants should be transformed in the model specification used in the +fitting for better compliance with the assumption of normal distribution +of the estimator. The default (TRUE) is to do transformations. The g +parameter of the DFOP and HS models are also transformed, as they can also +be seen as compositional data. The transformation used for these +transformations is the \code{\link{ilr}} transformation.} + +\item{transparms}{Transformed parameters of kinetic models as used in the +fitting procedure.} } \value{ - A vector of transformed or backtransformed parameters with the same names - as the original parameters. +A vector of transformed or backtransformed parameters with the same + names as the original parameters. } -\author{ - Johannes Ranke +\description{ +The transformations are intended to map parameters that should only take on +restricted values to the full scale of real numbers. For kinetic rate +constants and other paramters that can only take on positive values, a +simple log transformation is used. For compositional parameters, such as the +formations fractions that should always sum up to 1 and can not be negative, +the \code{\link{ilr}} transformation is used. } +\details{ +The transformation of sets of formation fractions is fragile, as it supposes +the same ordering of the components in forward and backward transformation. +This is no problem for the internal use in \code{\link{mkinfit}}. +} +\section{Functions}{ +\itemize{ +\item \code{backtransform_odeparms}: Backtransform the set of transformed parameters +}} + \examples{ + SFO_SFO <- mkinmod( parent = list(type = "SFO", to = "m1", sink = TRUE), m1 = list(type = "SFO")) @@ -113,5 +114,8 @@ fit.ff.2.s <- summary(fit.ff.2) print(fit.ff.2.s$par, 3) print(fit.ff.2.s$bpar, 3) } + +} +\author{ +Johannes Ranke } -\keyword{ manip } -- cgit v1.2.1