Title: | Bayesian Mediation Analysis with High-Dimensional Data |
---|---|
Description: | Mediation analysis is used to identify and quantify intermediate effects from factors that intervene the observed relationship between an exposure/predicting variable and an outcome. We use a Bayesian adaptive lasso method to take care of the hierarchical structures and high dimensional exposures or mediators. |
Authors: | Qingzhao Yu [aut, cre, cph], Bin Li [aut] |
Maintainer: | Qingzhao Yu <[email protected]> |
License: | GPL (>= 2) |
Version: | 1.0 |
Built: | 2024-11-10 06:28:18 UTC |
Source: | CRAN |
Mediation analysis is used to identify and quantify intermediate effects from factors that intervene the observed relationship between an exposure/predicting variable and an outcome. We use a Bayesian adaptive lasso method to take care of the hierarchical structures and high dimensional exposures or mediators.
The DESCRIPTION file:
Package: | hdbma |
Type: | Package |
Title: | Bayesian Mediation Analysis with High-Dimensional Data |
Version: | 1.0 |
Date: | 2023-12-16 |
Authors@R: | c(person("Qingzhao Yu", role = c("aut", "cre","cph"), email = "[email protected]"), person("Bin Li", role = "aut") ) |
Maintainer: | Qingzhao Yu <[email protected]> |
Depends: | R (>= 2.14.1), R2jags,gplots,MASS,survival,splines |
Imports: | lattice, methods |
Encoding: | UTF-8 |
Description: | Mediation analysis is used to identify and quantify intermediate effects from factors that intervene the observed relationship between an exposure/predicting variable and an outcome. We use a Bayesian adaptive lasso method to take care of the hierarchical structures and high dimensional exposures or mediators. |
License: | GPL (>= 2) |
URL: | https://www.r-project.org, https://publichealth.lsuhsc.edu/Faculty_pages/qyu/index.html |
RoxygenNote: | 7.2.3 |
NeedsCompilation: | no |
Packaged: | 2023-12-15 01:53:30 UTC; qyu |
Author: | Qingzhao Yu [aut, cre, cph], Bin Li [aut] |
Repository: | CRAN |
Date/Publication: | 2023-12-15 12:30:02 UTC |
Config/pak/sysreqs: | jags libicu-dev |
Index of help topics:
hdbma High-Dimensional Bayesian Mediation Analysis hdbma-package Bayesian Mediation Analysis with High-Dimensional Data print.summary.hdbma Print summary.hdbma Summary for hdbma results weight_behavior Weight_Behavior Data Set
The main function is hdbma to perform the Bayesian mediation anlysis with adaptive Laplace priors.
Qingzhao Yu [aut, cre, cph], Bin Li [aut]
Maintainer: Qingzhao Yu <[email protected]>
Yu, Q., Hagan, J., Wu, X., Richmond-Bryant, J., and Li, B., 2023, High-Dimensional Bayesian Mediation Analysis with Adaptive Laplace Priors. Submitted.
#See examples at summary.hdbma.
#See examples at summary.hdbma.
We use the adaptive lasso priors for the Bayesian mediation analysis. Significant exposure variables, mediators are identified and their effects infered.
hdbma(pred, m, y, refy = rep(NA, ncol(data.frame(y))), predref = rep(NA, ncol(data.frame(pred))), fpy = NULL, deltap = rep(0.001, ncol(data.frame(pred))), fmy = NULL, deltam = rep(0.001, ncol(data.frame(m))), fpm = NULL, mref = rep(NA, ncol(data.frame(m))), cova = NULL, mcov = NULL, mclist = NULL, inits = NULL, n.chains = 1, n.iter = 1100, n.burnin = 100, n.thin = 1, mucv = NULL, Omegacv = NULL, mu0.1 = NULL, Omega0.1 = NULL, mu1.1 = NULL, Omega1.1 = NULL, mu0.a = NULL, Omega0.a = NULL, mu1.a = NULL, Omega1.a = NULL, mu0.b = NULL, Omega0.b = NULL, mu1.b = NULL, Omega1.b = NULL, mu0.c = NULL, Omega0.c = NULL, mu1.c = NULL, Omega1.c = NULL, preci = 1e-06, tmax = Inf, multi = NULL, filename = NULL, deltax = 1, r1 = 1, partial = FALSE)
hdbma(pred, m, y, refy = rep(NA, ncol(data.frame(y))), predref = rep(NA, ncol(data.frame(pred))), fpy = NULL, deltap = rep(0.001, ncol(data.frame(pred))), fmy = NULL, deltam = rep(0.001, ncol(data.frame(m))), fpm = NULL, mref = rep(NA, ncol(data.frame(m))), cova = NULL, mcov = NULL, mclist = NULL, inits = NULL, n.chains = 1, n.iter = 1100, n.burnin = 100, n.thin = 1, mucv = NULL, Omegacv = NULL, mu0.1 = NULL, Omega0.1 = NULL, mu1.1 = NULL, Omega1.1 = NULL, mu0.a = NULL, Omega0.a = NULL, mu1.a = NULL, Omega1.a = NULL, mu0.b = NULL, Omega0.b = NULL, mu1.b = NULL, Omega1.b = NULL, mu0.c = NULL, Omega0.c = NULL, mu1.c = NULL, Omega1.c = NULL, preci = 1e-06, tmax = Inf, multi = NULL, filename = NULL, deltax = 1, r1 = 1, partial = FALSE)
pred |
the vector/matrix of exposure(s)/predictor(s). |
m |
a data frame contains all potential mediators and covariates. |
y |
the vector/matrix of outcome(s). |
refy |
the reference group of y if the outcome is categorical. |
predref |
the reference group of pred if the exposure/predictor is categorical. |
fpy |
the transformation function of predictor(s) (pred) to explain y. [[1]] list all continuous predictors to be transformed, then following items list the transformation functions for each predictor in list [[1]] in that order. |
deltap |
the vector of changing amount in predictors. |
fmy |
the transformation functions of mediators (m) to explain y, [[1]] list all continuous mediators in m to be transformed, then following items list the transformation functions for each mediator in list [[1]] in that order. |
deltam |
the vector of changing amount in mediators. |
fpm |
the transformation functions of predictors (pred) to explain mediators (m), [[1]] is a matrix, the first column indicator the mediators to be explained, the second column are the continuous predictors to be transformed; then transformation functions are listed in the following items by the row order of [[1]]. |
mref |
the reference group of m if any of them is categorical. By default, the reference group is the first one in alphebetic order. |
cova |
the covariates for the outcome. |
mcov |
the data frame with all covariates for mediators |
mclist |
the list of all covariates for mediators. If mclist is NULL but mcov is not, use all covariates in mcov for all mediators. Otherwise the first item of mclist lists all mediators that are using different covariates, the following items give the columns of covariates in mcov for the mediators in order of mclist[[1]]. Use NA is no covariates are to be used. If a mediator is not listed in mclist[[1]], use all covariates in mcov. |
inits |
to specify the starting values of parameters. Default is NULL. See R2jags:jags. |
n.chains |
number of Markov chains (default: 1). See R2jags:jags. |
n.iter |
number of total iterations per chain (including burn in; default: 1100). See R2jags:jags. |
n.burnin |
length of burn in, i.e. number of iterations to discard at the beginning. Default is 100. If n.burnin is 0, jags() will run 100 iterations for adaption. See R2jags:jags. |
n.thin |
thinning rate. Must be a positive integer. Default is 1. See R2jags:jags. |
mucv |
the prior mean for the variables in cova. Default is 0. |
Omegacv |
the prior precision for the variables in cova. Default is 0 preci. |
mu0.1 |
the prior mean for the intercept in the prediction model for all mediators. Default is 0. |
Omega0.1 |
the prior precision for the intercept in the prediction model for all mediators. Default is preci. |
mu1.1 |
a vector of the size of meditators include the prior mean for the slope of the exposures in the prediction model for all mediators. Default is rep(0,P). |
Omega1.1 |
the prior precision matrix (P*P) for the slope of the exposures in the prediction model for all mediators. Default is a diagoal matrix with preci. |
mu0.a |
the prior mean for the intercept in the prediction model for all continuous mediators. Default is rep(0,p1), p1 is the number of continuous mediators. |
Omega0.a |
the prior precision for the intercept in the prediction model for all continuous mediators. Default is diag(preci). |
mu1.a |
the prior mean for the slope of the exposures in the prediction model for all continuous mediators. Default is rep(0,p1), p1 is the number of continuous mediators. |
Omega1.a |
the prior precision for the slope of the exposures in the prediction model for all continuous mediators. Default is diag(preci). |
mu0.b |
the prior mean for the intercept in the prediction logit model for all binary mediators. Default is rep(0,p2), p2 is the number of bianry mediators. |
Omega0.b |
the prior precision matrix for the intercept in the prediction logit model for all binary mediators. Default is diag(preci). |
mu1.b |
the prior mean for the slope of exposure(s) in the prediction logit model for all binary mediators. Default is rep(0,p2). |
Omega1.b |
the prior precision matrix for the slope of exposure(s) in the prediction logit model for all binary mediators. Default is diag(preci). |
mu0.c |
the prior mean for the intercept in the prediction logit model for all categorical mediators. Default is 0 for all (array(0,p3,cat1,nmc), where p3 is the number of categorical mediators, cat1 is the maximum number of categories of all categorical mediators, and nmc is the number of mcov. |
Omega0.c |
the prior precision matrix for intercept in the prediction logit model for all categorical mediators. Default is preci at the diagnal matrix of nmc*nmc dimension. |
mu1.c |
the prior mean for the slope of exposures in the prediction logit model for all categorical mediators. Default is 0 for all (array(0,p3,cat1,c1), where p3 is the number of categorical mediators, cat1 is the maximum number of categories of all categorical mediators, and c1 is the number of exposures. |
Omega1.c |
the prior precision matrix for the slope of exposures in the prediction logit model for all categorical mediators. Default is preci at the diagnal matrix of c1*c1 dimension. |
preci |
the prior precision level. Default is 0.000001. |
tmax |
the maximum time to event for survival analysis. Default is Inf. |
multi |
in the survival analysis only. If true, calculate the multiplicative effect of survival time. |
filename |
the directory and filename for the bugs model. If is NULL, the function will generate the bugs model using default functions. |
deltax |
the change unit in the exposures to calculate the mediation effects. Default is 1. |
r1 |
the penalty parameter is
. Default is 1. |
partial |
if true, do the partial lasso,
Default is FALSE. |
The function will automatically catch the types of the outcome and compile the bugs model. Results will be summarized use the summary function. Please see examples under summary.
A hdbma object is returned with the following items. Results are summarized using the summary.hdbma function.
aie1 , ade1 , ate1 , ... , ate4
|
the average indirect effect (ie), direct effect (de) and total effect (te) from the four different methods. See the references. |
sims.list |
the simulation results from the bugs model. |
data0 |
the organized data set that was analyzed. |
omu3 , omu4
|
the total effects from method 3 or 4 for survival outcome only. |
Qingzhao Yu and Bin Li
Yu, Q., Hagan, J., Wu, X., Richmond-Bryant, J., and Li, B., 2023, High-Dimensional Bayesian Mediation Analysis with Adaptive Laplace Priors. Submitted.
#Check summary.hdbma.
#Check summary.hdbma.
print the results from summary.hdbma.
## S3 method for class 'summary.hdbma' print(x, ..., digit = x$digit, method = x$method, RE = x$RE)
## S3 method for class 'summary.hdbma' print(x, ..., digit = x$digit, method = x$method, RE = x$RE)
x |
the results from summary.hdbma. |
... |
further arguments passed to or from other methods. |
digit |
the number of digit to be shown. |
method |
the method to be shown. See the reference. |
RE |
if true, present results for relative effects. Default is True. |
No return value, called for to print results and plots.
Qingzhao Yu and Bin Li
Yu, Q., Hagan, J., Wu, X., Richmond-Bryant, J., and Li, B., 2023, High-Dimensional Bayesian Mediation Analysis with Adaptive Laplace Priors. Submitted.
#Examples at summary.hdbma.
#Examples at summary.hdbma.
This function summarize the results from hdbma objects with estimations, standard errors, and confidence intervals.
## S3 method for class 'hdbma' summary(object, ..., plot = TRUE, RE = TRUE, quant = c(0.025, 0.25, 0.5, 0.75, 0.975), digit = 4, method = 1)
## S3 method for class 'hdbma' summary(object, ..., plot = TRUE, RE = TRUE, quant = c(0.025, 0.25, 0.5, 0.75, 0.975), digit = 4, method = 1)
object |
the hdbma object from the hdbma function. |
... |
further arguments passed to or from other methods. |
plot |
if true, plot the estimation summaries. Default is True. |
RE |
if true, present results for relative effects. Default is True. |
quant |
the set of quantiles to be shown in the sumamry results. Default is c(0.025, 0.25, 0.5, 0.75, 0.975). |
digit |
the number of digit to be shown. |
method |
the method to be shown. See the reference. |
result1 , ... , result4
|
the inference results for estimated mediation effects from methods 1 to 4. |
result1.re , ... , result4.re
|
the inference results for estimated relative effects from methods 1 to 4. |
Qingzhao Yu and Bin Li
Yu, Q., Hagan, J., Wu, X., Richmond-Bryant, J., and Li, B., 2023, High-Dimensional Bayesian Mediation Analysis with Adaptive Laplace Priors. Submitted.
data("weight_behavior") #for all the examples, needs to remove or increase n.iter and n.burnin #binary predictor test.b.c<- hdbma(pred=weight_behavior[,3], m=weight_behavior[,c(4,14,12,13)], y=weight_behavior[,1],n.iter=10,n.burnin = 1) summary(test.b.c) ##use covariate for y test.b.c.2<- hdbma(pred=weight_behavior[,3], m=weight_behavior[,12:14], y=weight_behavior[,1],cova=weight_behavior[,2],n.iter=10,n.burnin = 1) summary(test.b.c.2) #categorical predictor test.ca.c<- hdbma(pred=weight_behavior[,4], m=weight_behavior[,12:14], y=weight_behavior[,1],n.iter=10,n.burnin = 1) summary(test.ca.c) #use covariate for mediators test.b.c.3<- hdbma(pred=weight_behavior[,3], m=weight_behavior[,c(9,12:14)], y=weight_behavior[,1],mcov=weight_behavior[,c(2,5)], mclist = list(1,2),n.iter=10,n.burnin = 1) summary(test.b.c.3) #use continuous predictor test.c.c<- hdbma(pred=weight_behavior[,2], m=weight_behavior[,12:14], y=weight_behavior[,1],n.iter=10,n.burnin = 1) summary(test.c.c,method=3) #use transfered continuous predictor test.c.c.2<- hdbma(pred=weight_behavior[,2], m=weight_behavior[,12:14], y=weight_behavior[,1],fpy=list(1,c("x","x^2")), n.iter=10,n.burnin = 1) summary(test.c.c.2,method=1) #multiple predictors test.m.c<- hdbma(pred=weight_behavior[,2:4], m=weight_behavior[,12:14], y=weight_behavior[,1],n.iter=10,n.burnin = 1) summary(test.m.c,RE=FALSE) ##binary outcome test.m.b<- hdbma(pred=weight_behavior[,2:4], m=weight_behavior[,12:14], y=weight_behavior[,15],cova=weight_behavior[,5], n.iter=10,n.burnin = 1) summary(test.m.b,method=2) ##categorical outcome weight_behavior[,14]=as.factor(weight_behavior[,14]) test.m.c<- hdbma(pred=weight_behavior[,2:4], m=weight_behavior[,12:13], y=weight_behavior[,14],cova=weight_behavior[,5], n.iter=10,n.burnin = 1) summary(test.m.c,method=2) summary(test.m.c,method=1) ##time-to-event outcome ##Surv class outcome (survival analysis) #use a simulation set.seed(1) N=100 alpha=0.5 x=rnorm(N,0,1) x=ifelse(x>0,1,0) e1=rnorm(N,0,1) M=alpha*x+e1 lambda=0.01 rho=1 beta=1.2 c=-1 rateC=0.001 v=runif(n=N) Tlat =(- log(v) / (lambda * exp(c*x+M*beta)))^(1 / rho) C=rexp(n=N, rate=rateC) time=pmin(Tlat, C) status <- as.numeric(Tlat <= C) test.m.t.1<- hdbma(pred=x, m=M,y=Surv(time,status),inits=function(){ list(r=1,lambda=0.01) },n.iter=10,n.burnin = 1) summary(test.m.t.1,RE=FALSE)
data("weight_behavior") #for all the examples, needs to remove or increase n.iter and n.burnin #binary predictor test.b.c<- hdbma(pred=weight_behavior[,3], m=weight_behavior[,c(4,14,12,13)], y=weight_behavior[,1],n.iter=10,n.burnin = 1) summary(test.b.c) ##use covariate for y test.b.c.2<- hdbma(pred=weight_behavior[,3], m=weight_behavior[,12:14], y=weight_behavior[,1],cova=weight_behavior[,2],n.iter=10,n.burnin = 1) summary(test.b.c.2) #categorical predictor test.ca.c<- hdbma(pred=weight_behavior[,4], m=weight_behavior[,12:14], y=weight_behavior[,1],n.iter=10,n.burnin = 1) summary(test.ca.c) #use covariate for mediators test.b.c.3<- hdbma(pred=weight_behavior[,3], m=weight_behavior[,c(9,12:14)], y=weight_behavior[,1],mcov=weight_behavior[,c(2,5)], mclist = list(1,2),n.iter=10,n.burnin = 1) summary(test.b.c.3) #use continuous predictor test.c.c<- hdbma(pred=weight_behavior[,2], m=weight_behavior[,12:14], y=weight_behavior[,1],n.iter=10,n.burnin = 1) summary(test.c.c,method=3) #use transfered continuous predictor test.c.c.2<- hdbma(pred=weight_behavior[,2], m=weight_behavior[,12:14], y=weight_behavior[,1],fpy=list(1,c("x","x^2")), n.iter=10,n.burnin = 1) summary(test.c.c.2,method=1) #multiple predictors test.m.c<- hdbma(pred=weight_behavior[,2:4], m=weight_behavior[,12:14], y=weight_behavior[,1],n.iter=10,n.burnin = 1) summary(test.m.c,RE=FALSE) ##binary outcome test.m.b<- hdbma(pred=weight_behavior[,2:4], m=weight_behavior[,12:14], y=weight_behavior[,15],cova=weight_behavior[,5], n.iter=10,n.burnin = 1) summary(test.m.b,method=2) ##categorical outcome weight_behavior[,14]=as.factor(weight_behavior[,14]) test.m.c<- hdbma(pred=weight_behavior[,2:4], m=weight_behavior[,12:13], y=weight_behavior[,14],cova=weight_behavior[,5], n.iter=10,n.burnin = 1) summary(test.m.c,method=2) summary(test.m.c,method=1) ##time-to-event outcome ##Surv class outcome (survival analysis) #use a simulation set.seed(1) N=100 alpha=0.5 x=rnorm(N,0,1) x=ifelse(x>0,1,0) e1=rnorm(N,0,1) M=alpha*x+e1 lambda=0.01 rho=1 beta=1.2 c=-1 rateC=0.001 v=runif(n=N) Tlat =(- log(v) / (lambda * exp(c*x+M*beta)))^(1 / rho) C=rexp(n=N, rate=rateC) time=pmin(Tlat, C) status <- as.numeric(Tlat <= C) test.m.t.1<- hdbma(pred=x, m=M,y=Surv(time,status),inits=function(){ list(r=1,lambda=0.01) },n.iter=10,n.burnin = 1) summary(test.m.t.1,RE=FALSE)
This database was obtained from the Louisiana State University Health Sciences Center, New Orleans, by Dr. Richard Scribner. He explored the relationship between BMI and kids behavior through a survey at children, teachers and parents in Grenada in 2014. This data set includes 691 observations and 15 variables.
data(weight_behavior)
data(weight_behavior)
The data set contains the following variables:
bmi - body mass index, calculated by weight(kg)/height(cm)^2, numeric
age - children's age in years at the time of survey, numeric
sex - sex of the children, factor
race - race of the children, factor
numpeople - number of people in family, numeric
car - the number of cars in family, numeric
gotosch - the method used to go to school, factor
snack - eat snack or not in a day, binary
tvhours - number of hours watching TV per week, numeric
cmpthours - number of hours using computer per week, numeric
cellhours - number of hours playing with cell phones per week, numeric
sports - join in a sport team or not, 1: yes; and 2: no
exercises - number of hours of exercises per week, numeric
sweat - number of hours of sweating activities per week, numeric
overweigh - the child is overweighed or not, binary
data(weight_behavior) names(weight_behavior)
data(weight_behavior) names(weight_behavior)