bdgraph {BDgraph} | R Documentation |
As the main function of the BDgraph package,
this function consists of several MCMC sampling algorithms for Bayesian model determination in undirected graphical models.
To speed up the computations, the birth-death MCMC sampling algorithms are implemented in parallel using OpenMP in C++
.
bdgraph( data, n = NULL, method = "ggm", algorithm = "bdmcmc", iter = 5000, burnin = iter / 2, not.cont = NULL, g.prior = 0.5, df.prior = 3, g.start = "empty", jump = NULL, save = FALSE, print = 1000, cores = NULL, threshold = 1e-8 )
data |
There are two options: (1) an (n \times p) matrix or a |
n |
The number of observations. It is needed if the |
method |
A character with two options |
algorithm |
A character with two options |
iter |
The number of iteration for the sampling algorithm. |
burnin |
The number of burn-in iteration for the sampling algorithm. |
not.cont |
For the case |
g.prior |
For determining the prior distribution of each edge in the graph. There are two options: a single value between 0 and 1 (e.g. 0.5 as a noninformative prior) or an (p \times p) matrix with elements between 0 and 1. |
df.prior |
The degree of freedom for G-Wishart distribution, W_G(b,D), which is a prior distribution of the precision matrix. |
g.start |
Corresponds to a starting point of the graph. It could be an (p \times p) matrix, |
jump |
It is only for the BDMCMC algorithm ( |
save |
Logical: if FALSE (default), the adjacency matrices are NOT saved. If TRUE, the adjacency matrices after burn-in are saved. |
print |
Value to see the number of iteration for the MCMC algorithm. |
cores |
The number of cores to use for parallel execution.
The case |
threshold |
The threshold value for the convergence of sampling algorithm from G-Wishart for the precision matrix. |
An object with S3
class "bdgraph"
is returned:
p_links |
An upper triangular matrix which corresponds the estimated posterior probabilities of all possible links. |
K_hat |
The posterior estimation of the precision matrix. |
For the case "save = TRUE" is returned:
sample_graphs |
A vector of strings which includes the adjacency matrices of visited graphs after burn-in. |
graph_weights |
A vector which includes the waiting times of visited graphs after burn-in. |
all_graphs |
A vector which includes the identity of the adjacency matrices for all iterations after burn-in. It is needed for monitoring the convergence of the BD-MCMC algorithm. |
all_weights |
A vector which includes the waiting times for all iterations after burn-in. It is needed for monitoring the convergence of the BD-MCMC algorithm. |
Reza Mohammadi a.mohammadi@uva.nl and Ernst Wit
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
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
Letac, G., Massam, H. and Mohammadi, R. (2018). The Ratio of Normalizing Constants for Bayesian Graphical Gaussian Model Selection, arXiv preprint arXiv:1706.04416v2
Dobra, A. and Mohammadi, R. (2018). Loglinear Model Selection and Human Mobility, Annals of Applied Statistics, 12(2):815-845
Mohammadi, A. and Dobra A. (2017). The R
Package BDgraph for Bayesian Structure Learning in Graphical Models, ISBA Bulletin, 24(4):11-16
bdgraph.mpl
, bdgraph.sim
, summary.bdgraph
, compare
## Not run: # --- Example 1 # Generating multivariate normal data from a 'random' graph data.sim <- bdgraph.sim( n = 20, p = 6, size = 7, vis = TRUE ) bdgraph.obj <- bdgraph( data = data.sim, iter = 1000 ) summary( bdgraph.obj ) # To compare our result with true graph compare( data.sim, bdgraph.obj, main = c( "Target", "BDgraph" ) ) # Running algorithm with starting points from previous run bdgraph.obj2 <- bdgraph( data = data.sim, g.start = bdgraph.obj ) compare( data.sim, bdgraph.obj, bdgraph.obj2, main = c( "Target", "Frist run", "Second run" ) ) # --- Example 2 # Generating mixed data from a 'scale-free' graph data.sim <- bdgraph.sim( n = 50, p = 6, type = "mixed", graph = "scale-free", vis = TRUE ) bdgraph.obj <- bdgraph( data = data.sim, method = "gcgm", iter = 10000 ) summary( bdgraph.obj ) compare( data.sim, bdgraph.obj ) ## End(Not run)