Learn R Programming

BDgraph (version 2.13)

bdgraph: Graph selection based on birth-death MCMC algorithm

Description

This function is the BD-MCMC algorithm for model selection in undirected Gaussian graphical models based on birth-death MCMC methodology.

Usage

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

Arguments

data
It could be a matrix or a data.frame of the data ( $n \times p$) or it could be a covariance matrix as $S=x'x$ which $x$ is the data matrix. It also could be an object of class "simulate".
n
The number of observations. It is needed if the "data" is a covariance matrix.
method
A character with three options "exact" (defult), "approx" and "copula" to determine a type of BD-MCMC algorithm. Option "exact" is a exact sampling from joint posterior distributions, without any approximation. Option "approx" is an approximation appro
iter
The number of iteration for the BD-MCMC algorithm.
burnin
The number of burn-in iteration for the BD-MCMC algorithm.
b
The degree of freedom for G-Wishart distribution, $W_G(b,D)$. G-Wishart distribution is the prior distribution of precision matrix. The default is 3.
D
The positive definite matrix for G-Wishart distribution, $W_G(b,D)$. G-Wishart distribution is the prior distribution of precision matrix. The default is an identity matrix.
Gstart
It is corresponding to a starting point for graph. It can be either "full" (default), "empty", or an object with S3 class "bdgraph". Option "full" means the initial graph is a full graph and "empty" means a empty graph. Gstart also could be an object

Value

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

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

See Also

bdgraph.sim

Examples

Run this code
# generating synthetic 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") )

Run the code above in your browser using DataLab