This function consists of several sampling algorithms for Bayesian structure learning in undirected graphical models for count data. It is based on Gaussian copula graphical models with discrete Weibull distributed marginals.
To speed up the computations, the birth-death MCMC sampling algorithms are implemented in parallel using OpenMP in C++
.
bdgraph.dw( data, x = NULL, formula = y ~ .,
n = NULL, algorithm = "bdmcmc", iter = 5000,
burnin = iter / 2, g.prior = 0.5, df.prior = 3,
ZI = FALSE, iter_bdw = 5000,
g.start = "empty", jump = NULL, save = FALSE,
q = NULL, beta = NULL, pii = NULL,
cores = NULL, threshold = 1e-8, verbose = TRUE )
An object with S3
class "bdgraph
" is returned, containing:
upper triangular matrix corresponding to the estimated posterior probabilities of all possible links.
posterior estimation of the precision matrix.
posterior samples of the regression coefficients of the marginal distributions.
For the case "save
= TRUE
", the code returns:
vector of strings which includes the adjacency matrices of the graphs visited after burn-in.
vector which includes the waiting times of the graphs visited after burn-in.
vector which includes the identity of the adjacency matrices for all iterations after burn-in. It is needed for monitoring the convergence of the BDMCMC algorithm.
vector which includes the waiting times for all iterations after burn-in. It is needed for monitoring the convergence of the BDMCMC algorithm.
(\(n \times p\)) matrix
or a data.frame
corresponding to the data on the p
nodes of the graph. It can also be an object of class "sim
", from the function bdgraph.sim
.
(\(n \times k\)) matrix
or a data.frame
corresponding to the predictors.
object of class formula as a symbolic description of the model for linking each node to the predictors. For the case of data.frame
, it is taken as the model frame (see model.frame)
.
number of observations. It is needed if the "data
" is a covariance matrix.
character with two options "bdmcmc
" (default) and "rjmcmc
".
Option "bdmcmc
" is based on a birth-death MCMC algorithm.
Option "rjmcmc
" is based on a reversible jump MCMC algorithm.
number of iterations for the sampling algorithm for graph learning.
number of burn-in iterations for the sampling algorithm for graph learning.
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 a (\(p \times p\)) matrix with elements between \(0\) and \(1\).
degree of freedom for G-Wishart distribution, \(W_G(b,D)\), which is a prior distribution for the precision matrix.
logical. If FALSE (default), the conditional distribution of each response variable is assumed to be Discrete Weibull given the predictors x
. If TRUE, a zero-inflated model will be applied to each response. ZI
can be passed also as a vector, in order to specify which of the (p
variables) should be fitted with zero-inflation (TRUE) or not (FALSE).
number of iterations for the sampling algorithm to estimate the regression parameters for the Discrete Weibull distribution. It is passed to the bdw.reg
function.
corresponds to a starting point of the graph. It could be an (\(p \times p\)) matrix, "empty
" (default), or "full
".
Option "empty
" means that the initial graph is an empty graph and "full
" means a full graph.
It also could be an object with S3
class "bdgraph
" of R
package BDgraph
or the class "ssgraph"
of R
package ssgraph::ssgraph()
;
this option can be used to run the sampling algorithm from the last objects of the previous run (see examples).
it is only for the BDMCMC algorithm (algorithm
= "bdmcmc
").
It is for simultaneously updating multiple links at the same time while updating the graph in the BDMCMC algorithm.
logical: if FALSE (default), the adjacency matrices are NOT saved. If TRUE, the adjacency matrices after burn-in are saved.
parameters of the discrete Weibull distribution used for the marginals. They should be given either as a (\(n \times p\)) matrix
(if covariates are present) or as a vector (if covariates are not present). If NULL (default), these parameters are estimated by the bdw.reg
function.
vector of zero-inflation parameters of the zero-inflated discrete Weibull distributions used for the marginals. If NULL (default), this parameter is estimated by the bdw.reg
function when ZI = TRUE
.
number of cores to use for parallel execution.
The case cores
= "all
" means all CPU cores to use for parallel execution.
threshold value for the convergence of the sampling algorithm from G-Wishart for the precision matrix.
logical: if TRUE (default), report/print the MCMC running time.
Reza Mohammadi a.mohammadi@uva.nl, Veronica Vinciotti, and Pariya Behrouzi
Vinciotti, V., Behrouzi, P., and Mohammadi, R. (2022) Bayesian structural learning of microbiota systems from count metagenomic data, arXiv preprint, tools:::Rd_expr_doi("10.48550/arXiv.2203.10118")
Peluso, A., Vinciotti, V., and Yu, K. (2018) Discrete Weibull generalized additive model: an application to count fertility, Journal of the Royal Statistical Society: Series C, 68(3):565-583, tools:::Rd_expr_doi("10.1111/rssc.12311")
Haselimashhadi, H., Vinciotti, V., and Yu, K. (2018) A novel Bayesian regression model for counts with an application to health data, Journal of Applied Statistics, 45(6):1085-1105, tools:::Rd_expr_doi("10.1080/02664763.2017.1342782")
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, tools:::Rd_expr_doi("10.18637/jss.v089.i03")
Mohammadi, A. and Wit, E. C. (2015). Bayesian Structure Learning in Sparse Gaussian Graphical Models, Bayesian Analysis, 10(1):109-138, tools:::Rd_expr_doi("10.1214/14-BA889")
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, tools:::Rd_expr_doi("10.1111/rssc.12171")
Mohammadi, R., Massam, H. and Letac, G. (2021). Accelerating Bayesian Structure Learning in Sparse Gaussian Graphical Models, Journal of the American Statistical Association, tools:::Rd_expr_doi("10.1080/01621459.2021.1996377")
bdgraph
, bdgraph.mpl, bdw.reg, bdgraph.sim
, summary.bdgraph
, compare
if (FALSE) {
# - - Example 1
# Generating multivariate Discrete Weibull data based on 'random' graph
data.sim <- bdgraph.sim( n = 100, p = 10, type = "dw", vis = TRUE )
bdgraph.obj <- bdgraph.dw( data = data.sim, iter = 5000 )
summary( bdgraph.obj )
# To compare the result with true graph
compare( data.sim, bdgraph.obj, main = c( "Target", "BDgraph" ), vis = TRUE )
# - - Example 2
# Generating multivariate Discrete Weibull data based on a 'scale-free' graph
data.sim <- bdgraph.sim( n = 100, p = 10, type = "dw", graph = "scale-free", vis = TRUE )
bdgraph.obj <- bdgraph.dw( data = data.sim, iter = 10000 )
summary( bdgraph.obj )
compare( data.sim, bdgraph.obj, main = c( "Target", "BDgraph" ), vis = TRUE )
}
Run the code above in your browser using DataLab