BayesCOOP is an R package for supervised multimodal integration with continuous outcomes.
It provides a scalable Bayesian alternative to traditional multiview regression by:
- enforcing group-wise sparsity via a spike-and-slab Laplace prior to identify informative features and modalities, and
- quantifying predictive uncertainty through the Bayesian bootstrap.
At its core, BayesCOOP combines fast maximum a posteriori (MAP) estimation with Bayesian bootstrap–based uncertainty quantification under a jittered group spike-and-slab double exponential prior, enabling simultaneous prediction and feature selection with principled uncertainty estimates using pseudo-posteriors.
The package supports two modes:
- Full Bayesian mode (
bb = TRUE) — generates posterior draws, credible intervals, and an agreement parameter reflecting cross-view cooperation. - Fast MAP mode (
bb = FALSE) — provides cross-validated MAP estimates without full posterior sampling for improved speed.
You can install the development version directly from GitHub:
install.packages("devtools")
devtools::install_github("himelmallick/BayesCOOP")
library(BayesCOOP)Here is a minimal call to BayesCOOP():
fit <- BayesCOOP::BayesCOOP(
data_train, # list with feature_table, sample_metadata and feature_metadata (train)
family = "gaussian", # currently only continuous outcomes are supported
ss = c(0.05, 1), # spike-and-slab scales (s0, s1); controls sparsity
group = TRUE, # whether to apply group-wise shrinkage by modality
bb = TRUE, # TRUE = Bayesian bootstrap mode (default); FALSE = MAP only
alpha_dirich = 1, # Dirichlet weight parameter for the Bayesian bootstrap
bbiters = 1100, # total bootstrap iterations
bbburn = 100, # burn-in iterations discarded from the bootstrap
maxit = 100, # max EM iterations for the inner optimizer
warning = TRUE, # print convergence warnings
verbose = TRUE, # print iteration progress and timing
control = list() # (used if bb = FALSE; see below)
)When bb = TRUE (the default Bayesian mode), the returned object includes:
beta_samples: posterior predictive drawsbeta_postmed: posterior median of the coefficientsrho_samples: posterior draws of the agreement parameter across viewsrho_postmed: posterior median of the agreement parameter across viewserrVar_samples: posterior draws of the error varianceerrVar_postmed: posterior median of the error variancetime: runtime in minutesfeature_names: list of feature names in the dataset
When bb = FALSE, BayesCOOP runs fast MAP estimation instead of the Bayesian bootstrap. In that case you must pass control = list(rho = c(...)), e.g.:
fit_map <- BayesCOOP::BayesCOOP(
data_train, ss = c(0.05, 1), group = TRUE,
bb = FALSE, maxit = 100,
control = list(rho = c(0, 0.5, 1)) # candidate cross-view agreement values
)
fit_map$rho_MAP # selected agreement parameter
fit_map$beta_MAP # MAP coefficientsFor an in-depth workflow — including real data preprocessing, baseline comparisons, and performance benchmarking — please see the full tutorial:
If you use BayesCOOP in your work, please cite:
Roy, S., Sarkar, S., Paul, E., Basak, P., Yi, N., & Mallick, H. (2025).
Bayesian Cooperative Learning for Multimodal Integration. bioRxiv.
https://doi.org/10.1101/2025.10.23.684056
You can also use the standard R citation command:
citation("BayesCOOP")We are happy to troubleshoot any issues with the package. Please contact the authors via email or open an issue in the GitHub repository.