rvmapply {rv}R Documentation

Apply a function to multiple random vector arguments

Description

rvmapply is the rv-compatible version of mapply. It repeats the function FUN for each joint draw of the random (or constant) arguments, while allowing vectorizing.

Usage

  rvmapply(FUN, ..., MoreArgs=NULL, SIMPLIFY = FALSE, USE.NAMES=TRUE, SAMPLESIZE=NULL)
  rvVectorize(FUN, vectorize.args = arg.names, SIMPLIFY = FALSE, USE.NAMES = TRUE, SAMPLESIZE=NULL) 

Arguments

FUN the function to apply to the simulations of X.
MoreArgs Other args passed to FUN `as is' (must not be rv objects unless the function already accepts them)
USE.NAMES logical; see mapply for details
SIMPLIFY logical; see mapply for details
SAMPLESIZE if specified, takes a (joint) sample of the simulations and processes only them.
vectorize.args a character vector of arguments which should be vectorized. Defaults to all arguments to FUN.
... further arguments to FUN, possibly random vectors or array.

Details

rvmapply applies a given function to each simulation (vector or array) of the given random vectors, returning a the results as a random vector or array.

The dimensions of each joint draw are preserved. For an example, see solve, that returns the distribution of the inverse of a random matrix.

Usually used in functions that implement an 'rv'-compatible routine.

For an example of a function that uses SAMPLESIZE, abline.

Value

Depends on FUN; a random vector or array if FUN is numeric.

Note

If the function (FUN) has an argument ``FUN", it must be specified within the list supplied to MoreArgs.

Author(s)

Jouni Kerman jouni@kerman.com

References

Kerman, J. and Gelman, A. (2007). Manipulating and Summarizing Posterior Simulations Using Random Variable Objects. Statistics and Computing 17:3, 235-244.

See also vignette("rv").

See Also

mapply, simapply


[Package rv version 1.0 Index]