Learn R Programming

BDgraph (version 2.13)

rgwish: Sampling from G-Wishart distribution

Description

Generate n random matrices, distributed according to the G-Wishart distribution with parameters b and D, $W_G(b, D)$.

Usage

rgwish( n = 1, G = NULL, b = 3, D = NULL )

Arguments

n
The number of samples required. The default is 1.
G
Adjacency matrix corresponding to the graph structure. It is an upper triangular matrix in which $G_{ij}=1$ if there is a link between notes $i$ and $j$, otherwise $G_{ij}=0$.
b
the degree of freedom for G-Wishart distribution, $W_G(b, D)$. The default is 3.
D
the positive definite $(p \times p)$ "scale" matrix for G-Wishart distribution, $W_G(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 G-Wishart distribution $W_G(b, D)$.

Details

Sampling from G-Wishart(b,D) distribution with density: $$p(K) \propto |K| ^ {(b - 2) / 2} exp(- \frac{1}{2} trace(K \times D))$$ which $b > 2$ is the degree of freedom and D is a symmetric positive definite matrix.

References

Mohammadi, A. and Wit, E. C. (2014). Bayesian structure learning in sparse Gaussian graphical models, Bayesian Analysis, acceped. http://arxiv.org/abs/1210.5371v6 Lenkoski, A. (2013). A direct sampler for G-Wishart variates, Stat 2, 119-128.

Examples

Run this code
G <- toeplitz( c( 0, 1, rep( 0, 3 ) ) )
		G # graph with 5 nodes and 4 links

		sample <- rgwish( n = 3, G = G, b = 3, D = diag(5) )
		sample

Run the code above in your browser using DataLab