rvarray: Matrices and Arrays of Random Vectors

Description Usage Arguments Details Author(s) References See Also Examples

Description

Arrange a given random vector into a matrix or array form.

Usage

1
2
3

Arguments

data

an optional data vector.

nrow

the desired number of rows.

ncol

the desired number of columns.

byrow

logical. If FALSE (the default) the matrix is filled by columns, otherwise the matrix is filled by rows.

dimnames

A dimnames attribute for the matrix: a list of length 2 giving the row and column names respectively.

dim

the dim attribute for the array to be created, that is a vector of length one or more giving the maximal indices in each dimension.

Details

These are 'rv' compatible versions of the functions matrix and array.

The function rvmatrix generates the random variable matrix via an rvarray call.

The rvarray function calls first array to set the dimensions of the argument data and then coerces the resulting array object to an 'rv' object.

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

To plot random matrices, see mlplot.

Examples

1
2
3
4
5
6
7
8
  n.rows <- 3; n.cols <- 4; n <- (n.rows*n.cols)
  mu.true <- rnorm(1:n.rows, mean=1:n.rows, sd=1)
  theta <- rvmatrix(rvnorm(n=n.cols, mean=mu.true, sd=0.5), nrow=n.rows)
  col.labels <- paste("Time", 1:n.cols, sep=":")
  row.labels <- paste("Unit", 1:n.rows, sep=":")
  dimnames(theta) <- list(row.labels, col.labels)
  print(theta)
  print(E(theta))  

jsta/rv documentation built on Feb. 12, 2022, 5:13 p.m.