Learn R Programming

BDgraph (version 2.33)

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. The default value is 1.
p
The number of variables (nodes). The default value is 2.
b
The degree of freedom for Wishart distribution, \(W(b, D)\). The default value is 3.
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)\).

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

Mohammadi, A. and E. Wit (2015). Bayesian Structure Learning in Sparse Gaussian Graphical Models, Bayesian Analysis, 10(1):109-138 Mohammadi, A. and E. Wit (2015). BDgraph: An R Package for Bayesian Structure Learning in Graphical Models, arXiv:1501.05108 Mohammadi, A., F. Abegaz Yazew, E. van den Heuvel, and E. Wit (2016). Bayesian modelling of Dupuytren disease by using Gaussian copula graphical models, Journal of the Royal Statistical Society: Series C

Examples

Run this code
## Not run: ------------------------------------
# p      <- 5
# sample <- rwish( n = 3, p = p, b = 3, D = diag(p) )
# round( sample, 2 )  
## ---------------------------------------------

Run the code above in your browser using DataLab