Version: | 0.0.4 |
Date: | 2021-09-02 |
Title: | Causal Mediation Analysis in Multisite Trials |
Author: | Xu Qin, Guanglei Hong, Jonah Deutsch, and Edward Bein |
Maintainer: | Xu Qin <xuqin@pitt.edu> |
Depends: | lme4, statmod, psych, MASS, ggplot2 |
Description: | Multisite causal mediation analysis using the methods proposed by Qin and Hong (2017) <doi:10.3102/1076998617694879>, Qin, Hong, Deutsch, and Bein (2019) <doi:10.1111/rssa.12446>, and Qin, Deutsch, and Hong (2021) <doi:10.1002/pam.22268>. It enables causal mediation analysis in multisite trials, in which individuals are assigned to a treatment or a control group at each site. It allows for estimation and hypothesis testing for not only the population average but also the between-site variance of direct and indirect effects transmitted through one single mediator or two concurrent (conditionally independent) mediators. This strategy conveniently relaxes the assumption of no treatment-by-mediator interaction while greatly simplifying the outcome model specification without invoking strong distributional assumptions. This package also provides a function that can further incorporate a sample weight and a nonresponse weight for multisite causal mediation analysis in the presence of complex sample and survey designs and non-random nonresponse, to enhance both the internal validity and external validity. The package also provides a weighting-based balance checking function for assessing the remaining overt bias. |
License: | GPL-2 |
RoxygenNote: | 7.1.1 |
URL: | https://github.com/Xu-Qin/MultisiteMediation |
BugReports: | https://github.com/Xu-Qin/MultisiteMediation/issues |
NeedsCompilation: | no |
Packaged: | 2021-09-05 15:38:31 UTC; XUQIN |
Repository: | CRAN |
Date/Publication: | 2021-09-05 16:00:02 UTC |
Balance checking for causal mediation analysis in multisite trials
Description
This function is used to check if, within a treatment group, the estimated nonresponse weight balances the distribution of the observed covariates between the respondents and the nonrespondents, or if the estimated RMPW weight balances the distribution of the observed covariates between those whose mediator takes value 1 and those whose mediator takes value 0.
Usage
balance(data, y, treatment, mediator, response, XR1, XR0, XM1, XM0, X, site)
Arguments
data |
The data set for analysis. |
y |
The name of the outcome variable (string). |
treatment |
The name of the treatment variable (string). |
mediator |
The name of the mediator variable (string). |
response |
The name of the response variable (string), which is equal to 1 if the individual responded and 0 otherwise. |
XR1 |
A vector of variable names (string) of pretreatment covariates in the propensity score model for the response under the treatment condition. For now, the multilevel propensity score model only allows for one random intercept. |
XR0 |
A vector of variable names (string) of pretreatment covariates in the propensity score model for the response under the control condition. For now, the multilevel propensity score model only allows for one random intercept. |
XM1 |
A vector of variable names (string) of pretreatment covariates in the propensity score model for the mediator under the treatment condition. For now, the multilevel propensity score model only allows for one random intercept. |
XM0 |
A vector of variable names (string) of pretreatment covariates in the propensity score model for the mediator under the control condition. For now, the multilevel propensity score model only allows for one random intercept. |
X |
A vector of variable names (string) of all the pretreatment covariates to be checked balance for. |
site |
The variable name for the site ID (string). |
Value
A list of tables containing the balance checking results for the response before weighting ($balance.R$balance1 under the treatment condition and $balance.R$balance0 under the control condition) and after weighting ($balance.R$balance1.adj under the treatment condition and $balance.R$balance0.adj under the control condition); and the balance checking results for the mediator before weighting ($balance.M$balance1 under the treatment condition and $balance.M$balance0 under the control condition) and after weighting ($balance.M$balance1.adj under the treatment condition and $balance.M$balance0.adj under the control condition). It also contains a set of balance checking plots corresponding to the tables.
balance.mean |
Population average of standardized bias. The standardized bias is calculated by dividing the unweighted (before weighting) or weighted (after weighting) mean difference between response or mediator levels in each covariate by the standard deviation of the covariate |
balance.sd |
Between-site standard deviation of standardized bias. |
balance.lower |
Lower bound of the 95% plausible value range of the site-specific standardized bias. |
balance.upper |
Upper bound of the 95% plausible value range of the site-specific standardized bias. |
Author(s)
Xu Qin, Guanglei Hong, Jonah Deutsch, and Edward Bein
References
Qin, X., Hong, G., Deutsch, J., & Bein, E. (2019). Multisite causal mediation analysis in the presence of complex sample and survey designs and non-random non-response. Journal of the Royal Statistical Society: Series A (Statistics in Society), 182(4), 1343-1370. doi: 10.1111/rssa.12446
Examples
data(sim.weights)
balance(data = sim.weights, y = "y", treatment = "tr", mediator = "me", response = "R",
XR1 = c("x1", "x2", "x3"), XR0 = c("x1", "x2", "x3"), XM1 = c("x1", "x2", "x3"),
XM0 = c("x1", "x2", "x3"), X = c("x1", "x2", "x3"), site = "site")
Causal mediation analysis in multisite trials
Description
This function is used to estimate both the population average and between-site variance of direct and indirect effects.
Usage
msmediate(data, y, treatment, mediator, X, site)
Arguments
data |
The data set for analysis. |
y |
The name of the outcome variable (string). |
treatment |
The name of the treatment variable (string). |
mediator |
The name of the mediator variable (string). |
X |
A vector of variable names (string) of pretreatment covariates, which will be included in the propensity score model. For now, the multilevel propensity score model only allows for one random intercept. |
site |
The variable name for the site ID (string). |
Value
A list contains the estimates of the between-site variance of direct effect, that of indirect effect, and the correlation between the direct and indirect effects across sites ($Random_effects), and the population average direct and indirect effect estimates along with their hypothesis testing results ($Fixed_effects).
Author(s)
Xu Qin and Guanglei Hong
References
Qin, X., & Hong, G (2017). A weighting method for assessing between-site heterogeneity in causal mediation mechanism. Journal of Educational and Behavioral Statistics. Journal of Educational and Behavioral Statistics, 42(3), 308-340. doi: 10.3102/1076998617694879
Examples
data(sim)
msmediate(data = sim, y = "y", treatment = "tr", mediator = "me", X = c("x1", "x2",
"x3", "x4"), site = "site")
Complex multisite causal mediation analysis with two concurrent mediators in the presence of complex sample and survey designs and non-random nonresponse
Description
This function is used to estimate both the population average and between-site variance of a natural indirect transmitted through each mediator and a natural direct effect when two concurrent (conditionally independent) mediators are involved in the mediation mechanism. It incorporates a sample weight to adjust for complex sample and survey designs and employs an estimated nonresponse weight to account for non-random nonresponse.
Usage
msmediate.concurrent(
data,
y,
treatment,
mediator,
response,
XR1,
XR0,
XM11,
XM10,
XM21,
XM20,
site,
sample.weight
)
Arguments
data |
The data set for analysis. |
y |
The name of the outcome variable (string). |
treatment |
The name of the treatment variable (string). |
mediator |
A vecor of two mediator variable names (string). |
response |
The name of the response variable (string), which is equal to 1 if the individual responded and 0 otherwise. |
XR1 |
A vector of variable names (string) of pretreatment covariates in the propensity score model for the response under the treatment condition. For now, the multilevel propensity score model only allows for one random intercept. |
XR0 |
A vector of variable names (string) of pretreatment covariates in the propensity score model for the response under the control condition. For now, the multilevel propensity score model only allows for one random intercept. |
XM11 |
A vector of variable names (string) of pretreatment covariates in the propensity score model for the first mediator under the treatment condition. For now, the multilevel propensity score model only allows for one random intercept. |
XM10 |
A vector of variable names (string) of pretreatment covariates in the propensity score model for the first mediator under the control condition. For now, the multilevel propensity score model only allows for one random intercept. |
XM21 |
A vector of variable names (string) of pretreatment covariates in the propensity score model for the second mediator under the treatment condition. For now, the multilevel propensity score model only allows for one random intercept. |
XM20 |
A vector of variable names (string) of pretreatment covariates in the propensity score model for the second mediator under the control condition. For now, the multilevel propensity score model only allows for one random intercept. |
site |
The variable name for the site ID (string). |
sample.weight |
The variable name for the sample weight given by design (string). |
Value
A list contains the estimates of the between-site variances of indirect effect via M1 given M2(0) ("I.M1(0)"), indirect effect via M2 given M1(1) ("I.M2(1)"), direct effect ("D"), indirect effect via M1 given M2(1) ("I.M1(1)"), indirect effect via M2 given M1(0) ("I.M2(0)"), interaction effect between M1 and M2 ("I.M1*M2"), and the correlations between the effects across sites ($Random_effects), and the population average effect estimates along with their hypothesis testing results ($Fixed_effects).
Author(s)
Xu Qin, Jonah Deutsch, and Guanglei Hong
References
Qin, X., Deutsch, J, & Hong, G. (2021). Unpacking Complex Mediation Mechanisms and Their Heterogeneity between Sites in A Job Corps Evaluation. The Journal of Policy Analysis and Management, 40(1), 158-190. doi: 10.1002/pam.22268
Examples
data(sim.weights)
msmediate.concurrent(data = sim.weights, y = "y", treatment = "tr", mediator = c("me",
"me2"), response = "R", XR1 = c("x1", "x2", "x3"), XR0 = c("x1", "x2", "x3"),
XM11 = c("x1", "x2", "x3"), XM10 = c("x1", "x2", "x3"), XM21 = c("x1", "x2",
"x3"), XM20 = c("x1", "x2", "x3"), site = "site", sample.weight = "WD")
Causal mediation analysis in multisite trials in the presence of complex sample and survey designs and non-random nonresponse
Description
This function is used to estimate both the population average and between-site variance of natural direct effect, natural indirect effect, pure indirect effect, and treatment-by-mediator interaction effect. It incorporates a sample weight to adjust for complex sample and survey designs and employs an estimated nonresponse weight to account for non-random nonresponse.
Usage
msmediate.weights(
data,
y,
treatment,
mediator,
response,
XR1,
XR0,
XM1,
XM0,
site,
sample.weight
)
Arguments
data |
The data set for analysis. |
y |
The name of the outcome variable (string). |
treatment |
The name of the treatment variable (string). |
mediator |
The name of the mediator variable (string). |
response |
The name of the response variable (string), which is equal to 1 if the individual responded and 0 otherwise. |
XR1 |
A vector of variable names (string) of pretreatment covariates in the propensity score model for the response under the treatment condition. For now, the multilevel propensity score model only allows for one random intercept. |
XR0 |
A vector of variable names (string) of pretreatment covariates in the propensity score model for the response under the control condition. For now, the multilevel propensity score model only allows for one random intercept. |
XM1 |
A vector of variable names (string) of pretreatment covariates in the propensity score model for the mediator under the treatment condition. For now, the multilevel propensity score model only allows for one random intercept. |
XM0 |
A vector of variable names (string) of pretreatment covariates in the propensity score model for the mediator under the control condition. For now, the multilevel propensity score model only allows for one random intercept. |
site |
The variable name for the site ID (string). |
sample.weight |
The variable name for the sample weight given by design (string). |
Value
A list contains the estimates of the between-site variances of natural direct effect, natural indirect effect, pure indirect effect, and treatment-by-mediator interaction effect, and the correlations between the effects across sites ($Random_effects), and the population average effect estimates along with their hypothesis testing results ($Fixed_effects).
Author(s)
Xu Qin, Guanglei Hong, Jonah Deutsch, and Edward Bein
References
Qin, X., Hong, G., Deutsch, J., & Bein, E. (2019). Multisite causal mediation analysis in the presence of complex sample and survey designs and non-random non-response. Journal of the Royal Statistical Society: Series A (Statistics in Society), 182(4), 1343-1370. doi: 10.1111/rssa.12446
Examples
data(sim.weights)
msmediate.weights(data = sim.weights, y = "y", treatment = "tr", mediator = "me",
response = "R", XR1 = c("x1", "x2", "x3"), XR0 = c("x1", "x2", "x3"), XM1 = c("x1",
"x2", "x3"), XM0 = c("x1", "x2", "x3"), site = "site", sample.weight = "WD")
A simulated example data
Description
This simulated data list is for demonstration.
Value
A list containing
site |
Site ID |
y |
Outcome |
tr |
Treatment |
me |
Mediator |
x1 |
Pretreatment covariate |
x2 |
Pretreatment covariate |
x3 |
Pretreatment covariate |
x4 |
Pretreatment covariate |
A simulated example data
Description
This simulated data list is for demonstration.
Value
A list containing
site |
Site ID |
y |
Outcome |
tr |
Treatment |
me |
Mediator |
x1 |
Pretreatment covariate |
x2 |
Pretreatment covariate |
x3 |
Pretreatment covariate |
R |
Response indicator |
WD |
Sample weight |
Variance testing for multisite causal mediation analysis
Description
This function performs hypothesis testing for the between-site variance of direct effect and that of indirect effect, besides providing the same output as given by the function msmediate().
Usage
vartest.msmediate(data, y, treatment, mediator, X, site, npermute = 200)
Arguments
data |
The data set for analysis. |
y |
The name of the outcome variable (string). |
treatment |
The name of the treatment variable (string). |
mediator |
The name of the mediator variable (string). |
X |
A vector of variable names (string) of pretreatment covariates, which will be included in the propensity score model. For now, the multilevel propensity score model only allows for one random intercept. |
site |
The variable name for the site ID (string). |
npermute |
The number of permutations for the permutation test. The default value is 200. It may take a long time, depending on the sample size and the length of X. |
Value
A list contains the hypothesis testing results of the between-site variance of the causal effects, besides the same output as given by the function msmediate().
Author(s)
Xu Qin and Guanglei Hong
References
Qin, X., & Hong, G (2017). A weighting method for assessing between-site heterogeneity in causal mediation mechanism. Journal of Educational and Behavioral Statistics. Journal of Educational and Behavioral Statistics. Journal of Educational and Behavioral Statistics, 42(3), 308-340. doi: 10.3102/1076998617694879
Examples
data(sim)
vartest.msmediate(data = sim, y = "y", treatment = "tr", mediator = "me", X = c("x1",
"x2", "x3", "x4"), site = "site", npermute = 2)
Variance testing for complex multisite causal mediation analysis with two concurrent mediators in the presence of complex sample and survey designs and non-random nonresponse
Description
This function performs hypothesis testing for the between-site variances besides providing the same output as given by the function msmediate.concurrent().
Usage
vartest.msmediate.concurrent(
data,
y,
treatment,
mediator,
response,
XR1,
XR0,
XM11,
XM10,
XM21,
XM20,
site,
sample.weight,
npermute = 200
)
Arguments
data |
The data set for analysis. |
y |
The name of the outcome variable (string). |
treatment |
The name of the treatment variable (string). |
mediator |
A vecor of two mediator variable names (string). |
response |
The name of the response variable (string), which is equal to 1 if the individual responded and 0 otherwise. |
XR1 |
A vector of variable names (string) of pretreatment covariates in the propensity score model for the response under the treatment condition. For now, the multilevel propensity score model only allows for one random intercept. |
XR0 |
A vector of variable names (string) of pretreatment covariates in the propensity score model for the response under the control condition. For now, the multilevel propensity score model only allows for one random intercept. |
XM11 |
A vector of variable names (string) of pretreatment covariates in the propensity score model for the first mediator under the treatment condition. For now, the multilevel propensity score model only allows for one random intercept. |
XM10 |
A vector of variable names (string) of pretreatment covariates in the propensity score model for the first mediator under the control condition. For now, the multilevel propensity score model only allows for one random intercept. |
XM21 |
A vector of variable names (string) of pretreatment covariates in the propensity score model for the second mediator under the treatment condition. For now, the multilevel propensity score model only allows for one random intercept. |
XM20 |
A vector of variable names (string) of pretreatment covariates in the propensity score model for the second mediator under the control condition. For now, the multilevel propensity score model only allows for one random intercept. |
site |
The variable name for the site ID (string). |
sample.weight |
The variable name for the sample weight given by design (string). |
npermute |
The number of permutations for the permutation test. The default value is 200. It may take a long time, depending on the sample size and the length of X. |
Value
A list contains the hypothesis testing results of the between-site variance of the causal effects, besides the same output as given by the function msmediate().
Author(s)
Xu Qin, Jonah Deutsch, and Guanglei Hong
References
Qin, X., Deutsch, J, & Hong, G. (2021). Unpacking Complex Mediation Mechanisms and Their Heterogeneity between Sites in A Job Corps Evaluation. The Journal of Policy Analysis and Management, 40(1), 158-190. doi: 10.1002/pam.22268
Examples
data(sim.weights)
set.seed(1)
vartest.msmediate.concurrent(data = sim.weights, y = "y", treatment = "tr",
mediator = c("me", "me2"), response = "R", XR1 = c("x1", "x2", "x3"), XR0 = c("x1",
"x2", "x3"), XM11 = c("x1", "x2", "x3"), XM10 = c("x1", "x2", "x3"),
XM21 = c("x1", "x2", "x3"), XM20 = c("x1", "x2", "x3"), site = "site",
sample.weight = "WD", npermute = 2)
Variance testing for multisite causal mediation analysis in the presence of complex sample and survey designs and non-random nonresponse
Description
This function performs hypothesis testing for the between-site variances of natural direct effect, natural indirect effect, pure indirect effect, and treatment-by-mediator interaction effect in the presence of complex sample and survey designs and non-random nonresponse, besides providing the same output as given by the function msmediate.weights().
Usage
vartest.msmediate.weights(
data,
y,
treatment,
mediator,
response,
XR1,
XR0,
XM1,
XM0,
site,
sample.weight,
npermute = 200
)
Arguments
data |
The data set for analysis. |
y |
The name of the outcome variable (string). |
treatment |
The name of the treatment variable (string). |
mediator |
The name of the mediator variable (string). |
response |
The name of the response variable (string), which is equal to 1 if the individual responded and 0 otherwise. |
XR1 |
A vector of variable names (string) of pretreatment covariates in the propensity score model for the response under the treatment condition. For now, the multilevel propensity score model only allows for one random intercept. |
XR0 |
A vector of variable names (string) of pretreatment covariates in the propensity score model for the response under the control condition. For now, the multilevel propensity score model only allows for one random intercept. |
XM1 |
A vector of variable names (string) of pretreatment covariates in the propensity score model for the mediator under the treatment condition. For now, the multilevel propensity score model only allows for one random intercept. |
XM0 |
A vector of variable names (string) of pretreatment covariates in the propensity score model for the mediator under the control condition. For now, the multilevel propensity score model only allows for one random intercept. |
site |
The variable name for the site ID (string). |
sample.weight |
The variable name for the sample weight given by design (string). |
npermute |
The number of permutations for the permutation test. The default value is 200. It may take a long time, depending on the sample size and the length of X. |
Value
A list contains the hypothesis testing results of the between-site variance of the causal effects, besides the same output as given by the function msmediate().
Author(s)
Xu Qin, Guanglei Hong, Jonah Deutsch, and Edward Bein
References
Qin, X., Hong, G., Deutsch, J., & Bein, E. (2019). Multisite causal mediation analysis in the presence of complex sample and survey designs and non-random non-response. Journal of the Royal Statistical Society: Series A (Statistics in Society), 182(4), 1343-1370. doi: 10.1111/rssa.12446
Examples
data(sim.weights)
vartest.msmediate.weights(data = sim.weights, y = "y", treatment = "tr", mediator = "me",
response = "R", XR1 = c("x1", "x2", "x3"), XR0 = c("x1", "x2", "x3"), XM1 = c("x1",
"x2", "x3"), XM0 = c("x1", "x2", "x3"), site = "site", sample.weight = "WD",
npermute = 2)