Learn R Programming

rv (version 1.1.0)

rvsims: Create Random Vectors from Simulation Draws

Description

rvsims takes a vector, matrix, or list (sims) containing simulations, and returns a random vector (an object of type 'rv')

Usage

rvsims(sims, n.sims=getnsims(), permute=FALSE)

Arguments

sims
an array of simulations (1, or 2-dimensional) or a list
n.sims
number of simulations to save
permute
logical, indicate if scramble the simulations

Details

A vector is interpreted to contain simulations for one single random variable.

If sims is two-dimensional, the columns are supposed to contain simulations for several random variables.

If sims is a list, the numeric vectors are recursively combined to a list of random vectors: each component of the list is supposed to be containing one (joint) draw from some distribution---this may be a list.

If permute is TRUE, the simulations are scrambled, i.e. the joint draws are permuted randomly.

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").

Examples

Run this code
# x and y have the same distributions but not the same simulations:
  setnsims(200)
  y <- rvnorm(1)
  x <- rvsims(rnorm(getnsims()))
  #

Run the code above in your browser using DataLab