Implements a Bayesian approach for inference on mixed graphical models. Estimates conditional independencies between variables of mixed types (continuous, discrete, categorical, zero-inflated count data) using an MCMC algorithm for posterior inference.
bmgm(
X,
type,
nburn = 1000,
nsample = 1000,
theta_priors,
v_0 = 0.05,
v_1 = 1,
pi_beta,
seed,
context_spec = TRUE,
bfdr = 0.05,
cont = FALSE,
verbose = TRUE,
...
)A numeric matrix or data frame containing the data (mixed type variables). Categorical variables (type "m") must be coded as positive integers (1, 2, ..., K), where K is the number of categories. Category 1 is used as the reference level.
A character vector indicating the type of each variable. Options: "c" (continuous), "d" (discrete), "z" (zero-inflated count), "m" (categorical).
Number of burn-in iterations for MCMC. Default is 1000.
Number of MCMC samples to collect after burn-in. Default is 1000.
List of priors for node parameters.
Prior variance for the spike in spike-and-slab. Default is 0.05.
Prior variance for the slab in spike-and-slab. Default is 1.
Prior probability of edge inclusion. Default is `2/(p-1)`.
Random seed for reproducibility.
Logical, whether to compute the context-specific adjacency matrix. Default is TRUE.
Bayesian False Discovery Rate threshold for edge selection. Default is 0.05.
Logical, whether to transform continuous variables. Default is FALSE.
Logical, whether to display a progress bar during MCMC sampling. Default is TRUE.
Additional arguments.
A list containing:
Posterior samples of the precision matrix.
Posterior samples of node parameters.
Posterior samples of edge indicators.
Estimated adjacency matrix for dependencies.
Adjacency matrix for edge selection.
Estimated transformation parameter.
# Simulated example data
set.seed(123)
n <- 100
X1 <- rpois(n, lambda = 3)
X2 <- rnorm(n, mean = 5)
X3 <- rnorm(n, mean = X2)
X4 <- rnorm(n, mean = X1)
X <- cbind(X1,X2,X3,X4)
type <- c("d", "c", "c", "c")
# \donttest{
# Fit Bayesian Mixed Graphical Model
fit <- bmgm(X, type, nburn = 1000, nsample = 2000)
# Print adjacency matrix
print(fit$adj_G)
#> [,1] [,2] [,3] [,4]
#> [1,] 0 0 1 1
#> [2,] 0 0 1 0
#> [3,] 1 1 0 0
#> [4,] 1 0 0 0
# }