Learn R Programming

rv (version 0.949)

sims: Retrieve the Simulations of Random Vectors

Description

Returns the simulation matrix for the random variable object x.

Usage

sims(x, n.sims=NULL, dimensions=FALSE, sim.matrix=FALSE, mc.array=FALSE)
 ## S3 method for class 'default':
sims(x, ...)
 ## S3 method for class 'rv':
sims(x, n.sims=NULL, dimensions=FALSE, sim.matrix=FALSE, mc.array=FALSE)

Arguments

x
a random variable object
n.sims
(optional) number of simulations
dimensions
logical, try to preserve the dimensions of x
sim.matrix
logical, (if dimensions is TRUE) indicate if want to return the plain simulation matrix as attribute ``sim.matrix"
mc.array
logical, indicate if want to return the original 3-way mcmc matrix, if possible
...
omitted arguments

Details

sims returns the matrix of simulations for a given random variable object x.

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 <- rvnorm(24)               # Suppose that L is the number of simulations per scalar
  dim(x) <- c(2,3,4)
  dim(sims(x))                  # Lx24
  dim(sims(x, dimensions=TRUE)) # Lx2x3x4
  dim(attr(sims(x, dimensions=TRUE, sim.matrix=TRUE), "sim.matrix")) # Lx24
  dim(sims(x, mc.array=TRUE)) # Error: x was not generated by a mcmc process

Run the code above in your browser using DataLab