Learn R Programming

BDgraph (version 2.3)

prob.g: Posterior probability for a specific graph

Description

According to the output of the BDMCMC algorithm, this function gives us the posterior probability for a specific graph.

Usage

prob.g(A, output)

Arguments

A
upper triangular matrix in which $a_{ij}=1$ if there is a link between notes $i$ and $j$, otherwise $a_{ij}=0$.
output
a list which is the result of BDMCMC algorithm from the 'bdmcmc', 'bdmcmc.low', or 'bdmcmc.high' functions.

References

Mohammadi, A. and E. C. Wit (2012). Gaussian graphical model determination based on birth-death MCMC inference, arXiv:1210.5371v4. http://arxiv.org/abs/1210.5371v4

See Also

bdmcmc

Examples

Run this code
p <- 8 # number of nodes 
  # "truK" is the precision matrix of true graph
  truK <- diag(p)
  for (i in 1:(p-1)) truK[i,i+1] <- truK[i+1,i] <- 0.5
  truK[1,p] <- truK[p,1] <- 0.4
  truK # precision matrix of the true graph
  
  # generate the data (200 observations) from multivariate normal 
  # distribution with mean zero and percision matrix "truK"
  data <- mvrnorm(200, c(rep(0,p)), solve(truK))  
  output <- bdmcmc(data, meanzero = T, iter = 2000)
  
  A <- ceiling (truK)
  A[lower.tri(A, diag = T)] <- 0
  A # matrix A shows circle graph with 8 links and 8 nodes which is the true graphical model
  
  prob.g(A, output)

Run the code above in your browser using DataLab