cov.rv: Distributions of Various Statistics of a Random Vector and...

Description Usage Arguments Details Value Author(s) References Examples


var.rv, cov.rv and cor.rv compute the distribution of the variance statistic of x and the distribution of the covariance statistic or the correlation statistic of x and y if these are vectors. If x and y are matrices then the covariances (or correlations) between the columns of x and the columns of y are computed.


  sd.rv(x, na.rm=FALSE)
  cov.rv(x, y=NULL, ...)
  cor.rv(x, y=NULL, ...)
  var.rv(x, ...)



a numeric or random vector, matrix, or a data frame


NULL (default) or a vector, matrix or data frame with compatible dimensions to x. The default is equivalent to y = x (but more efficient).


further arguments passed to the corresponding numeric functions


These functions are compatible with both numeric and rv objects. To make your code compatible with rv objects, use e.g. sd.rv instead of sd.

The functions cov.rv is implemented by applying the corresponding numerical function to the rows of the simulation matrices of x and y and forming a new rv object from the resulting vector of simulations. Alternatively x may be a random matrix (and y NULL).

cor.rv works similarly, but returns the distribution of the correlation statistic (i.e. function).

var.rv computes the distribution of the variance statistic. sd.rv is the square root of the result obtained by var.rv.


A random vector or array.


Jouni Kerman


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



Search within the rv package
Search all R packages, documentation and source code

Questions? Problems? Suggestions? or email at

Please suggest features or report bugs with the GitHub issue tracker.

All documentation is copyright its authors; we didn't write any of that.