Learn R Programming

BDgraph (version 2.23)

bdgraph: Search algorithm in graphical models

Description

As the main function of the BDgraph package, this function consists of several sampling algorithms for Bayesian model determination in undirected graphical models.

Usage

bdgraph( data, n = NULL, method = "ggm", algorithm = "bdmcmc", iter = 5000, 
		         burnin = iter / 2, b = 3, Gstart = "empty", save.all = FALSE )

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 "sim", from function bdgrap
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
algorithm
A character with two options "bdmcmc" (defult) and "rjmcmc". Option "bdmcmc" is based on birth-death MCMC algorithm. Option "rjmcmc" is based on reverible jump MCMC algorithm.
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.
Gstart
Corresponds to a starting point of the 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 "
save.all
Logical: if FALSE (default), the adjacency matrices are NOT saved. If TRUE, the adjacency matrices after burn-in are saved.

Value

  • An object with S3 class "bdgraph" is returned:
  • phatUpper triangular matrix which corresponds the estimated posterior probabilities of all possible links.
  • KhatPosterior estimation of the precision matrix.
  • sampleGraphsA vector of strings which includes the adjacency matrices of visited graphs after burn-in.
  • graphWeightsA vector which includes the waiting times of visited graphs after burn-in.
  • allGraphsA 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.
  • allWeightsA vector which includes the waiting times for all iterations after burn-in. It is needed for monitoring the convergence of the BD-MCMC algorithm.

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

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") )
   
# Running algorithm with starting points from previous run
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 = 50, 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