19.2 Causal Inference Approach
19.2.1 Example 1
from Virginia’s library
myData <-
read.csv('http://static.lib.virginia.edu/statlab/materials/data/mediationData.csv')
# Step 1 (no longer necessary)
model.0 <- lm(Y ~ X, myData)
summary(model.0)
#>
#> Call:
#> lm(formula = Y ~ X, data = myData)
#>
#> Residuals:
#> Min 1Q Median 3Q Max
#> -5.0262 -1.2340 -0.3282 1.5583 5.1622
#>
#> Coefficients:
#> Estimate Std. Error t value Pr(>|t|)
#> (Intercept) 2.8572 0.6932 4.122 7.88e-05 ***
#> X 0.3961 0.1112 3.564 0.000567 ***
#> ---
#> Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
#>
#> Residual standard error: 1.929 on 98 degrees of freedom
#> Multiple R-squared: 0.1147, Adjusted R-squared: 0.1057
#> F-statistic: 12.7 on 1 and 98 DF, p-value: 0.0005671
# Step 2
model.M <- lm(M ~ X, myData)
summary(model.M)
#>
#> Call:
#> lm(formula = M ~ X, data = myData)
#>
#> Residuals:
#> Min 1Q Median 3Q Max
#> -4.3046 -0.8656 0.1344 1.1344 4.6954
#>
#> Coefficients:
#> Estimate Std. Error t value Pr(>|t|)
#> (Intercept) 1.49952 0.58920 2.545 0.0125 *
#> X 0.56102 0.09448 5.938 4.39e-08 ***
#> ---
#> Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
#>
#> Residual standard error: 1.639 on 98 degrees of freedom
#> Multiple R-squared: 0.2646, Adjusted R-squared: 0.2571
#> F-statistic: 35.26 on 1 and 98 DF, p-value: 4.391e-08
# Step 3
model.Y <- lm(Y ~ X + M, myData)
summary(model.Y)
#>
#> Call:
#> lm(formula = Y ~ X + M, data = myData)
#>
#> Residuals:
#> Min 1Q Median 3Q Max
#> -3.7631 -1.2393 0.0308 1.0832 4.0055
#>
#> Coefficients:
#> Estimate Std. Error t value Pr(>|t|)
#> (Intercept) 1.9043 0.6055 3.145 0.0022 **
#> X 0.0396 0.1096 0.361 0.7187
#> M 0.6355 0.1005 6.321 7.92e-09 ***
#> ---
#> Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
#>
#> Residual standard error: 1.631 on 97 degrees of freedom
#> Multiple R-squared: 0.373, Adjusted R-squared: 0.3601
#> F-statistic: 28.85 on 2 and 97 DF, p-value: 1.471e-10
# Step 4 (boostrapping)
library(mediation)
results <- mediate(
model.M,
model.Y,
treat = 'X',
mediator = 'M',
boot = TRUE,
sims = 500
)
summary(results)
#>
#> Causal Mediation Analysis
#>
#> Nonparametric Bootstrap Confidence Intervals with the Percentile Method
#>
#> Estimate 95% CI Lower 95% CI Upper p-value
#> ACME 0.3565 0.2119 0.51 <2e-16 ***
#> ADE 0.0396 -0.1750 0.28 0.760
#> Total Effect 0.3961 0.1743 0.64 0.004 **
#> Prop. Mediated 0.9000 0.5042 1.94 0.004 **
#> ---
#> Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
#>
#> Sample Size Used: 100
#>
#>
#> Simulations: 500
Total Effect = 0.3961 = b1 (step 1) = total effect of X on Y without M
Direct Effect = ADE = 0.0396 = b4 (step 3) = direct effect of X on Y accounting for the indirect effect of M
ACME = Average Causal Mediation Effects = b1−b4 = 0.3961 - 0.0396 = 0.3565 = b2×b3 = 0.56102 * 0.6355 = 0.3565
Using mediation
package suggested by Imai, Keele, and Yamamoto (2010). More details of the package can be found here
2 types of Inference in this package:
Model-based inference:
Assumptions:
Treatment is randomized (could use matching methods to achieve this).
Sequential Ignorability: conditional on covariates, there is other confounders that affect the relationship between (1) treatment-mediator, (2) treatment-outcome, (3) mediator-outcome. Typically hard to argue in observational data. This assumption is for the identification of ACME (i.e., average causal mediation effects).
Design-based inference
Notations: we stay consistent with package instruction
Mi(t) = mediator
Ti = treatment status (0,1)
Yi(t,m) = outcome where t = treatment, and m = mediating variables.
Xi = vector of observed pre-treatment confounders
Treatment effect (per unit i) = τi=Yi(1,Mi(1))−Yi(0,Mi(0)) which has 2 effects
Causal mediation effects: δi(t)≡Yi(t,Mi(1))−Yi(t,Mi(0))
Direct effects: ζ(t)≡Yi(1,Mi(1))−Yi(0,Mi(0))
summing up to the treatment effect: τi=δi(t)+ζi(1−t)
More on sequential ignorability
{Yi(t′,m),Mi(t)}⊥Ti|Xi=x
Yi(t′,m)⊥Mi(t)|Ti=t,Xi=x
where
0<P(Ti=t|Xi=x)
0<P(Mi=m|Ti=t,Xi=x)
First condition is the standard strong ignorability condition where treatment assignment is random conditional on pre-treatment confounders.
Second condition is stronger where the mediators is also random given the observed treatment and pre-treatment confounders. This condition is satisfied only when there is no unobserved pre-treatment confounders, and post-treatment confounders, and multiple mediators that are correlated.
My understanding is that until the moment I write this note, there is no way to test the sequential ignorability assumption. Hence, researchers can only do sensitivity analysis to argue for their result.