Skip to content
Snippets Groups Projects
Commit 35518b52 authored by Sebastian Henz's avatar Sebastian Henz
Browse files

Merge branch 'bugfix/documentation' into 'develop'

Fix documentation of ecxsys and predict_ecxsys

See merge request !17
parents 7dbf78a3 6d14df76
No related branches found
No related tags found
2 merge requests!19Develop,!17Bugfix/documentation
Package: stressaddition Package: stressaddition
Type: Package Type: Package
Title: Modeling Tri-Phasic Concentration-Response Relationships Title: Modeling Tri-Phasic Concentration-Response Relationships
Version: 2.0.0 Version: 2.0.0.9000
Date: 2020-02-17 Date: 2020-02-17
Authors@R: person("Sebastian", "Henz", role = c("aut", "cre"), Authors@R: person("Sebastian", "Henz", role = c("aut", "cre"),
email = "sebastian.henz@ufz.de", email = "sebastian.henz@ufz.de",
......
# stressaddition (development version)
* Fix documentation of `ecxsys()` and `predict_ecxsys`.
# stressaddition 2.0.0 # stressaddition 2.0.0
* Changed the order of arguments in `ecxsys()`. * Changed the order of arguments in `ecxsys()`.
......
...@@ -8,8 +8,8 @@ ...@@ -8,8 +8,8 @@
#' ECx-SyS #' ECx-SyS
#' #'
#' The ECx-SyS model for modeling concentration-effect relationships which #' The ECx-SyS model for modeling concentration-effect relationships whith
#' indicate signs of hormesis. #' hormesis.
#' #'
#' It is advised to complete the curve down to zero for optimal prediction. #' It is advised to complete the curve down to zero for optimal prediction.
#' Therefore \code{effect_tox_observed} in the highest concentration should be #' Therefore \code{effect_tox_observed} in the highest concentration should be
...@@ -20,9 +20,8 @@ ...@@ -20,9 +20,8 @@
#' \code{effect_tox_env_observed} (if provided) must be of equal length and #' \code{effect_tox_env_observed} (if provided) must be of equal length and
#' sorted by increasing concentration. #' sorted by increasing concentration.
#' #'
#' @param concentration A vector of concentrations, one of which must be 0 to #' @param concentration A vector of concentrations. Must be sorted in ascending
#' indicate the control. Should be sorted in ascending order, otherwise it #' order and the first element must be 0 to indicate the control.
#' will be sorted automatically.
#' @param hormesis_concentration The concentration where the hormesis occurs. #' @param hormesis_concentration The concentration where the hormesis occurs.
#' This is usually the concentration of the highest effect after the control. #' This is usually the concentration of the highest effect after the control.
#' @param effect_tox_observed A vector of effect values observed at the given #' @param effect_tox_observed A vector of effect values observed at the given
...@@ -34,10 +33,31 @@ ...@@ -34,10 +33,31 @@
#' survival data in percent this should be 100 (the default). #' survival data in percent this should be 100 (the default).
#' @param p,q The shape parameters of the beta distribution. Default is 3.2. #' @param p,q The shape parameters of the beta distribution. Default is 3.2.
#' #'
#' @return A list (of class ecxsys) containing many different objects with the #' @return A list (of class ecxsys) containing many different objects of which
#' most important being \code{curves}, a data frame containing effect and #' the most important are listed below. The effect and stress vectors
#' stress values at different concentrations. See \code{\link{predict_ecxsys}} #' correspond to the provided concentrations.
#' for details. #' \describe{
#' \item{effect_tox}{Modeled effect resulting from toxicant stress.}
#' \item{effect_tox_sys}{Modeled effect resulting from toxicant and system
#' stress.}
#' \item{effect_tox_env}{Modeled effect resulting from toxicant and
#' environmental stress.}
#' \item{effect_tox_env_sys}{Modeled effect resulting from toxicant,
#' environmental and system stress.}
#' \item{effect_tox_LL5}{The effect predicted by the five-parameter
#' log-logistic model derived from the observations under toxicant stress
#' but without environmental stress.}
#' \item{effect_tox_env_LL5}{The effect predicted by the five-parameter
#' log-logistic model derived from the observations under toxicant stress
#' with environmental stress.}
#' \item{curves}{A data frame containing effect and stress values as
#' returned by \code{\link{predict_ecxsys}}. The concentrations are
#' regularly spaced on a logarithmic scale in the given concentration range.
#' The control is approximated by the lowest non-control concentration times
#' 1e-7. The additional column \code{use_for_plotting} is used by the
#' plotting functions of this package to approximate the control and
#' generate a break in the concentration axis.}
#' }
#' #'
#' @examples model <- ecxsys( #' @examples model <- ecxsys(
#' concentration = c(0, 0.03, 0.3, 3, 10), #' concentration = c(0, 0.03, 0.3, 3, 10),
...@@ -46,7 +66,7 @@ ...@@ -46,7 +66,7 @@
#' effect_tox_env_observed = c(24, 23, 32, 0, 0) #' effect_tox_env_observed = c(24, 23, 32, 0, 0)
#' ) #' )
#' #'
#' # Use effect_max if for example the effect is given as the number of #' # Use effect_max if for example the effect is given as the average number of
#' # surviving animals and the initial number of animals is 20: #' # surviving animals and the initial number of animals is 20:
#' model <- ecxsys( #' model <- ecxsys(
#' concentration = c(0, 0.03, 0.3, 3, 10), #' concentration = c(0, 0.03, 0.3, 3, 10),
...@@ -111,8 +131,7 @@ ecxsys <- function(concentration, ...@@ -111,8 +131,7 @@ ecxsys <- function(concentration,
if (any(is.na(c(all_observations, concentration)))) { if (any(is.na(c(all_observations, concentration)))) {
stop("Values containing NA are not supported.") stop("Values containing NA are not supported.")
} }
if (any(all_observations > effect_max) || if (any(all_observations > effect_max) || any(all_observations < 0)) {
any(all_observations < 0)) {
stop("Observed effect must be between 0 and effect_max.") stop("Observed effect must be between 0 and effect_max.")
} }
conc_shift <- 2 # Powers of ten to shift the control downwards from the conc_shift <- 2 # Powers of ten to shift the control downwards from the
......
#' Predict ECxSyS at various concentrations #' Predict effects and stresses
#' #'
#' @param model The output of a call to \code{\link{ecxsys}}. #' Calculate the effects and stresses of an ECx-SyS model at arbitrary
#' concentrations.
#'
#' @param model An ECx-SyS model as returned by \code{\link{ecxsys}}.
#' @param concentration A numeric vector of concentrations. #' @param concentration A numeric vector of concentrations.
#' #'
#' @return A data frame (of class "ecxsys_predicted") with the following #' @return A data frame (of class "ecxsys_predicted") with the following
#' columns: #' columns:
#' \describe{ #' \describe{
#' \item{concentration}{Concentrations regularly spaced on a logarithmic #' \item{concentration}{The supplied concentrations.}
#' scale in the given concentration range. The control is approximated by #' \item{effect_tox_LL5}{The effect predicted by the five-parameter
#' the lowest non-control concentration times 1e-7.} #' log-logistic model derived from the observations under toxicant stress
#' \item{effect_tox_LL5}{The five-parameter log-logistic model of the #' but without environmental stress.}
#' effect derived from the observations under toxicant stress but without #' \item{effect_tox}{Modeled effect resulting from toxicant stress.}
#' environmental stress.}
#' \item{effect_tox}{Modeled effect resulting from toxicant and system
#' stress.}
#' \item{effect_tox_sys}{Modeled effect resulting from toxicant and system #' \item{effect_tox_sys}{Modeled effect resulting from toxicant and system
#' stress.} #' stress.}
#' \item{stress_tox}{The toxicant stress.} #' \item{stress_tox}{The toxicant stress.}
...@@ -21,9 +21,9 @@ ...@@ -21,9 +21,9 @@
#' without environmental stress.} #' without environmental stress.}
#' \item{stress_tox_sys}{The sum of \code{stress_tox} and #' \item{stress_tox_sys}{The sum of \code{stress_tox} and
#' \code{sys_tox}.} #' \code{sys_tox}.}
#' \item{effect_tox_env_LL5}{The five-parameter log-logistic model of the #' \item{effect_tox_env_LL5}{The effect predicted by the five-parameter
#' effect derived from the observations under toxicant stress with #' log-logistic model derived from the observations under toxicant stress
#' environmental stress.} #' with environmental stress.}
#' \item{effect_tox_env}{Modeled effect resulting from toxicant and #' \item{effect_tox_env}{Modeled effect resulting from toxicant and
#' environmental stress.} #' environmental stress.}
#' \item{effect_tox_env_sys}{Modeled effect resulting from toxicant, #' \item{effect_tox_env_sys}{Modeled effect resulting from toxicant,
...@@ -39,7 +39,8 @@ ...@@ -39,7 +39,8 @@
#' @examples model <- ecxsys( #' @examples model <- ecxsys(
#' concentration = c(0, 0.03, 0.3, 3, 10), #' concentration = c(0, 0.03, 0.3, 3, 10),
#' hormesis_concentration = 0.3, #' hormesis_concentration = 0.3,
#' effect_tox_observed = c(85, 76, 94, 35, 0) #' effect_tox_observed = c(85, 76, 94, 35, 0),
#' effect_tox_env_observed = c(24, 23, 32, 0, 0)
#' ) #' )
#' p <- predict_ecxsys(model, c(0.001, 0.01, 0.1, 1, 10)) #' p <- predict_ecxsys(model, c(0.001, 0.01, 0.1, 1, 10))
#' #'
......
...@@ -15,9 +15,8 @@ ecxsys( ...@@ -15,9 +15,8 @@ ecxsys(
) )
} }
\arguments{ \arguments{
\item{concentration}{A vector of concentrations, one of which must be 0 to \item{concentration}{A vector of concentrations. Must be sorted in ascending
indicate the control. Should be sorted in ascending order, otherwise it order and the first element must be 0 to indicate the control.}
will be sorted automatically.}
\item{hormesis_concentration}{The concentration where the hormesis occurs. \item{hormesis_concentration}{The concentration where the hormesis occurs.
This is usually the concentration of the highest effect after the control.} This is usually the concentration of the highest effect after the control.}
...@@ -35,14 +34,35 @@ survival data in percent this should be 100 (the default).} ...@@ -35,14 +34,35 @@ survival data in percent this should be 100 (the default).}
\item{p, q}{The shape parameters of the beta distribution. Default is 3.2.} \item{p, q}{The shape parameters of the beta distribution. Default is 3.2.}
} }
\value{ \value{
A list (of class ecxsys) containing many different objects with the A list (of class ecxsys) containing many different objects of which
most important being \code{curves}, a data frame containing effect and the most important are listed below. The effect and stress vectors
stress values at different concentrations. See \code{\link{predict_ecxsys}} correspond to the provided concentrations.
for details. \describe{
\item{effect_tox}{Modeled effect resulting from toxicant stress.}
\item{effect_tox_sys}{Modeled effect resulting from toxicant and system
stress.}
\item{effect_tox_env}{Modeled effect resulting from toxicant and
environmental stress.}
\item{effect_tox_env_sys}{Modeled effect resulting from toxicant,
environmental and system stress.}
\item{effect_tox_LL5}{The effect predicted by the five-parameter
log-logistic model derived from the observations under toxicant stress
but without environmental stress.}
\item{effect_tox_env_LL5}{The effect predicted by the five-parameter
log-logistic model derived from the observations under toxicant stress
with environmental stress.}
\item{curves}{A data frame containing effect and stress values as
returned by \code{\link{predict_ecxsys}}. The concentrations are
regularly spaced on a logarithmic scale in the given concentration range.
The control is approximated by the lowest non-control concentration times
1e-7. The additional column \code{use_for_plotting} is used by the
plotting functions of this package to approximate the control and
generate a break in the concentration axis.}
}
} }
\description{ \description{
The ECx-SyS model for modeling concentration-effect relationships which The ECx-SyS model for modeling concentration-effect relationships whith
indicate signs of hormesis. hormesis.
} }
\details{ \details{
It is advised to complete the curve down to zero for optimal prediction. It is advised to complete the curve down to zero for optimal prediction.
...@@ -62,7 +82,7 @@ model <- ecxsys( ...@@ -62,7 +82,7 @@ model <- ecxsys(
effect_tox_env_observed = c(24, 23, 32, 0, 0) effect_tox_env_observed = c(24, 23, 32, 0, 0)
) )
# Use effect_max if for example the effect is given as the number of # Use effect_max if for example the effect is given as the average number of
# surviving animals and the initial number of animals is 20: # surviving animals and the initial number of animals is 20:
model <- ecxsys( model <- ecxsys(
concentration = c(0, 0.03, 0.3, 3, 10), concentration = c(0, 0.03, 0.3, 3, 10),
......
...@@ -2,12 +2,12 @@ ...@@ -2,12 +2,12 @@
% Please edit documentation in R/predict_ecxsys.R % Please edit documentation in R/predict_ecxsys.R
\name{predict_ecxsys} \name{predict_ecxsys}
\alias{predict_ecxsys} \alias{predict_ecxsys}
\title{Predict ECxSyS at various concentrations} \title{Predict effects and stresses}
\usage{ \usage{
predict_ecxsys(model, concentration) predict_ecxsys(model, concentration)
} }
\arguments{ \arguments{
\item{model}{The output of a call to \code{\link{ecxsys}}.} \item{model}{An ECx-SyS model as returned by \code{\link{ecxsys}}.}
\item{concentration}{A numeric vector of concentrations.} \item{concentration}{A numeric vector of concentrations.}
} }
...@@ -15,14 +15,11 @@ predict_ecxsys(model, concentration) ...@@ -15,14 +15,11 @@ predict_ecxsys(model, concentration)
A data frame (of class "ecxsys_predicted") with the following A data frame (of class "ecxsys_predicted") with the following
columns: columns:
\describe{ \describe{
\item{concentration}{Concentrations regularly spaced on a logarithmic \item{concentration}{The supplied concentrations.}
scale in the given concentration range. The control is approximated by \item{effect_tox_LL5}{The effect predicted by the five-parameter
the lowest non-control concentration times 1e-7.} log-logistic model derived from the observations under toxicant stress
\item{effect_tox_LL5}{The five-parameter log-logistic model of the but without environmental stress.}
effect derived from the observations under toxicant stress but without \item{effect_tox}{Modeled effect resulting from toxicant stress.}
environmental stress.}
\item{effect_tox}{Modeled effect resulting from toxicant and system
stress.}
\item{effect_tox_sys}{Modeled effect resulting from toxicant and system \item{effect_tox_sys}{Modeled effect resulting from toxicant and system
stress.} stress.}
\item{stress_tox}{The toxicant stress.} \item{stress_tox}{The toxicant stress.}
...@@ -30,9 +27,9 @@ A data frame (of class "ecxsys_predicted") with the following ...@@ -30,9 +27,9 @@ A data frame (of class "ecxsys_predicted") with the following
without environmental stress.} without environmental stress.}
\item{stress_tox_sys}{The sum of \code{stress_tox} and \item{stress_tox_sys}{The sum of \code{stress_tox} and
\code{sys_tox}.} \code{sys_tox}.}
\item{effect_tox_env_LL5}{The five-parameter log-logistic model of the \item{effect_tox_env_LL5}{The effect predicted by the five-parameter
effect derived from the observations under toxicant stress with log-logistic model derived from the observations under toxicant stress
environmental stress.} with environmental stress.}
\item{effect_tox_env}{Modeled effect resulting from toxicant and \item{effect_tox_env}{Modeled effect resulting from toxicant and
environmental stress.} environmental stress.}
\item{effect_tox_env_sys}{Modeled effect resulting from toxicant, \item{effect_tox_env_sys}{Modeled effect resulting from toxicant,
...@@ -46,13 +43,15 @@ A data frame (of class "ecxsys_predicted") with the following ...@@ -46,13 +43,15 @@ A data frame (of class "ecxsys_predicted") with the following
} }
} }
\description{ \description{
Predict ECxSyS at various concentrations Calculate the effects and stresses of an ECx-SyS model at arbitrary
concentrations.
} }
\examples{ \examples{
model <- ecxsys( model <- ecxsys(
concentration = c(0, 0.03, 0.3, 3, 10), concentration = c(0, 0.03, 0.3, 3, 10),
hormesis_concentration = 0.3, hormesis_concentration = 0.3,
effect_tox_observed = c(85, 76, 94, 35, 0) effect_tox_observed = c(85, 76, 94, 35, 0),
effect_tox_env_observed = c(24, 23, 32, 0, 0)
) )
p <- predict_ecxsys(model, c(0.001, 0.01, 0.1, 1, 10)) p <- predict_ecxsys(model, c(0.001, 0.01, 0.1, 1, 10))
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment