Learn R Programming

BDgraph (version 2.19)

bdgraph: Birth-death MCMC sampling algorithm for graphical models

Description

The main function of the BDgraph package. The function consists of two sampling algorithm for model determination in undirected graphical models based on birth-death MCMC method.

Usage

bdgraph( data, n = NULL, method = "ggm", iter = 5000, burnin = iter / 2, 
         b = 3, D = NULL, Gstart = "empty" )

Arguments

data
It could be a ($n \times p$) matrix or a data.frame of data or a covariance matrix as $S=X'X$ which $X$ is the data matrix. It also could be an object of class "simulate", from function bdgraph.sim
n
The number of observations. It is needed if the "data" is a covariance matrix.
method
A character with two options "ggm" (defult) and "gcgm". Option "ggm" is for Gaussian graphical models based on Gaussianity assumption. Option "gcgm" is for Gaussian copula graphical models for the
iter
The number of iteration for the sampling algorithm.
burnin
The number of burn-in iteration for the sampling algorithm.
b
The degree of freedom for G-Wishart distribution, $W_G(b,D)$, which is a prior distribution of the precision matrix. The default is 3.
D
The positive definite matrix for G-Wishart distribution, $W_G(b,D)$. The default is an identity matrix.
Gstart
It corresponds to a starting point for graph. It can be "full" (default), "empty", or an object with S3 class "bdgraph". Option "full" means the initial graph is a full graph and "

Value

  • An object with S3 class "bdgraph" is returned:
  • sampleGraphsA vector which includes the adjacency matrices for all iterations after burn-in.
  • graphWeightsA vector which includes the waiting times for all iterations after burn-in.
  • allGraphsA vector which includes the adjacency matrices for all iterations (includes burn-in iteration). It is needed for monitoring the convergence of the BD-MCMC algorithm.
  • allWeightsA vector which includes the waiting times for all iterations (includes burn-in iteration). It is needed for monitoring the convergence of the BD-MCMC algorithm.
  • KhatEstimation for precision matrix which is a mean of all samples from precision matrices.

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 preprint arXiv:1501.05108v2 Mohammadi, A., F. Abegaz Yazew, E. van den Heuvel, and E. Wit (2015). Bayesian Modeling of Dupuytren Disease Using Gaussian Copula Graphical Models, Arxiv preprint arXiv:1501.04849v2

See Also

bdgraph.sim, summary.bdgraph, and compare

Examples

Run this code
# generating multivariate normal data from a 'random' graph
data.sim <- bdgraph.sim( n = 20, p = 6, size = 7, vis = TRUE )

output <- bdgraph( data = data.sim, iter = 1000 )

summary(output)

# To compare our result with true graph
compare( data.sim, output, colnames = c("True graph", "BDgraph") )

output2 <- bdgraph( data = data.sim, iter = 5000, Gstart = output )

compare( data.sim, output, output2, colnames = c("True graph", "Frist run", "Second run") )

# generating mixed data from a 'scale-free' graph
data.sim <- bdgraph.sim( n = 100, p = 6, type = "mixed", graph = "scale-free", vis = TRUE )

output <- bdgraph( data = data.sim, method = "gcgm", iter = 10000 )

summary( output )

compare( data.sim, output )

Run the code above in your browser using DataLab