RxODE (version 0.9.0-8)

cvPost: Sample a covariance Matrix from the Posteior Inverse Wishart distribution.

Description

Note this Inverse wishart rescaled to match the original scale of the covariance matrix.

Usage

cvPost(nu, omega, n = 1L, omegaIsChol = FALSE, returnChol = FALSE)

Arguments

nu

Degrees of Freedom (Number of Observations) for covariance matrix simulation.

omega

Estimate of Covariance matrix.

n

Number of Matrices to sample. By default this is 1.

omegaIsChol

is an indicator of if the omega matrix is in the cholesky decomposition.

returnChol

Return the cholesky decomposition of the covariance matrix sample.

Value

a matrix (n=1) or a list of matricies (n > 1)

Details

If your covariance matrix is a 1x1 matrix, this uses an scaled inverse chi-squared which is equivalent to the Inverse Wishart distribution in the uni-directional case.

Examples

Run this code
# NOT RUN {
## Sample a single covariance.
draw1 <- cvPost(3, matrix(c(1,.3,.3,1),2,2))

## Sample 3 covariances
set.seed(42)
draw3 <- cvPost(3, matrix(c(1,.3,.3,1),2,2), n=3)

## Sample 3 covariances, but return the cholesky decomposition
set.seed(42)
draw3c <- cvPost(3, matrix(c(1,.3,.3,1),2,2), n=3, returnChol=TRUE)
# }

Run the code above in your browser using DataCamp Workspace