diff options
author | Johannes Ranke <jranke@uni-bremen.de> | 2017-01-19 11:41:19 +0100 |
---|---|---|
committer | Johannes Ranke <jranke@uni-bremen.de> | 2017-01-19 11:41:19 +0100 |
commit | 2ab822d51c4c7e29d62076336d7a3f02a46e41a5 (patch) | |
tree | b9836a7318d92bc73e96dfd8a943986fa3f3cee7 | |
parent | 46883a0c3a3c00127a563a7befa0af440573baaa (diff) |
Corrections in the documentation
-rw-r--r-- | ChangeLog | 12 | ||||
-rw-r--r-- | R/twa.R | 26 | ||||
-rw-r--r-- | docs/reference/one_box.html | 25 | ||||
-rw-r--r-- | man/one_box.Rd | 20 |
4 files changed, 60 insertions, 23 deletions
@@ -1,3 +1,15 @@ +commit 46883a0c3a3c00127a563a7befa0af440573baaa +Author: Johannes Ranke <jranke@uni-bremen.de> +Date: 2017-01-19 11:22:08 +0100 + + Correct default y axis label for plot.one_box + +commit 3947731a5a8c3598271b26f5201dea4bcb13ef6d +Author: Johannes Ranke <jranke@uni-bremen.de> +Date: 2017-01-19 10:47:09 +0100 + + Fix one_box for ini = 1, use in sawtooth examples + commit dd30f0d0ff1d8d0cc46aaef6e0917c51fe798f52 Author: Johannes Ranke <jranke@uni-bremen.de> Date: 2017-01-19 10:36:19 +0100 @@ -18,15 +18,20 @@ #' Create a time series of decline data #' -#' The time series starts with the amount specified for the first application. -#' This does not create objects of type \code{\link{ts}}. -#' #' @param x When numeric, this is the half-life to be used for an exponential -#' decline. If x is an mkinfit object, the decline is calculated from this object -#' @param ini The initial amount for each compound +#' decline. When a character string specifying a parent decline model is given +#' e.g. \code{FOMC}, \code{parms} must contain the corresponding paramters. +#' If x is an \code{\link{mkinfit}} object, the decline is calculated from this +#' object. +#' @param ini The initial amount for the parent compound. If x is an +#' \code{\link{mkinfit}} object, and ini is 'model', the fitted initial +#' concentrations are used. Otherwise, ini must be numeric. If it has +#' length one, it is used for the parent and initial values of metabolites +#' are zero, otherwise, it must give values for all observed variables. #' @param t_end End of the time series #' @param res Resolution of the time series #' @param ... Further arguments passed to methods +#' @return An object of class \code{one_box}, inheriting from \code{\link{ts}}. #' @importFrom stats filter frequency time ts #' @export #' @examples @@ -59,7 +64,7 @@ one_box.numeric <- function(x, ini = 1, ..., half_life = x k = log(2)/half_life t_out <- seq(0, t_end, by = res) - raw <- matrix(exp( - k * t_out), ncol = 1) + raw <- matrix(ini * exp( - k * t_out), ncol = 1) dimnames(raw) <- list(NULL, "parent") result <- ts(raw, 0, t_end, frequency = 1/res) class(result) <- c("one_box", "ts") @@ -87,7 +92,7 @@ one_box.character <- function(x, ini = 1, parms, ..., } t_out <- seq(0, t_end, by = res) - pred <- mkinpredict(m, odeparms = parms, odeini = c(parent = 1), + pred <- mkinpredict(m, odeparms = parms, odeini = c(parent = ini), outtimes = t_out, solution_type = "analytical")[-1] result <- ts(pred, 0, t_end, frequency = 1/res) class(result) <- c("one_box", "ts") @@ -97,13 +102,14 @@ one_box.character <- function(x, ini = 1, parms, ..., #' @rdname one_box #' @importFrom mkin mkinpredict #' @export -one_box.mkinfit <- function(x, ini = c("model", 1), ..., t_end = 100, res = 0.01) { +one_box.mkinfit <- function(x, ini = "model", ..., t_end = 100, res = 0.01) { fit <- x if (ini[1] == "model") { odeini = x$bparms.state } else { - if (ini[1] != 1) stop ("Argument ini can only be 'model' or 1") - odeini <- c(1, rep(0, length(fit$mkinmod$spec) - 1)) + if (!is.numeric(ini[1])) stop ("Argument ini can only be 'model' or numeric") + if (length(ini) == 1) odeini <- c(ini[1], rep(0, length(fit$mkinmod$spec) - 1)) + else odeini = ini names(odeini) <- names(fit$mkinmod$spec) } diff --git a/docs/reference/one_box.html b/docs/reference/one_box.html index 853f892..4e60143 100644 --- a/docs/reference/one_box.html +++ b/docs/reference/one_box.html @@ -70,8 +70,7 @@ </div> - <p>The time series starts with the amount specified for the first application. -This does not create objects of type <code>ts</code>.</p> + <p>Create a time series of decline data</p> <pre><span class='fu'>one_box</span>(<span class='no'>x</span>, <span class='no'>ini</span>, <span class='no'>...</span>, <span class='kw'>t_end</span> <span class='kw'>=</span> <span class='fl'>100</span>, <span class='kw'>res</span> <span class='kw'>=</span> <span class='fl'>0.01</span>) @@ -84,16 +83,22 @@ This does not create objects of type <code>ts</code>.</p> <span class='kw'>res</span> <span class='kw'>=</span> <span class='fl'>0.01</span>) <span class='co'># S3 method for mkinfit</span> -<span class='fu'>one_box</span>(<span class='no'>x</span>, <span class='kw'>ini</span> <span class='kw'>=</span> <span class='fu'>c</span>(<span class='st'>"model"</span>, <span class='fl'>1</span>), <span class='no'>...</span>, <span class='kw'>t_end</span> <span class='kw'>=</span> <span class='fl'>100</span>, - <span class='kw'>res</span> <span class='kw'>=</span> <span class='fl'>0.01</span>)</pre> +<span class='fu'>one_box</span>(<span class='no'>x</span>, <span class='kw'>ini</span> <span class='kw'>=</span> <span class='st'>"model"</span>, <span class='no'>...</span>, <span class='kw'>t_end</span> <span class='kw'>=</span> <span class='fl'>100</span>, <span class='kw'>res</span> <span class='kw'>=</span> <span class='fl'>0.01</span>)</pre> <h2 class="hasAnchor" id="arguments"><a class="anchor" href="#arguments"></a> Arguments</h2> <dl class="dl-horizontal"> <dt>x</dt> <dd>When numeric, this is the half-life to be used for an exponential -decline. If x is an mkinfit object, the decline is calculated from this object</dd> +decline. When a character string specifying a parent decline model is given +e.g. <code>FOMC</code>, <code>parms</code> must contain the corresponding paramters. +If x is an <code>mkinfit</code> object, the decline is calculated from this +object.</dd> <dt>ini</dt> - <dd>The initial amount for each compound</dd> + <dd>The initial amount for the parent compound. If x is an +<code>mkinfit</code> object, and ini is 'model', the fitted initial +concentrations are used. Otherwise, ini must be numeric. If it has +length one, it is used for the parent and initial values of metabolites +are zero, otherwise, it must give values for all observed variables.</dd> <dt>...</dt> <dd>Further arguments passed to methods</dd> <dt>t_end</dt> @@ -104,6 +109,10 @@ decline. If x is an mkinfit object, the decline is calculated from this object</ <dd>A named numeric vector containing the model parameters</dd> </dl> + <h2 class="hasAnchor" id="value"><a class="anchor" href="#value"></a>Value</h2> + + <p>An object of class <code>one_box</code>, inheriting from <code>ts</code>.</p> + <h2 class="hasAnchor" id="examples"><a class="anchor" href="#examples"></a>Examples</h2> <pre class="examples"><div class='input'><span class='co'># Only use a half-life</span> @@ -123,7 +132,9 @@ decline. If x is an mkinfit object, the decline is calculated from this object</ <h2>Contents</h2> <ul class="nav nav-pills nav-stacked"> <li><a href="#arguments">Arguments</a></li> - + + <li><a href="#value">Value</a></li> + <li><a href="#examples">Examples</a></li> </ul> diff --git a/man/one_box.Rd b/man/one_box.Rd index 1bdc791..134b206 100644 --- a/man/one_box.Rd +++ b/man/one_box.Rd @@ -14,14 +14,20 @@ one_box(x, ini, ..., t_end = 100, res = 0.01) \method{one_box}{character}(x, ini = 1, parms, ..., t_end = 100, res = 0.01) -\method{one_box}{mkinfit}(x, ini = c("model", 1), ..., t_end = 100, - res = 0.01) +\method{one_box}{mkinfit}(x, ini = "model", ..., t_end = 100, res = 0.01) } \arguments{ \item{x}{When numeric, this is the half-life to be used for an exponential -decline. If x is an mkinfit object, the decline is calculated from this object} +decline. When a character string specifying a parent decline model is given +e.g. \code{FOMC}, \code{parms} must contain the corresponding paramters. +If x is an \code{\link{mkinfit}} object, the decline is calculated from this +object.} -\item{ini}{The initial amount for each compound} +\item{ini}{The initial amount for the parent compound. If x is an +\code{\link{mkinfit}} object, and ini is 'model', the fitted initial +concentrations are used. Otherwise, ini must be numeric. If it has +length one, it is used for the parent and initial values of metabolites +are zero, otherwise, it must give values for all observed variables.} \item{...}{Further arguments passed to methods} @@ -31,9 +37,11 @@ decline. If x is an mkinfit object, the decline is calculated from this object} \item{parms}{A named numeric vector containing the model parameters} } +\value{ +An object of class \code{one_box}, inheriting from \code{\link{ts}}. +} \description{ -The time series starts with the amount specified for the first application. -This does not create objects of type \code{\link{ts}}. +Create a time series of decline data } \examples{ # Only use a half-life |