Fits the Bayesian covariate-varying factor model of Zhang, Patnode and Lee by MCMC. The model jointly estimates a covariate-dependent mean abundance and a covariate-dependent covariance (interaction) structure for high-dimensional multivariate count data, using a rounded multivariate log-normal kernel, a sparse covariate-dependent factor loading matrix with a Dirichlet-Horseshoe prior, and mean-constrained Dirichlet process mixtures for the size factor and baseline abundance.
Usage
bcaia(
Y,
Xmean,
Xcov,
subject = NULL,
K = 8,
niter = 160000,
burnin = NULL,
thin = 10,
seed = NULL,
control = bcaia_control(),
verbose = TRUE,
keep_all = FALSE
)Arguments
- Y
An
n x Jmatrix of non-negative integer counts (samples in rows, features/OTUs in columns).- Xmean
An
n x Pmeandesign matrix for the mean regression excluding the intercept (the intercept is absorbed into the size factor / baseline abundance).- Xcov
An
n x Pcovdesign matrix for the covariance regression, including an intercept column (typically the first column of ones).- subject
Optional length-
nvector (factor, integer or character) giving the subject each sample belongs to. When supplied, the subject-indexed model is fitted; whenNULL, the simple model is fitted.- K
Number of latent factors (the working dimension of the loading matrix). Choose a value large enough to capture the covariance; redundant factors are shrunk out by the prior. See
choose_K.- niter
Total number of MCMC iterations. Default
160000.- burnin
Number of burn-in iterations discarded before saving. Default
niter/2.- thin
Thinning interval for saved samples. Default
10.- seed
Optional integer seed for reproducible initialisation.
- control
A
bcaia_controllist of hyperparameters and tuning constants.- verbose
Logical; print progress. Default
TRUE.- keep_all
Logical; if
TRUE, the returnedsamplesalso contain the full posterior draws of every model parameter – the latent factorseta, the Dirichlet-Horseshoe parametersphiandzeta, and the Dirichlet-process internals (omega,psi,xi) and membership indicators for the size factor and baseline abundance – in addition toF,Q,tau,beta,ri,alpha/alphasijandsig2. This can be large; defaultFALSEkeeps only the lighter set.
Value
An object of class "bcaia": a list with element samples
(posterior draws of F, Q, tau, beta, ri,
alpha / alphasij, sig2), together with runtime,
data (dimensions and the design matrices), control, and the
model variant used. Use posterior_Sigma and
posterior_cor to summarise covariate-varying covariance and
correlation.
Details
Two model variants are available and selected automatically through the
subject argument:
Simple model (
subject = NULL): one baseline abundance \(\alpha_j\) per feature. This matches Simulation 1 and the mice data analysis in the paper.Subject-indexed model (
subjectsupplied): a subject-specific baseline abundance \(\alpha_{s,j}\) to accommodate repeated samples and large inter-subject variability. This matches Simulations 2 and 3.
References
Zhang, S., Patnode, M. L. and Lee, J. Bayesian Covariate-Varying Interaction Analysis for Multivariate Count Data: Application to Microbiome Studies.