medsens {mediation}R Documentation

Causal Mediation Analysis - Sensitivity Analysis

Description

Function to perform sensitivity analysis on mediation effect for violations of sequential ignorability assumption. This allows for a correlation between the error terms of the outcome model and the mediator model. Sensitivity analysis is possible with 1) continuous mediator and continuous outcome, 2) binary outcome and continuous mediator, and 3) continuous outcome and binary mediator. Output from the function can be passed through summary or plot functions which display estimated mediation effects for given values of rho.

Usage


medsens(model.m, model.y, T="treat.name", M="med.name", INT=FALSE, DETAIL=FALSE, sims=1000, eps=.Machine$double.eps)

Arguments

model.m R model object for mediator. Can be of class lm or glm using a probit link function.
model.y R model object for outcome. Can be of class lm or glm using a probit link function.
INT If TRUE this indicates that treatment is interacted with mediator in ymodel object. Default is FALSE. Interaction implemented by including a T:M interaction term in the outcome model. This option is currently only available for continuous outcome continuous mediator case.
T Name of binary treatment indicator, 1 for treatment and 0 if control. Variable name listed in quotations.
M Name of mediator. Variable name listed in quotations.
DETAIL If FALSE estimation is on .1 grid for rho (sensitivity parameter) vs. a grid of .01). Due to computational time FALSE is recommended.
sims Number of draws for parametric bootstrap used to calculate 95 percent confidence intervals.
eps Convergence parameter for FGLS estimation.

Details

This is the workhorse function for estimating sensitivity analyses for mediation effects. In fitting models for a binary variable a probit function must be used. In fitting the model.y object with a treatmentXmediator interaction the user must input the interation in the format treatment:mediator. Furthermore, the user must make sure to also include the main effect for the mediator in this case.

Users should note that computation time is several minutes for these functions. Setting DETAIL=TRUE significantly increases computational time, as does increasing the number of simulations.

Value

medsens returns an object of class "medsens". Some of the below elements are not available depending on whether INT is specified as TRUE or FALSE by the user or depending on the type of model fit The function summary is used to obtain a table of the results. The function plot is used to plot the results.

d0 Point estimate for mediation effect under control.
d1 Point estimate for mediation effect under treatment.
upper.d0 Upper confidence interval for mediation effect under control.
lower.d0 Lower confidence interval for mediation effect under control.
upper.d1 Upper confidence interval for mediation effect under treatment.
lower.d1 Lower confidence interval for mediation effect under treatment.
tau Point estimate for total effect.
upper.tau Upper confidence interval for total effect.
lower.tau Lower confidence interval for total effect.
nu Proportion of total effect mediated.
upper.nu Upper confidence interval for proportion mediated.
lower.nu Upper confidence interval for proportion mediated.

Warning

These functions assume that all missing values have been removed from the data set. This can be done using the na.omit() command before the outcome and mediation models are fitted.

Author(s)

Luke Keele, Ohio State University, keele.4@osu.edu , Dustin Tingley, Princeton University, dtingley@princeton.edu, Teppei Yamamoto, Princeton University, tyamamot@princeton.edu, Kosuke Imai, Princeton University, kimai@princeton.edu

References

Imai, Kosuke, Luke Keele and Dustin Tingley (2009) A General Approach to Causal Mediation Analysis. Imai, Kosuke, Luke Keele and Teppei Yamamoto (2009) Identification, Inference, and Sensitivity Analysis for Causal Mediation Effects. Imai, Kosuke, Luke Keele, Dustin Tingley and Teppei Yamamoto (2009) Causal Mediation Analysis in R.

See Also

See also mediate

Examples

 

#Example with JOBS II Field experiment
#For illustration purposes simulations set to low number.

#Example with JOBS II Field experiment
data(jobs)

#########################################
#continuous mediator and continuous outcome
#########################################

#fit parametric model
model.m <- lm(job_seek ~ treat + depress1, data=jobs)
model.y <- lm(depress2 ~ treat + job_seek + depress1, data=jobs)
#pass model objects through medsens function
sens.cont <- medsens(model.m, model.y, T="treat", M="job_seek", INT=FALSE,  DETAIL=FALSE, sims=1000)
#use summary function to display values of rho where 95
summary(sens.cont)
#plot mediation effect and 95
plot(sens.cont, main="JOBS", ylim=c(-.2,.2))

## Not run: 
#########################################
#binary outcome and continuous mediator
#########################################

model.m <- lm(job_seek ~ treat + depress1, data=jobs)
model.y <- glm(work1 ~ treat + job_seek + depress1, family=binomial(link="probit"), data=jobs)
sens.dichO <- medsens(model.m, model.y, T="treat", M="job_seek", INT=FALSE,  DETAIL=FALSE)
summary(sens.dichO)
plot(sens.dichO, main="JOBS", ylim=c(-.2,.2))

#########################################
#continuous outcome and binary mediator w no interaction
#########################################

model.m <- glm(job_dich ~ treat + depress1, data=jobs, family=binomial(link="probit"))
model.y <- lm(depress2 ~ treat + job_dich + depress1, data=jobs)
sens.dichM <- medsens(model.m, model.y, T="treat", M="job_dich", INT=FALSE,  DETAIL=FALSE)
summary(sens.dichM)
plot(sens.dichM, main="JOBS", ylim=c(-.2,.2))

#########################################
#continuous outcome and binary mediator w interaction
#########################################

model.m <- glm(job_dich ~ treat + depress1, data=jobs, family=binomial(link="probit"))
model.y <- lm(depress2 ~ treat + job_dich + treat:job_dich + depress1, data=jobs)
sens.dichM.int <- medsens(model.m, model.y, T="treat", M="job_dich", INT=TRUE,  DETAIL=FALSE)
summary(sens.dichM.int)
plot(sens.dichM.int, main="JOBS", ylim=c(-.2,.2))
## End(Not run)


[Package mediation version 1.0 Index]