data.org.big: Data Organization and Identify Potential Mediators

View source: R/mmabig.r

data.org.bigR Documentation

Data Organization and Identify Potential Mediators

Description

Do a preliminary data analysis to identify potential mediators and covariates. Each variable listed in jointm is forced in the final estimation model as a mediator. Also organize the data into a format that can be directly used for the mediation analysis functions.

Usage

data.org.big(x,y,pred,mediator=NULL,contmed=NULL,binmed=NULL,binref=NULL,catmed=NULL,
                       catref=NULL,jointm=NULL, 
                       family1=as.list(rep(NA,ncol(data.frame(y)))),
                       predref=NULL,alpha=1,alpha1=0.01,alpha2=0.01,testtype=2, w=NULL,
                       lambda=exp(seq(log(0.001), log(5), length.out=15)))

Arguments

x

a data frame contains the predictor, all potential mediators and covariates

y

the vector of outcome variable.The outcome can be binary, continuous, multicategorical or of "Surv" class (see survival package for help). For a factor, the last level in alphabetical order is the target class.

pred

the column or matrix of predictor(s): the predictor is the exposure variable, it can be a binary or multi-categorical factor or one/a few contiuous variable(s).

mediator

the list of mediators (column numbers in x or by variable names). The mediators to be checked can be identified by "contmed", "binmed" and "catmed", or by this argument, "mediator", where binary and categorical mediators in x are identified as factors or characters, the reference group is the first level of the factor or factorized character. if a mediator has only two unique values, the mediator is identified as binary. If the reference groups need to be changed, the binary or categorical mediators can be listed in binmed or catmed, and the corresponding reference group in binref or catref.

contmed

a vector of variable names or column numbers that locate the potential continuous mediators in x.

binmed

a vector of column numbers that locate the potential binary mediators in x.

binref

the defined reference groups of the binary potential mediators in binmed. The first levels of the mediators if is null.

catmed

a vector of variable names or column numbers that locate the potential categorical mediators in x. The first levels of the mediators if is null.

catref

the defined reference groups of the categorical potential mediators in catmed.

jointm

a vector of variables that need to be forced in as mediators.

family1

define the conditional distribution of y given x, and the linkage function that links the mean of y with the system component in generalized linear model. The default value of family1 is binomial(link = "logit") for binary y, and gaussian(link="identity") for continuous y.

predref

if the predictor is binary, identify the reference group of the binary predictor. The default is the first level of the predictor. The value of the predictor is 0 for the reference grop.

alpha

the elasticnet mixing parameter such that 0<=alpha<=1, with alpha=1 is the lasso penalty, and alpha=0 be the ridge penalty. By default, alpha=1.

alpha1

the significance level at which to test if the potential mediators (identified by contmed, binmed, and catmed) can be used as a covariate or mediator in estimating y when all variables in x are included in the model. The default value is alpha1=0.01.

alpha2

the significant level at which to test if a potential mediator is related with the predictor. The default value is alpha2=0.01.

testtype

if the testtype is 1, covariates/mediators are identified using full model; if the testtype is 2 (by default), covariates/mediators are tested one by one in models with the predictor only.

w

the weight for data analysis, by default is rep(1,length(y)).

lambda

the lambda sequence when fit cv.glmnet. By default, it is exp(seq(log(0.001), log(5), length.out=15)).

Value

data.org.big returns a "med_iden" class (see mma package), a list with the organized data and identifiers of the potential mediators in the organized data set.

x

the organized data frame that include all potential mediators and covariates that should be used to estimate the outcome.

dirx

the vector/matrix of predictor(s)/exposure variable(s).

contm

the column numbers of x that locate the potential continuous mediators.

binm

when the predictor is continuous, binm gives the column numbers of x that locate the potential binary mediators.

catm

when the predictor is binary, catm gives the column numbers of x that locate the potential binary or categorical mediators; when the predictor is continuous, catm gives a list where the first item is the number of potential categorical mediators, and the following items give the column numbers of each binarized categorical mediator in x.

jointm

a list where the first item is the number of groups of joint mediators, and each of the following items identifies the column numbers of the mediators in the newly organized x for each group of joint mediators.

y

the vector/matrix of outcome(s).

y_type

the variable type of outcome(s): 1 is continuous, 2 is binary, 3 is reserved for multi-categorical (no 3 would show in y_type, since all categorical responses are binarized), and 4 is survival.

fullmodel

a list with each item the full linear model fitted with all potential mediators and covariates for each response.

rela

p-values of tests on the realtionship between the predictor(s) and each potiential mediator.

P1

If testtype=2, P1 gives the p-value of the corresponding variables in predicting the outcome(s) when only the variable and predictor are covariates in the model.

Note

All other variables in x but not identified by mediator, contmed, binmed, or catmed are forced in the final model as covariates. Compared with data.org, joint mediators are considered in this function. Every variable in the jointm should be listed in contmed, binmed, or catmed, and these variables are forced to be included as mediators for further mediation analysis. A variables can be included in more than one groups of joint mediators in jointm.

Author(s)

Qingzhao Yu qyu@lsuhsc.edu and Bin Li bli@lsu.edu

References

Baron, R.M., and Kenny, D.A. (1986) <doi:10.1037/0022-3514.51.6.1173>. The moderator-mediator variable distinction in social psychological research: conceptual, strategic, and statistical considerations. J. Pers Soc Psychol, 51(6), 1173-1182.

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

Yu, Q., Scribner, R.A., Leonardi, C., Zhang, L., Park, C., Chen, L., and Simonsen, N.R. (2017) <doi:10.1016/j.sste.2017.02.001>. "Exploring racial disparity in obesity: a mediation analysis considering geo-coded environmental factors," Spatial and Spatio-temporal Epidemiology, 21, 13-23.

Yu, Q., and Li, B. (2017) <doi:10.5334/hors.160>. "mma: An r package for multiple mediation analysis," Journal of Open Research Software, 5(1), 11.

Li, B. and Yu, Q. (2018). "Mediation Analysis with Large Data Sets".

Examples

#See help(mma.big)

mmabig documentation built on Aug. 29, 2023, 5:09 p.m.