rgwish {BDgraph}R Documentation

Sampling from G-Wishart distribution

Description

Generates random matrices, distributed according to the G-Wishart distribution with parameters bb and DD, WG(b,D)W_G(b, D) with respect to the graph structure GG. Note this fuction works for both non-decomposable and decomposable graphs.

Usage

 rgwish( n = 1, adj = NULL, b = 3, D = NULL, threshold = 1e-8 ) 

Arguments

n

number of samples required.

adj

adjacency matrix corresponding to the graph structure which can be non-decomposable or decomposable. It should be an upper triangular matrix in which aij=1a_{ij}=1 if there is a link between notes ii and jj, otherwise aij=0a_{ij}=0. adj could be an object of class "graph", from function graph.sim. It also could be an object of class "sim", from function bdgraph.sim. It also could be an object of class "bdgraph", from functions bdgraph.mpl or bdgraph.

b

degree of freedom for G-Wishart distribution, WG(b,D)W_G(b, D).

D

positive definite (p×p)(p \times p) "scale" matrix for G-Wishart distribution, WG(b,D)W_G(b, D). The default is an identity matrix.

threshold

threshold value for the convergence of sampling algorithm from G-Wishart.

Details

Sampling from G-Wishart distribution, KWG(b,D)K \sim W_G(b, D), with density:

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

which b>2b > 2 is the degree of freedom and DD is a symmetric positive definite matrix.

Value

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

Author(s)

Reza Mohammadi a.mohammadi@uva.nl

References

Lenkoski, A. (2013). A direct sampler for G-Wishart variates, Stat, 2:119-128, doi:10.1002/sta4.23

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, doi:10.18637/jss.v089.i03

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

See Also

gnorm, rwish

Examples

# Generating a 'circle' graph as a non-decomposable graph
adj <- graph.sim( p = 5, graph = "circle" )
adj    # adjacency of graph with 5 nodes
  
sample <- rgwish( n = 1, adj = adj, b = 3, D = diag( 5 ) )
round( sample, 2 ) 

sample <- rgwish( n = 5, adj = adj )
round( sample, 2 )  

[Package BDgraph version 2.72 Index]