diff --git a/R/apply_niche.R b/R/apply_niche.R index f320be4..09e0264 100644 --- a/R/apply_niche.R +++ b/R/apply_niche.R @@ -11,6 +11,8 @@ apply_niche = function(x, niche_def, gc){ #' Models niches by removing events (fossil occurrences) when they are outside of their niche using the function `thin`. #' Combines the functions `niche_def` and `gc` ("gradient change") to determine how the taxons' collection probability changes with time/position. This is done by composing `niche_def` and `gc`. The result is then used as a thinning on the events `x`. #' + #' @returns numeric vector, events preserved after thinning + #' #' @examples #' \dontrun{ #' ## setup diff --git a/R/apply_taphonomy.R b/R/apply_taphonomy.R index fadda79..c76b25d 100644 --- a/R/apply_taphonomy.R +++ b/R/apply_taphonomy.R @@ -13,7 +13,15 @@ apply_taphonomy = function(x, pres_potential, ctc){ #' #' @seealso [apply_niche()] for modeling niche preferences based on the same principle, [thin()] for the underlying mathematical procedure. #' + #' @returns numeric vector, events preserved after taphonomic effects are applied #' + #' @examples + #' \dontrun{ + #' # see + #' vignette("advanced_functionality") + #' # details on usage + #' } + #' # function that returns preservation potential as a function of input (e.g. time or position) change_pres_pot = function(y) pres_potential(ctc(y)) diff --git a/R/p3_var_rate.R b/R/p3_var_rate.R index dba911e..7e6464a 100644 --- a/R/p3_var_rate.R +++ b/R/p3_var_rate.R @@ -35,6 +35,8 @@ p3_var_rate = function(x, y = NULL, from = 0, to = 1, f_max = 1, n = NULL){ #' } #' #' @seealso [p3()] for the constant rate implementation, [rej_samp()] for the underlying random number generation. + #' + #' @returns numeric vector, timing/location of events if (from >= to){ stop("\"from\" must be smaller than \"to\".") diff --git a/R/rej_samp.R b/R/rej_samp.R index b348ce2..32f05eb 100644 --- a/R/rej_samp.R +++ b/R/rej_samp.R @@ -19,6 +19,8 @@ rej_samp = function(f, x_min, x_max, n = 1L, f_max = 1){ #' hist(x) # note that no samples are drawn where sin is negative #' } #' @seealso [p3_var_rate()] for the derived variable rate Poisson point process implementation. + #' + #' @returns numeric vector, samples drawn from the (pseudo) pdf x = c() warn = FALSE if (f_max <= 0) {stop("`f_max` must be positive.")} diff --git a/R/thin.R b/R/thin.R index 010731b..2146c1c 100644 --- a/R/thin.R +++ b/R/thin.R @@ -23,6 +23,8 @@ thin = function(x, thin){ #' } #' #' @seealso [apply_niche()] and [apply_taphonomy()] for use cases with biological meaning + #' + #' @returns numeric vector, events after thinning p = pmax(pmin(thin(x), rep(1, length(x))), rep(0, length(x))) # cut off at 0 and 1 ind = stats::rbinom(n = length(x), size = 1, prob = p) # determine if preserved or not diff --git a/man/apply_niche.Rd b/man/apply_niche.Rd index d348782..1089092 100644 --- a/man/apply_niche.Rd +++ b/man/apply_niche.Rd @@ -13,6 +13,9 @@ apply_niche(x, niche_def, gc) \item{gc}{function, stands for "gradient change". Specifies how the gradient changes, e.g. with time} } +\value{ +numeric vector, events preserved after thinning +} \description{ Models niches by removing events (fossil occurrences) when they are outside of their niche using the function \code{thin}. Combines the functions \code{niche_def} and \code{gc} ("gradient change") to determine how the taxons' collection probability changes with time/position. This is done by composing \code{niche_def} and \code{gc}. The result is then used as a thinning on the events \code{x}. diff --git a/man/apply_taphonomy.Rd b/man/apply_taphonomy.Rd index 4ceee33..8677e6e 100644 --- a/man/apply_taphonomy.Rd +++ b/man/apply_taphonomy.Rd @@ -13,8 +13,19 @@ apply_taphonomy(x, pres_potential, ctc) \item{ctc}{function, change in taphonomic conditions (ctc) with time or stratigraphic position.} } +\value{ +numeric vector, events preserved after taphonomic effects are applied +} \description{ Models taphonomy by combining the change in taphonomic conditions with the preservation potential as a function of taphonomic conditions to determine how preservation potential changes. This is then used to systematically remove (thin) the event data using \code{thin}. +} +\examples{ +\dontrun{ +# see +vignette("advanced_functionality") +# details on usage +} + } \seealso{ \code{\link[=apply_niche]{apply_niche()}} for modeling niche preferences based on the same principle, \code{\link[=thin]{thin()}} for the underlying mathematical procedure. diff --git a/man/p3_var_rate.Rd b/man/p3_var_rate.Rd index 16555e1..79dcbb4 100644 --- a/man/p3_var_rate.Rd +++ b/man/p3_var_rate.Rd @@ -19,6 +19,9 @@ p3_var_rate(x, y = NULL, from = 0, to = 1, f_max = 1, n = NULL) \item{n}{NULL or an integer. Number of events drawn. If NULL, the number of events is determined by the rate (specified by x and y). If an integer is passed, n events are returned.} } +\value{ +numeric vector, timing/location of events +} \description{ simulates events based on a variable rate Poisson point process. Rates can be either specified by a function passed to \code{x}, or by providing two vectors \code{x} and \code{y}. In this case the rate is specified by approxfun(x, y, rule = 2), i.e. by linear interpolation between the values of x (abscissa) and y (ordinate) In the context of paleontology, these events can be interpreted as fossil occurrences or first/last occurrences of species. In this case, the rate is the average number of fossil occurrences (resp first/last occurrences) per unit diff --git a/man/rej_samp.Rd b/man/rej_samp.Rd index 8ba6312..2137dd5 100644 --- a/man/rej_samp.Rd +++ b/man/rej_samp.Rd @@ -17,6 +17,9 @@ rej_samp(f, x_min, x_max, n = 1L, f_max = 1) \item{f_max}{maximum value of \code{f} in the interval from \code{x_min} to \code{x_max}. If f attains values larger than \code{f_max} a warning is throw, \code{f_max} is adjusted, and sampling is started again} } +\value{ +numeric vector, samples drawn from the (pseudo) pdf +} \description{ Rejection sampling from the (pseudo) pdf \code{f} in the interval between \code{x_min} and \code{x_max}. Returns \code{n} samples. Note that values of \code{f} below 0 are capped to zero } diff --git a/man/thin.Rd b/man/thin.Rd index b9711fa..44482b0 100644 --- a/man/thin.Rd +++ b/man/thin.Rd @@ -11,6 +11,9 @@ thin(x, thin) \item{thin}{a function used for thinning} } +\value{ +numeric vector, events after thinning +} \description{ Thins a vector of events using the function thin, meaning the probability that the ith event in x is preserved is given by \emph{thin(x(i))}. Values of \code{thin} below 0 and above 1 are ignored.