Description Usage Arguments Details Value Author(s) References See Also Examples

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

1 |

`n` |
The number of samples required. |

`adj` |
The adjacency matrix corresponding to the graph structure which can be non-decomposable or decomposable. It should be an upper triangular matrix in which |

`b` |
The degree of freedom for G-Wishart distribution, |

`D` |
The positive definite |

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

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

*Pr(K) \propto |K| ^ {(b - 2) / 2} \exp ≤ft\{- \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.

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)*.
Note, for the case *n=1*, the output is a matrix.

Reza Mohammadi a.mohammadi@uva.nl

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

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

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, A. et al (2017). Bayesian modelling of Dupuytren disease by using Gaussian copula graphical models, *Journal of the Royal Statistical Society: Series C*, 66(3):629-645

1 2 3 4 5 6 7 8 9 |

```
[,1] [,2] [,3] [,4] [,5]
[1,] 0 1 0 0 1
[2,] 1 0 1 0 0
[3,] 0 1 0 1 0
[4,] 0 0 1 0 1
[5,] 1 0 0 1 0
attr(,"class")
[1] "graph"
[,1] [,2] [,3] [,4] [,5]
[1,] 0.59 0.06 0.00 0.00 -0.04
[2,] 0.06 1.68 -0.21 0.00 0.00
[3,] 0.00 -0.21 2.64 -2.70 0.00
[4,] 0.00 0.00 -2.70 3.49 0.48
[5,] -0.04 0.00 0.00 0.48 7.42
, , 1
[,1] [,2] [,3] [,4] [,5]
[1,] 8.26 2.63 0.00 0.00 0.58
[2,] 2.63 8.92 1.27 0.00 0.00
[3,] 0.00 1.27 3.17 0.62 0.00
[4,] 0.00 0.00 0.62 1.80 1.86
[5,] 0.58 0.00 0.00 1.86 2.65
, , 2
[,1] [,2] [,3] [,4] [,5]
[1,] 3.78 1.85 0.00 0.00 3.11
[2,] 1.85 3.14 -0.46 0.00 0.00
[3,] 0.00 -0.46 5.63 1.63 0.00
[4,] 0.00 0.00 1.63 5.35 2.41
[5,] 3.11 0.00 0.00 2.41 8.05
, , 3
[,1] [,2] [,3] [,4] [,5]
[1,] 1.64 -0.82 0.00 0.00 -0.62
[2,] -0.82 3.02 1.04 0.00 0.00
[3,] 0.00 1.04 4.55 0.07 0.00
[4,] 0.00 0.00 0.07 3.97 -1.31
[5,] -0.62 0.00 0.00 -1.31 1.08
, , 4
[,1] [,2] [,3] [,4] [,5]
[1,] 19.21 2.16 0.00 0.00 2.21
[2,] 2.16 1.75 2.27 0.00 0.00
[3,] 0.00 2.27 6.17 -3.45 0.00
[4,] 0.00 0.00 -3.45 8.40 1.92
[5,] 2.21 0.00 0.00 1.92 2.40
, , 5
[,1] [,2] [,3] [,4] [,5]
[1,] 8.26 0.81 0.00 0.00 3.15
[2,] 0.81 2.86 -2.05 0.00 0.00
[3,] 0.00 -2.05 9.55 3.22 0.00
[4,] 0.00 0.00 3.22 15.38 3.22
[5,] 3.15 0.00 0.00 3.22 5.75
```

Embedding an R snippet on your website

Add the following code to your website.

For more information on customizing the embed code, read Embedding Snippets.