Learn R Programming

mma (version 1.0-0)

boot.med.contx: Statistical Inference on Mediation Analysis with Continuous Predictor

Description

To make inferences on the mediation effects when the predictor is continuous.

Usage

boot.med.contx(x, y, dirx, binm = NULL, contm = NULL, catm = NULL, 
 jointm = NULL, margin = 1, n = 20, seed = sample(1:1000, 1), 
 mart = F, nu = 0.001, D = 3, distn = "gaussian", 
 family1 = gaussian(link = "identity"), n2 = 50)

Arguments

x
a data frame contains the predictor, all mediators and covariates.
y
the vector of outcome variable.
dirx
the column number of x that locates the predictor.
binm
the column number of x that locates the binary mediators.
contm
the column numbers of x that locate the potential continuous mediators.
catm
categorical mediators should be binarized and be presented as a list, where the first item is the number of categorical variables and the following items are the column numbers of each binarized categorical variable in x. data.org and data.org2 organize t
jointm
a list where the first item is the number of groups of joint mediators to be considered, and each of the following items identifies the column numbers of the mediators in x for each group of joint mediators.
margin
the change in predictor when calculating the mediation effects, see Yu et al. (2014).
n
the time of resampling in calculating the indirect effects, default is n=20, see Yu et al. (2014).
seed
set seed to make the calculation repeatable. The default value of seed is from sample(1:1000,1).
mart
if TURE, Multiple Additive Regression Trees (MART) will be used to fit the final full model in estimating the outcome. The default value of mart is FALSE, in which case, a generalized linear model will be used to fit the final full model.
nu
set the parameter "interaction.depth" in gbm function if MART is to be used, by default, nu=0.001. See also help(gbm.fit).
D
set the parameter "shrinkage" in gbm function if MART is to be used, by default, D=3. See also help(gbm.fit).
distn
the assumed distribution of the outcome if MART is used for final full model. The default value of distn is "gaussian". If y is binary, may use distn="bernoulli".
family1
define the conditional distribution of y given x, and the linkage function that links the mean of y with the system component if generalized linear model is used as the final full model. The default value of family1 is gaussian(link="identity"). If y is
n2
the number of times of bootstrap resampling. The default value is n2=50.

Value

  • Returns an mma object.
  • estimationlist the estimation of ie (indirect effect), te (total effect), and de (direct effect from the predictor) separately.
  • bootsresultsa list where the first item, ie, is a matrix of n2 rows where each column gives the estimated indirect effect from the corresponding mediator (identified by the column name) from the n2 bootstrap samples; the second item, te, is a vector of estimated total effects from the bootstrap sample; and the 3rd item, de, is a vector of estimated direct effect of the predictor from the bootstrap sample.
  • modela list where the first item, mart, is T if MART is fitted for the final model; the second item, model, is the fitted final full model where y is the outcome and all predictor, covariates, and mediators are the explanatory variables; and the third item, best.iter is the number of best iterations if MART is used to fit the final model.

Details

The mediators are not tested in this function. data.org or data.org2 should be used for the tests and the resulted list can be used directly to define the parameters in this function. boot.med.contx considers all variables in x as mediators or covariates in the final model and all variables identified by contm, binm, catm, or jointm as mediators.

References

Yu, Q., Fan, Y., and Wu, X. (2014). "General Multiple Mediation Analysis With an Application to Explore Racial Disparity in Breast Cancer Survival," Journal of Biometrics & Biostatistics,5(2): 189.

See Also

"med.contx" to estimate mediation effects, "med.binx" and "boot.med.binx" for mediation analysis when the preditor is binary.

Examples

Run this code
data("weight_behavior")
 #binary y
 x=weight_behavior[,2:14]
 y=weight_behavior[,15]
 data.contx<-data.org(x,y,pred=1,contmed=c(8:10,12:13),binmed=c(7,11),
   binref=c(1,1),catmed=6,catref=1,binpred=FALSE,alpha=0.4,alpha2=0.4)
 temp5<-boot.med.contx(x=data.contx$x,y,dirx=data.contx$dirx,
   binm=data.contx$binm, contm=data.contx$contm,catm=data.contx$catm,
   seed=1,n=2,family1=binomial(link = "logit"),n2=2)
 
 #continuous y
 x=weight_behavior[,2:14]
 y=weight_behavior[,1]
 data.contx<-data.org(x,y,pred=1,contmed=c(8:10,12:13),binmed=c(7,11),
   binref=c(1,1),catmed=6,catref=1,binpred=FALSE,
   family1=gaussian(link="identity"),alpha=0.4,alpha2=0.4)
 temp7<-boot.med.contx(x=data.contx$x,y,dirx=data.contx$dirx,
   binm=data.contx$binm, contm=data.contx$contm,catm=data.contx$catm,
   seed=1,n=2,n2=2)

Run the code above in your browser using DataLab