BDgraph (version 2.62)

rwish: Sampling from Wishart distribution

Description

Generates random matrices, distributed according to the Wishart distribution with parameters \(b\) and \(D\), \(W(b, D)\).

Usage

rwish( n = 1, p = 2, b = 3, D = diag( p ) )

Arguments

n

The number of samples required.

p

The number of variables (nodes).

b

The degree of freedom for Wishart distribution, \(W(b, D)\).

D

The positive definite \((p \times p)\) "scale" matrix for Wishart distribution, \(W(b, D)\). The default is an identity matrix.

Value

A numeric array, say A, of dimension \((p \times p \times n)\), where each \(A[,,i]\) is a positive definite matrix, a realization of the Wishart distribution \(W(b, D)\). Note, for the case \(n=1\), the output is a matrix.

Details

Sampling from Wishart distribution, \(K \sim W(b, D)\), with density:

$$Pr(K) \propto |K| ^ {(b - 2) / 2} \exp \left\{- \frac{1}{2} \mbox{trace}(K \times D)\right\},$$

which \(b > 2\) is the degree of freedom and \(D\) is a symmetric positive definite matrix.

References

Lenkoski, A. (2013). A direct sampler for G-Wishart variates, Stat, 2:119-128

Mohammadi, A. and Wit, E. C. (2015). Bayesian Structure Learning in Sparse Gaussian Graphical Models, Bayesian Analysis, 10(1):109-138

Letac, G., Massam, H. and Mohammadi, R. (2018). The Ratio of Normalizing Constants for Bayesian Graphical Gaussian Model Selection, arXiv preprint arXiv:1706.04416v2

Mohammadi, R. and Wit, E. C. (2019). BDgraph: An R Package for Bayesian Structure Learning in Graphical Models, Journal of Statistical Software, 89(3):1-30

See Also

gnorm, rgwish

Examples

Run this code
# NOT RUN {
sample <- rwish( n = 3, p = 5, b = 3, D = diag( 5 ) )

round( sample, 2 )  
# }

Run the code above in your browser using DataLab