bama is a Bayesian inference method that uses continuous shrinkage priors
for high-dimensional Bayesian mediation analysis, developed by Song et al
(2019, 2020). bama provides estimates for the regression coefficients as
well as the posterior inclusion probability for ranking mediators.
bama(
Y,
A,
M,
C1,
C2,
method,
burnin,
ndraws,
weights = NULL,
inits = NULL,
control = list(k = 2, lm0 = 1e-04, lm1 = 1, lma1 = 1, l = 1, lambda0 = 0.04, lambda1 =
0.2, lambda2 = 0.2, phi0 = 0.01, phi1 = 0.01, a0 = 0.01 * ncol(M), a1 = 0.05 *
ncol(M), a2 = 0.05 * ncol(M), a3 = 0.89 * ncol(M)),
seed = NULL
)If method = "BSLMM", then bama returns a object of type "bama" with 12 elements:
ndraws x p matrix containing outcome model mediator
coefficients.
ndraws x p matrix indicating whether or not each beta.m
belongs to the larger normal component (1) or smaller normal
component (0).
ndraws x p matrix containing the mediator model
exposure coefficients.
ndraws x p matrix indicating whether or not each alpha.a
belongs to the larger normal component (1) or smaller normal component (0).
Vector of length ndraws containing the beta.a coefficient.
Vector of length ndraws containing the proportion of
non zero beta.m coefficients.
Vector of length ndraws containing the proportion of
non zero alpha.a coefficients.
Vector of length ndraws containing the standard
deviation of the smaller normal component for mediator-outcome
coefficients (beta.m).
Vector of length ndraws containing standard deviation
of the larger normal component for mediator-outcome coefficients (beta.m).
Vector of length ndraws containing standard
deviation of the smaller normal component for exposure-mediator
coefficients (alpha.a).
Vector of length ndraws containing standard deviation
of the larger normal component for exposure-mediator coefficients
(alpha.a).
The R call that generated the output.
NOTE: GMM not currently supported. Instead, use method = 'PTG'
If method = "GMM", then bama returns a object of type "bama" with:
ndraws x p matrix containing outcome model mediator
coefficients.
ndraws x p matrix containing the mediator model
exposure coefficients.
ndraws x p matrix of 1's and 0's where
item = 1 only if beta.m is non-zero.
ndraws x p matrix of 1's and 0's where
item = 1 only if alpha.a is non-zero.
ndraws x (q2 + p) matrix containing alpha_c coefficients.
Since alpha.c is a matrix of dimension q2 x p, the draws are indexed as
alpha_c(w, j) = w * p + j
ndraws x q1 matrix containing beta_c coefficients.
Since beta.c is a matrix of dimension q1 x p
Vector of length ndraws containing the beta.a coefficient.
Vector of length ndraws variance of beta.a effect
Vector of length ndraws variance of outcome model error
Vector of length ndraws variance of mediator model error
If method = "PTG", then bama returns a object of type "bama" with:
ndraws x p matrix containing outcome model mediator
coefficients.
ndraws x p matrix containing the mediator model
exposure coefficients.
ndraws x (q2 + p) matrix containing alpha_c coefficients.
Since alpha.c is a matrix of dimension q2 x p, the draws are indexed as
alpha_c(w, j) = w * p + j
ndraws x q1 matrix containing beta_c coefficients.
Since beta.c is a matrix of dimension q1 x p
ndraws x p matrix of 1's and 0's where
item = 1 only if beta.m is non-zero.
ndraws x p matrix of 1's and 0's where
item = 1 only if alpha.a is non-zero.
Vector of length ndraws containing the beta.a coefficient.
Vector of length ndraws variance of beta.a effect
Vector of length ndraws variance of outcome model error
Vector of length ndraws variance of mediator model error
Length n numeric outcome vector
Length n numeric exposure vector
n x p numeric matrix of mediators of Y and A
n x nc1 numeric matrix of extra covariates to include in the
outcome model
n x nc2 numeric matrix of extra covariates to include in the
mediator model
String indicating which method to use. Options are
- mixture of two normal components; Song et al. 2019
- product threshold Gaussian prior; Song et al. 2020
- NOTE: GMM not currently supported. Instead, use method = 'PTG'. four-component Gaussian mixture prior; Song et al. 2020
number of iterations to run the MCMC before sampling
number of draws to take from MCMC (includes burnin draws)
Length n numeric vector of weights
list of initial values for the Gibbs sampler. Options are
- Length p numeric vector of initial beta.m in the
outcome model. See details for equation
- Length p numeric vector of initial alpha.a in
the mediator model. See details for equation
list of Gibbs algorithm control options. These include prior
and hyper-prior parameters. Options vary by method selection. If
method = "BSLMM"
- Shape parameter prior for inverse gamma
- Scale parameter prior for inverse gamma for the small normal components
- Scale parameter prior for inverse gamma for the large normal components of beta_m
- Scale parameter prior for inverse gamma for the large normal component of alpha_a
- Scale parameter prior for the other inverse gamma distributions
If method = "PTG"
- threshold parameter for product of alpha.a and beta.m effect
- threshold parameter for beta.m effect
- threshold parameter for alpha.a effect
- inverse gamma shape prior for sigma.sq.a
- inverse gamma scale prior for sigma.sq.a
- inverse gamma shape prior for sigma.sq.e
- inverse gamma scale prior for sigma.sq.e
- inverse gamma shape prior for sigma.sq.g
- inverse gamma scale prior for sigma.sq.g
- inverse gamma shape prior for tau.sq.b
- inverse gamma scale prior for tau.sq.b
- inverse gamma shape prior for tau.sq.a
- inverse gamma scale prior for tau.sq.a
If method = "GMM". NOTE: GMM not currently supported. Instead, use method = 'PTG'.
- prior beta.m variance
- prior alpha.a variance
- prior count of non-zero beta.m and alpha.a effects
- prior count of non-zero beta.m and zero alpha.a effects
- prior count of zero beta.m and non-zero alpha.a effects
- prior count of zero beta.m and zero alpha.a effects
- inverse gamma shape prior for sigma.sq.a
- inverse gamma scale prior for sigma.sq.a
- inverse gamma shape prior for sigma.sq.e
- inverse gamma scale prior for sigma.sq.e
- inverse gamma shape prior for sigma.sq.g
- inverse gamma scale prior for sigma.sq.g
numeric seed for GIBBS sampler
bama uses two regression models for the two conditional relationships,
\(Y | A, M, C\) and \(M | A, C\). For the outcome model, bama
uses
$$Y = M \beta_M + A * \beta_A + C* \beta_C + \epsilon_Y$$
For the mediator model, bama uses the model
$$M = A * \alpha_A + C * \alpha_C + \epsilon_M$$
For high dimensional tractability, bama employs continuous Bayesian
shrinkage priors to select mediators and makes the two following assumptions:
First, it assumes that all the potential mediators contribute small effects
in mediating the exposure-outcome relationship. Second, it assumes
that only a small proportion of mediators exhibit large effects
("active" mediators). bama uses a Metropolis-Hastings within Gibbs
MCMC to generate posterior samples from the model.
NOTE: GMM not currently supported. Instead, use method = 'PTG'.
Song, Y, Zhou, X, Zhang, M, et al. Bayesian shrinkage estimation of high dimensional causal mediation effects in omics studies. Biometrics. 2019; 1-11. tools:::Rd_expr_doi("10.1111/biom.13189")
Song, Yanyi, Xiang Zhou, Jian Kang, Max T. Aung, Min Zhang, Wei Zhao, Belinda L. Needham et al. "Bayesian Sparse Mediation Analysis with Targeted Penalization of Natural Indirect Effects." arXiv preprint arXiv:2008.06366 (2020).
library(bama)
Y <- bama.data$y
A <- bama.data$a
# grab the mediators from the example data.frame
M <- as.matrix(bama.data[, paste0("m", 1:100)], nrow(bama.data))
# We just include the intercept term in this example as we have no covariates
C1 <- matrix(1, 1000, 1)
C2 <- matrix(1, 1000, 1)
beta.m <- rep(0, 100)
alpha.a <- rep(0, 100)
out <- bama(Y = Y, A = A, M = M, C1 = C1, C2 = C2, method = "BSLMM", seed = 1234,
burnin = 100, ndraws = 110, weights = NULL, inits = NULL,
control = list(k = 2, lm0 = 1e-04, lm1 = 1, lma1 = 1, l = 1))
# The package includes a function to summarise output from 'bama'
summary <- summary(out)
head(summary)
# \donttest{
# Product Threshold Gaussian
ptgmod = bama(Y = Y, A = A, M = M, C1 = C1, C2 = C2, method = "PTG", seed = 1234,
burnin = 100, ndraws = 110, weights = NULL, inits = NULL,
control = list(lambda0 = 0.04, lambda1 = 0.2, lambda2 = 0.2))
mean(ptgmod$beta.a)
apply(ptgmod$beta.m, 2, mean)
apply(ptgmod$alpha.a, 2, mean)
apply(ptgmod$betam_member, 2, mean)
apply(ptgmod$alphaa_member, 2, mean)
# }
Run the code above in your browser using DataLab