[Mediation-information] possible bug in 'mediation-0.4'

Liviu Andronic landronimirc at gmail.com
Mon Mar 26 11:32:51 CEST 2012


Dear Teppei


On Mon, Mar 26, 2012 at 6:57 AM, Teppei Yamamoto <teppei at mit.edu> wrote:
> The current version of the mediate function uses the bootstrap for the
> construction of percentile confidence intervals, not for bias correction. So
> for the linear models, the point estimate of the mediation effect will be
> exactly the same as the product of coefficients, but the confidence interval
> will slightly differ from the standard one based on the t table.
>
As a user, not as an expert, I find it strange that when estimating
mediation effects via _bootstrapping_, the actual point estimates
being displayed via summary() and plot() are NOT those computed from
the bootstrap estimates.

In v3.1.2:
> require(mediation)
[..]
Version: 3.1.2

##estimate m model
> mod.m <- lm(EFFICACY ~ LEADER + AGE + SEX + DIPLOMA + DEPART + SUPTENURE, indir)
##estimate y model
> mod.y <- lm(CREATIV ~ EFFICACY + LEADER + AGE + SEX + DIPLOMA + DEPART + SUPTENURE, indir)
##supply m and y models for mediation analysis
> med_a <- mediate(mod.m, mod.y, dropobs=T, treat='LEADER', mediator='EFFICACY', boot=T, sims=500)
> summary(med_a)

 Causal Mediation Analysis

Confidence Intervals Based on Nonparametric Bootstrap

Mediation Effect:  0.02796 95 % CI  -0.02251  0.08666
Direct Effect:  0.2015 95 % CI  0.06194 0.35702
Total Effect:  0.2295 95 % CI  0.08975 0.38164
Proportion of Total Effect via Mediation:  0.1214 95 % CI  -0.1174  0.4886

Sample Size Used: 95

> mean(med_a$d0.sims) #boot/acme
[1] 0.02795699
> med_a$d0
[1] 0.02795699


The above summary() seems logical to me, since I computed the
bootstrapped estimates via mediate(..., boot=TRUE), so I was expecting
in the summary() to see the average effect as extracted from the
bootstraps. For what it's worth, this is what the SAS and SPSS macros
[1] (Preacher & Hayes, 2008) report when estimating mediation effects
via bootstrapping:
#Indirect Effects of IV on DV through Proposed Mediators (ab paths)
#             Data      boot      Bias        SE
#EFFICACY     ,0314     ,0270    -,0044     ,0261
#
# Bias Corrected and Accelerated Confidence Intervals
#               Lower     Upper
# EFFICACY    -,0039     ,1089

[1] http://www.afhayes.com/spss-sas-and-mplus-macros-and-code.html


In v4.0, however, the same calls as above will result in different
output (as you explained).
> require(mediation)
[..]
Version: 4.0

> med_a <- mediate(mod.m, mod.y, dropobs=T, treat='LEADER', mediator='EFFICACY', boot=T, sims=500)  ##supply m and y models for mediation analysis
> summary(med_a)

Causal Mediation Analysis

Confidence Intervals Based on Nonparametric Bootstrap

                         Estimate 95% CI Lower 95% CI Upper p-value
Mediation Effect           0.0314      -0.0176       0.0790    0.21
Direct Effect              0.2030       0.0365       0.3853    0.01
Total Effect               0.2345       0.0712       0.3930    0.01
Proportion via Mediation   0.1341      -0.0688       0.5223    0.21

Sample Size Used: 95

> mean(med_a$d0.sims) #boot/acme
[1] 0.02666546
> med_a$d0 #??bug
[1] 0.03143479


Again, not an expert, but this is not what I've been expecting: the
'Estimate 95%' should be '0.0266' instead of '0.0314'. Am I
misunderstanding something? Perhaps the summary() function should also
report the bias-corrected estimate?



> If you do worry about the bias, you can estimate it using the bootstrap
> draws contained in the output (d0.sims, etc) as
>
> d0.bias <- mean(med_a$d0.sim) - med_a$d0


Estimating the above yields:
> (d0.bias <- mean(med_a$d0.sim) - med_a$d0)
[1] -0.004769328


> Then the simplest bias-corrected estimate will be
>
> med_a$d0 - d0.bias


Do you mean '+' in the above? If I do
> med_a$d0 - d0.bias
[1] 0.03620412

However if I do
> med_a$d0 + d0.bias
[1] 0.02666546

then I get the same coefficient as in
> mean(med_a$d0.sims) #boot/acme
[1] 0.02666546


Regards
Liviu


> The previous version of the function computed the estimate differently, but
> it was NOT a bias-corrected estimate.
>


More information about the Mediation-information mailing list