Learn R Programming

rv (version 0.949)

rvsims: Create a Random Vector from a Matrix of Simulations

Description

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

Usage

rvsims(sims, n.sims=setnsims(), permute=FALSE, save.order=FALSE)

Arguments

sims
an array of simulations (1, 2, or 3-dimensional)
n.sims
number of simulations to save
permute
logical, indicate if scramble the simulations
save.order
logical, indicate if the original order of simulations should be saved (only if permute is TRUE)

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 three-dimensional, it is supposed to be output from a Markov chain simulation program: the first dimension corresponds to the simulations, the second corresponds to the chains (typically 3 or 5), and the last dimension corresponds to the variables.

If permute is TRUE, the simulations are scrambled, i.e. the rows are permuted randomly. If permute=TRUE and save.order=TRUE, the original order of the simulations is saved in an attribute rvsim$order.

If sims is three-dimensional, the simulations are always scrambled.

References

Kerman, Jouni and Gelman, Andrew. Manipulating and Summarizing Posterior Simulations Using Random Variable Objects. Technical report, Columbia University, New York.

Examples

Run this code
# x and y have the same distributions:
  x <- sims(rnorm(1000))
  y <- rvnorm(1)

Run the code above in your browser using DataLab