rvsims {rv}R Documentation

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=rvnsims(), 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.

Author(s)

Jouni Kerman kerman@stat.columbia.edu http://www.stat.columbia.edu/~kerman

References

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

Examples

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

[Package rv version 0.911 Index]