Package 'mediationsens'

Title: Simulation-Based Sensitivity Analysis for Causal Mediation Studies
Description: Simulation-based sensitivity analysis for causal mediation studies. It numerically and graphically evaluates the sensitivity of causal mediation analysis results to the presence of unmeasured pretreatment confounding. The proposed method has primary advantages over existing methods. First, using an unmeasured pretreatment confounder conditional associations with the treatment, mediator, and outcome as sensitivity parameters, the method enables users to intuitively assess sensitivity in reference to prior knowledge about the strength of a potential unmeasured pretreatment confounder. Second, the method accurately reflects the influence of unmeasured pretreatment confounding on the efficiency of estimation of the causal effects. Third, the method can be implemented in different causal mediation analysis approaches, including regression-based, simulation-based, and propensity score-based methods. It is applicable to both randomized experiments and observational studies.
Authors: Xu Qin and Fan Yang
Maintainer: Xu Qin <[email protected]>
License: GPL-2
Version: 0.0.3
Built: 2024-12-02 06:37:23 UTC
Source: CRAN

Help Index


Simulation-Based Sensitivity Analysis Table for Causal Mediation Analysis

Description

This function is used to evaluate the sensitivity of the estimated natural direrct and indirect effects to potential violations of the ignorability assumptions. It estimates the natural direct and indirect effects after adjusting for an unmeasured pretreatment confounder, U, with a specified degree of confounding. In a randomized experiment, the degree of confounding is evaluated via two sensitivity parameters, the coefficient of U in the mediator model and that in the outcome model, given the specified prior distribution of U. When the treatment is not randomized, an additional sensitivity parameter is introduced – the coefficient of U in the treatment model. The mediator, outcome, and unmeasured pretreatment confounder could be either binary or continuous, while the treatment has to be binary. If the treatment is randomized, the sensitivity analysis method is applicable to various causal mediation analysis methods, including the ratio of mediator probability weights (RMPW) method, the regression-based method proposed by VanderWeele (2010), and the simulation-based method proposed by Imai et al. (2010a, 2010b). If the treatment is not randomized, the method is applicable to the RMPW method. To reduce the risk of model misspecifications, we account for the interaction between the treatment and each observed pretreatment covariate in the mediator model.

Usage

sens(
  y,
  t.rand = TRUE,
  t,
  m,
  covariates,
  scale.y,
  scale.m,
  scale.U,
  b.t = NULL,
  range.b.m = c(-2, 2),
  range.b.y = c(-1, 1),
  grid.b.y = 5,
  grid.b.m = 5,
  p.u = 0.5,
  sigma.u = 1,
  iter = 10,
  nsim = 40,
  est,
  B,
  data
)

Arguments

y

The name of the outcome variable (string).

t.rand

TRUE if the treatment is randomized, and FALSE if not. The default is TRUE.

t

The name of the treatment variable (string). The treatment variable has to be binary.

m

The name of the mediator variable (string).

covariates

A vector of variable names (string) of pretreatment confounders, which will be included in the propensity score model. Transform each categorical variable into multiple binary indicators before specifying X.

scale.y

The scale of the outcome variable (string). Can be "continuous" or "binary".

scale.m

The scale of the mediator variable (string). Can be "continuous" or "binary".

scale.U

The scale of the unobserved pretreatment confounder (string). Can be "continuous" or "binary".

b.t

The value of the sensitivity parameter that represents the conditional association between the unobserved pretreatment confounder and the treatment. The default is NULL, because when the treatment is randomized, there is no need to specify this sensitivity parameter.

range.b.m

The range of the sensitivity parameter that represents the conditional association between the unobserved pretreatment confounder and the mediator. The default is c(-2, 2).

range.b.y

The range of the sensitivity parameter that represents the conditional association between the unobserved pretreatment confounder and the outcome. The default is c(-1, 1).

grid.b.y

The vertical dimension of the grid. The default is 5. Increase the number for more smooth curves.

grid.b.m

The horizontal dimension of the grid. The default is 5. Increase the number for more smooth curves.

p.u

The prior probability of the unobserved pretreatment confounder if it is binary. The default is 0.5.

sigma.u

The standard deviation of the prior distribution of the unobserved pretreatment confounder if it is continuous. The default is 1.

iter

The number of iterations in the stochastic EM algorithm for generating the unobserved pretreatment confounder. The default is 10.

nsim

The number of random draws of the unobserved pretreatment confounder in each cell. The default is 40. Increase the number for more smooth curves.

est

The method to be used in the estimation of the causal mediation effects. "rmpw" uses the weighting-based method. It estimates the natural direct and indirect effects through mean contrasts of the outcome. When the outcome is coninuous, it controls for the pretreatment confounders in the outcome model for improving efficiency. When the outcome is binary, it cannot control for the pretreatment confounders. In addition to the scenario with a binary mediator and a continuous outcome, we use bootstrapping to estimate their standard errors and test their significance. "regression" uses the regression-based method developed by VanderWeele and Vansteelandt (2009). It is only applicable to continuous outcomes, because when the outcome is binary, the natural direct and indirect effects are identified on the odds ratio scale, rendering results difficult to report. Because the estimator of the natural direct effect or the natural indirect effect is a complex combination of regression coefficients and may not follow a normal distribution, we use bootstrapping to estimate their standard errors and test their significance. "simulation" uses the simulation-based method developed by Imai et al. (2010a, 2010b), and the mediation package is adopted. For a binary mediator or outcome, the link function is always specified to be logit. If t.rand = FALSE, i.e the treatment is not randomized, only rmpw is applicable.

B

The number of bootstrapped samples in the causal mediation analysis if bootstrapping is used for estimating standard errors and testing significance.

data

The data set for analysis.

Value

A list containing

results.old

the causal effect estimates in the original analysis.

X.coef.plot

the coefficients of the observed pretreatment covariates in the mediator and outcome models (which are used to calibrate the strength of the sensitivity parameters in the sensitivity plots).

range.b.m, range.b.y

same as specified in the sens function.

b.m.all, b.y.all

all the specific values of the sensitivity parameters for constructing the grids.

results.new

tables for the causal effect estimates, standard errors, and p values in all the grids, after the adjustment of the unobserved pretreatment confounder.

Author(s)

Xu Qin and Fan Yang

References

Qin, X., & Yang, F. (2020). Simulation-Based Sensitivity Analysis for Causal Mediation Studies.

VanderWeele, T. J. (2010). Bias formulas for sensitivity analysis for direct and indirect effects. Epidemiology, 21, 540.

Imai, K., Keele, L., & Tingley, D. (2010a). A general approach to causal mediation analysis. Psychological Methods, 15, 309.

Imai, K., Keele, L., & Yamamoto, T. (2010b). Identification, inference and sensitivity analysis for causal mediation effects. Statistical Science, 25, 51-71.

Examples

library(mediation)
data(jobs)
# Generate a binary outcome based on the median of the
# continuous outcome.
jobs$depress2_dich[jobs$depress2 >= median(jobs$depress2)] = 1
jobs$depress2_dich[jobs$depress2 < median(jobs$depress2)] = 0

sens.results = sens(y = "depress2", t = "treat", m = "job_seek",
    covariates = c("econ_hard", "depress1", "sex", "age"), scale.y = "continuous",
    scale.m = "continuous", scale.U = "binary", range.b.m = c(-2,
        2), range.b.y = c(-1, 1), grid.b.y = 2, grid.b.m = 1, p.u = 0.5,
    iter = 10, nsim = 10, est = "rmpw", B = 2, data = jobs)

Simulation-Based Sensitivity Analysis Plot for Causal Mediation Analysis

Description

This function is used to visually represent the sensitivity analysis results when the treatment is randomized. Each black contour represents the combinations of sensitivity parameters that lead to the same indirect effect estimate as indicated by the number on the contour. The sensitivity parameters along the red dashed curves reduce the estimate to zero. In the region between the two blue dotted curves that bracket the red curve, the effect is changed to be insignificant at the significance level of 0.05. The larger the magnitudes of the sensitivity parameters are for removing the effects or changing their significance, the less sensitive the results are. Each dot corresponds to the conditional associations of each observed covariate with the outcome and the mediator, which are used to calibrate the strength of the sensitivity parameters.

Usage

sens.plot(sens.results, effect = "NIE", est)

Arguments

sens.results

An output from the sens function.

effect

The name of the effect whose sensitivity analysis results are to be plotted (string). "NIE" for natural indirect effect. "NDE" for natural direct effect. The default is "NIE".

est

The method used in the estimation of the causal mediation effects. "rmpw" uses the weighting-based method. "regression" uses the regression-based method developed by VanderWeele and Vansteelandt (2009). "simulation" uses the simulation-based method developed by Imai et al. (2010a, 2010b).

Value

Sensitivity analysis plots for the natural direct and in direct effects.

Author(s)

Xu Qin and Fan Yang

References

Qin, X., & Yang, F. (2020). Simulation-Based Sensitivity Analysis for Causal Mediation Studies.