<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=Windows-1252">
<style type="text/css" style="display:none;"><!-- P {margin-top:0;margin-bottom:0;} --></style>
</head>
<body dir="ltr">
<div id="divtagdefaultwrapper" style="font-size:12pt;color:#000000;font-family:Calibri,Helvetica,sans-serif;" dir="ltr">
<p style="margin-right: 0px; margin-left: 0px; font-stretch: normal; font-size: 20px; line-height: normal; font-family: "Helvetica Neue";">
<b>Mediation analysis project using data from a randomised controlled trial</b></p>
<p style="margin-right: 0px; margin-left: 0px; font-stretch: normal; font-size: 13px; line-height: normal; font-family: "Helvetica Neue"; min-height: 15px;">
<br>
</p>
<p style="margin-right: 0px; margin-left: 0px; font-stretch: normal; font-size: 13px; line-height: normal; font-family: "Helvetica Neue";">
Dear Sirs,</p>
<p style="margin-right: 0px; margin-left: 0px; font-stretch: normal; font-size: 13px; line-height: normal; font-family: "Helvetica Neue"; min-height: 15px;">
<br>
</p>
<p style="margin-right: 0px; margin-left: 0px; font-stretch: normal; font-size: 13px; line-height: normal; font-family: "Helvetica Neue";">
For my PhD research, I investigate causal mediation effect using Stata (both medeff and paramed commands). </p>
<p style="margin-right: 0px; margin-left: 0px; font-stretch: normal; font-size: 13px; line-height: normal; font-family: "Helvetica Neue";">
Because of my specific research question, I will likely need to use different types of statistical models. So, I started working with ‘mediate’ function in R, given its flexibility.</p>
<p style="margin-right: 0px; margin-left: 0px; font-stretch: normal; font-size: 13px; line-height: normal; font-family: "Helvetica Neue"; min-height: 15px;">
<br>
</p>
<p style="margin-right: 0px; margin-left: 0px; font-stretch: normal; font-size: 13px; line-height: normal; font-family: "Helvetica Neue";">
Currently, my project uses a binary mediator, outcome and treatment</p>
<p style="margin-right: 0px; margin-left: 0px; font-stretch: normal; font-size: 13px; line-height: normal; font-family: "Helvetica Neue";">
Under the No Interaction (NINT) assumption, the results generated with Stata medeff, Stata paramed and R mediate were pretty consistent. (with the exception that paramed generated odd ratios rather than risk difference). </p>
<p style="margin-right: 0px; margin-left: 0px; font-stretch: normal; font-size: 13px; line-height: normal; font-family: "Helvetica Neue";">
However, when I relaxed the NINT assumption (in my research), the results with Stata commands changed e.g. ADE (treated) decreased from approx. 19 to 6 (and lost significance). </p>
<p style="margin-right: 0px; margin-left: 0px; font-stretch: normal; font-size: 13px; line-height: normal; font-family: "Helvetica Neue";">
Because I wasn’t sure how to interpret this, my idea was to replicate Stata results in R and vice versa.</p>
<p style="margin-right: 0px; margin-left: 0px; font-stretch: normal; font-size: 13px; line-height: normal; font-family: "Helvetica Neue"; min-height: 15px;">
<br>
</p>
<p style="margin-right: 0px; margin-left: 0px; font-stretch: normal; font-size: 13px; line-height: normal; font-family: "Helvetica Neue";">
Starting with the framing example described in jstatsoft “mediation: R Package for Causal Mediation Analysis” (pg. 7-9), I was able to exactly replicate the estimates under the NINT assumption.</p>
<p style="margin-right: 0px; margin-left: 0px; font-stretch: normal; font-size: 13px; line-height: normal; font-family: "Helvetica Neue";">
But when introducing treatment and mediator interaction (pg 9), I was not able to replicate the estimates (significant levels were comparable though). In addition, ADE (control) was negative in below output, vs positive in the paper.</p>
<p style="margin-right: 0px; margin-left: 0px; font-stretch: normal; font-size: 13px; line-height: normal; font-family: "Helvetica Neue";">
I tried different ways, for example setting seed prior to running mediate (this was suggested in one of the previous threads posted).</p>
<p style="margin-right: 0px; margin-left: 0px; font-stretch: normal; font-size: 13px; line-height: normal; font-family: "Helvetica Neue"; min-height: 15px;">
<br>
</p>
<p style="margin-right: 0px; margin-left: 0px; font-stretch: normal; font-size: 13px; line-height: normal; font-family: "Helvetica Neue";">
This may sound like nitpicking. But that is not my intent. My plan is to ensure the causal mediation estimates align (in terms of significance, the direction of effect) regardless of the mediation package. I seem stuck as I am unable to replicate this framing
example in R, so makes no sense to compare it with my Stata output.</p>
<p style="margin-right: 0px; margin-left: 0px; font-stretch: normal; font-size: 13px; line-height: normal; font-family: "Helvetica Neue"; min-height: 15px;">
<br>
</p>
<p style="margin-right: 0px; margin-left: 0px; font-stretch: normal; font-size: 13px; line-height: normal; font-family: "Helvetica Neue";">
I assume I made an error, or overlooked anything? Thank you for your help with my “endeavours”.</p>
<p style="margin-right: 0px; margin-left: 0px; font-stretch: normal; font-size: 13px; line-height: normal; font-family: "Helvetica Neue";">
Benedicte Lescrauwaet</p>
<p style="margin-right: 0px; margin-left: 0px; font-stretch: normal; font-size: 13px; line-height: normal; font-family: "Helvetica Neue";">
PhD candidate University of Gent Belgium</p>
<p style="margin-right: 0px; margin-left: 0px; font-stretch: normal; font-size: 13px; line-height: normal; font-family: "Helvetica Neue";">
benedicte.lescrauwaet@ugent.be</p>
<p style="margin-right: 0px; margin-left: 0px; font-stretch: normal; font-size: 13px; line-height: normal; font-family: "Helvetica Neue"; min-height: 15px;">
<br>
</p>
<p style="margin-right: 0px; margin-left: 0px; font-stretch: normal; font-size: 13px; line-height: normal; font-family: "Helvetica Neue";">
OUTPUT</p>
<p style="margin-right: 0px; margin-left: 0px; font-stretch: normal; font-size: 13px; line-height: normal; font-family: "Helvetica Neue";">
mediation: Causal Mediation Analysis</p>
<p style="margin-right: 0px; margin-left: 0px; font-stretch: normal; font-size: 13px; line-height: normal; font-family: "Helvetica Neue";">
Version: 4.5.0</p>
<p style="margin-right: 0px; margin-left: 0px; font-stretch: normal; font-size: 13px; line-height: normal; font-family: "Helvetica Neue"; min-height: 15px;">
<br>
</p>
<p style="margin-right: 0px; margin-left: 0px; font-stretch: normal; font-size: 13px; line-height: normal; font-family: "Helvetica Neue"; min-height: 15px;">
<br>
</p>
<p style="margin-right: 0px; margin-left: 0px; font-stretch: normal; font-size: 13px; line-height: normal; font-family: "Helvetica Neue";">
> set.seed(2014)</p>
<p style="margin-right: 0px; margin-left: 0px; font-stretch: normal; font-size: 13px; line-height: normal; font-family: "Helvetica Neue";">
> data("framing", package = "mediation")</p>
<p style="margin-right: 0px; margin-left: 0px; font-stretch: normal; font-size: 12px; line-height: normal; font-family: "Courier New";">
/// NINT assumption /// </p>
<p style="margin-right: 0px; margin-left: 0px; font-stretch: normal; font-size: 13px; line-height: normal; font-family: "Helvetica Neue";">
> med.fit <-lm(emo~ treat + age + educ + gender + income, data = framing)</p>
<p style="margin-right: 0px; margin-left: 0px; font-stretch: normal; font-size: 13px; line-height: normal; font-family: "Helvetica Neue";">
> out.fit <- glm(cong_mesg ~ emo + treat + age + educ + gender + income, data=framing, family = binomial("probit"))</p>
<p style="margin-right: 0px; margin-left: 0px; font-stretch: normal; font-size: 13px; line-height: normal; font-family: "Helvetica Neue";">
> med.out <- mediate(med.fit, out.fit, treat = "treat", mediator = "emo", robustSE = TRUE, sims = 100)</p>
<p style="margin-right: 0px; margin-left: 0px; font-stretch: normal; font-size: 13px; line-height: normal; font-family: "Helvetica Neue";">
> summary(med.out)</p>
<p style="margin-right: 0px; margin-left: 0px; font-stretch: normal; font-size: 13px; line-height: normal; font-family: "Helvetica Neue"; min-height: 15px;">
<br>
</p>
<p style="margin-right: 0px; margin-left: 0px; font-stretch: normal; font-size: 12px; line-height: normal; font-family: "Courier New";">
Causal Mediation Analysis </p>
<p style="margin-right: 0px; margin-left: 0px; font-stretch: normal; font-size: 12px; line-height: normal; font-family: "Courier New";">
Quasi-Bayesian Confidence Intervals</p>
<p style="margin-right: 0px; margin-left: 0px; font-stretch: normal; font-size: 12px; line-height: normal; font-family: "Courier New";">
Estimate 95% CI Lower 95% CI Upper p-value </p>
<p style="margin-right: 0px; margin-left: 0px; font-stretch: normal; font-size: 12px; line-height: normal; font-family: "Courier New";">
ACME (control) 0.0791 0.0351 0.15 <2e-16 ***</p>
<p style="margin-right: 0px; margin-left: 0px; font-stretch: normal; font-size: 12px; line-height: normal; font-family: "Courier New";">
ACME (treated) 0.0804 0.0367 0.16 <2e-16 ***</p>
<p style="margin-right: 0px; margin-left: 0px; font-stretch: normal; font-size: 12px; line-height: normal; font-family: "Courier New";">
ADE (control) 0.0206 -0.0976 0.12 0.70 </p>
<p style="margin-right: 0px; margin-left: 0px; font-stretch: normal; font-size: 12px; line-height: normal; font-family: "Courier New";">
ADE (treated) 0.0218 -0.1053 0.12 0.70 </p>
<p style="margin-right: 0px; margin-left: 0px; font-stretch: normal; font-size: 12px; line-height: normal; font-family: "Courier New";">
Total Effect 0.1009 -0.0497 0.23 0.14 </p>
<p style="margin-right: 0px; margin-left: 0px; font-stretch: normal; font-size: 12px; line-height: normal; font-family: "Courier New";">
Prop. Mediated (control) 0.6946 -6.3109 3.68 0.14 </p>
<p style="margin-right: 0px; margin-left: 0px; font-stretch: normal; font-size: 12px; line-height: normal; font-family: "Courier New";">
Prop. Mediated (treated) 0.7118 -5.7936 3.50 0.14 </p>
<p style="margin-right: 0px; margin-left: 0px; font-stretch: normal; font-size: 12px; line-height: normal; font-family: "Courier New";">
ACME (average) 0.0798 0.0359 0.15 <2e-16 ***</p>
<p style="margin-right: 0px; margin-left: 0px; font-stretch: normal; font-size: 12px; line-height: normal; font-family: "Courier New";">
ADE (average) 0.0212 -0.1014 0.12 0.70 </p>
<p style="margin-right: 0px; margin-left: 0px; font-stretch: normal; font-size: 12px; line-height: normal; font-family: "Courier New";">
Prop. Mediated (average) 0.7032 -6.0523 3.59 0.14 </p>
<p style="margin-right: 0px; margin-left: 0px; font-stretch: normal; font-size: 12px; line-height: normal; font-family: "Courier New";">
---</p>
<p style="margin-right: 0px; margin-left: 0px; font-stretch: normal; font-size: 12px; line-height: normal; font-family: "Courier New";">
Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1</p>
<p style="margin-right: 0px; margin-left: 0px; font-stretch: normal; font-size: 12px; line-height: normal; font-family: "Courier New";">
Sample Size Used: 265 </p>
<p style="margin-right: 0px; margin-left: 0px; font-stretch: normal; font-size: 12px; line-height: normal; font-family: "Courier New";">
Simulations: 100 </p>
<p style="margin-right: 0px; margin-left: 0px; font-stretch: normal; font-size: 12px; line-height: normal; font-family: "Courier New"; min-height: 14px;">
<br>
</p>
<p style="margin-right: 0px; margin-left: 0px; font-stretch: normal; font-size: 12px; line-height: normal; font-family: "Courier New";">
/// Relaxing NINT assumption /// </p>
<p style="margin-right: 0px; margin-left: 0px; font-stretch: normal; font-size: 12px; line-height: normal; font-family: "Courier New";">
> med.fit <-lm(emo~ treat + age + educ + gender + income, data = framing)</p>
<p style="margin-right: 0px; margin-left: 0px; font-stretch: normal; font-size: 12px; line-height: normal; font-family: "Courier New";">
> out.fit <- glm(cong_mesg ~ <b>emo * treat</b> + age + educ + gender + income, data=framing, family = binomial("probit"))</p>
<p style="margin-right: 0px; margin-left: 0px; font-stretch: normal; font-size: 12px; line-height: normal; font-family: "Courier New";">
> med.out <- mediate(med.fit, out.fit, treat = "treat", mediator = "emo", robustSE = TRUE, sims = 100)</p>
<p style="margin-right: 0px; margin-left: 0px; font-stretch: normal; font-size: 12px; line-height: normal; font-family: "Courier New";">
> summary(med.out)</p>
<p style="margin-right: 0px; margin-left: 0px; font-stretch: normal; font-size: 12px; line-height: normal; font-family: "Courier New"; min-height: 14px;">
<br>
</p>
<p style="margin-right: 0px; margin-left: 0px; font-stretch: normal; font-size: 12px; line-height: normal; font-family: "Courier New";">
Causal Mediation Analysis </p>
<p style="margin-right: 0px; margin-left: 0px; font-stretch: normal; font-size: 12px; line-height: normal; font-family: "Courier New";">
Quasi-Bayesian Confidence Intervals</p>
<p style="margin-right: 0px; margin-left: 0px; font-stretch: normal; font-size: 12px; line-height: normal; font-family: "Courier New";">
Estimate 95% CI Lower 95% CI Upper p-value </p>
<p style="margin-right: 0px; margin-left: 0px; font-stretch: normal; font-size: 12px; line-height: normal; font-family: "Courier New";">
ACME (control) 0.076168 0.034648 0.13 <2e-16 ***</p>
<p style="margin-right: 0px; margin-left: 0px; font-stretch: normal; font-size: 12px; line-height: normal; font-family: "Courier New";">
ACME (treated) 0.099377 0.037170 0.17 <2e-16 ***</p>
<p style="margin-right: 0px; margin-left: 0px; font-stretch: normal; font-size: 12px; line-height: normal; font-family: "Courier New";">
ADE (control) -0.000209 -0.129077 0.10 0.96 </p>
<p style="margin-right: 0px; margin-left: 0px; font-stretch: normal; font-size: 12px; line-height: normal; font-family: "Courier New";">
ADE (treated) 0.023000 -0.108593 0.15 0.76 </p>
<p style="margin-right: 0px; margin-left: 0px; font-stretch: normal; font-size: 12px; line-height: normal; font-family: "Courier New";">
Total Effect 0.099168 -0.031926 0.22 0.12 </p>
<p style="margin-right: 0px; margin-left: 0px; font-stretch: normal; font-size: 12px; line-height: normal; font-family: "Courier New";">
Prop. Mediated (control) 0.648575 -2.341819 11.02 0.12 </p>
<p style="margin-right: 0px; margin-left: 0px; font-stretch: normal; font-size: 12px; line-height: normal; font-family: "Courier New";">
Prop. Mediated (treated) 0.871007 -3.071536 13.97 0.12 </p>
<p style="margin-right: 0px; margin-left: 0px; font-stretch: normal; font-size: 12px; line-height: normal; font-family: "Courier New";">
ACME (average) 0.087773 0.038951 0.15 <2e-16 ***</p>
<p style="margin-right: 0px; margin-left: 0px; font-stretch: normal; font-size: 12px; line-height: normal; font-family: "Courier New";">
ADE (average) 0.011396 -0.114601 0.11 0.82 </p>
<p style="margin-right: 0px; margin-left: 0px; font-stretch: normal; font-size: 12px; line-height: normal; font-family: "Courier New";">
Prop. Mediated (average) 0.759791 -2.583546 12.49 0.12 </p>
<p style="margin-right: 0px; margin-left: 0px; font-stretch: normal; font-size: 12px; line-height: normal; font-family: "Courier New";">
---</p>
<p style="margin-right: 0px; margin-left: 0px; font-stretch: normal; font-size: 12px; line-height: normal; font-family: "Courier New";">
Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1</p>
<p style="margin-right: 0px; margin-left: 0px; font-stretch: normal; font-size: 12px; line-height: normal; font-family: "Courier New";">
Sample Size Used: 265 </p>
<p style="margin-right: 0px; margin-left: 0px; font-stretch: normal; font-size: 12px; line-height: normal; font-family: "Courier New";">
Simulations: 100 </p>
<p style="margin-right: 0px; margin-left: 0px; font-stretch: normal; font-size: 12px; line-height: normal; font-family: "Courier New"; min-height: 14px;">
<br>
</p>
<p style="margin-right: 0px; margin-left: 0px; font-stretch: normal; font-size: 12px; line-height: normal; font-family: "Courier New"; min-height: 14px;">
<br>
</p>
<p style="margin-right: 0px; margin-left: 0px; font-stretch: normal; font-size: 12px; line-height: normal; font-family: "Courier New";">
/// Relaxing NINT assumption and introducing set.seed prior to mediate///</p>
<p style="margin-right: 0px; margin-left: 0px; font-stretch: normal; font-size: 12px; line-height: normal; font-family: "Courier New";">
> med.fit <-lm(emo~ treat + age + educ + gender + income, data = framing)</p>
<p style="margin-right: 0px; margin-left: 0px; font-stretch: normal; font-size: 12px; line-height: normal; font-family: "Courier New";">
> out.fit <- glm(cong_mesg ~ emo * treat + age + educ + gender + income, data=framing, family = binomial("probit"))</p>
<p style="margin-right: 0px; margin-left: 0px; font-stretch: normal; font-size: 12px; line-height: normal; font-family: "Courier New";">
<b>> set.seed(2014)</b></p>
<p style="margin-right: 0px; margin-left: 0px; font-stretch: normal; font-size: 12px; line-height: normal; font-family: "Courier New";">
> med.out <- mediate(med.fit, out.fit, treat = "treat", mediator = "emo", robustSE = TRUE, sims = 100)</p>
<p style="margin-right: 0px; margin-left: 0px; font-stretch: normal; font-size: 12px; line-height: normal; font-family: "Courier New";">
> summary(med.out)</p>
<p style="margin-right: 0px; margin-left: 0px; font-stretch: normal; font-size: 12px; line-height: normal; font-family: "Courier New"; min-height: 14px;">
<br>
</p>
<p style="margin-right: 0px; margin-left: 0px; font-stretch: normal; font-size: 12px; line-height: normal; font-family: "Courier New";">
Causal Mediation Analysis </p>
<p style="margin-right: 0px; margin-left: 0px; font-stretch: normal; font-size: 12px; line-height: normal; font-family: "Courier New";">
Quasi-Bayesian Confidence Intervals</p>
<p style="margin-right: 0px; margin-left: 0px; font-stretch: normal; font-size: 12px; line-height: normal; font-family: "Courier New";">
Estimate 95% CI Lower 95% CI Upper p-value </p>
<p style="margin-right: 0px; margin-left: 0px; font-stretch: normal; font-size: 12px; line-height: normal; font-family: "Courier New";">
ACME (control) 0.07724 0.02967 0.15 <2e-16 ***</p>
<p style="margin-right: 0px; margin-left: 0px; font-stretch: normal; font-size: 12px; line-height: normal; font-family: "Courier New";">
ACME (treated) 0.09698 0.04396 0.18 <2e-16 ***</p>
<p style="margin-right: 0px; margin-left: 0px; font-stretch: normal; font-size: 12px; line-height: normal; font-family: "Courier New";">
ADE (control) -0.00785 -0.11271 0.10 0.84 </p>
<p style="margin-right: 0px; margin-left: 0px; font-stretch: normal; font-size: 12px; line-height: normal; font-family: "Courier New";">
ADE (treated) 0.01189 -0.10190 0.16 0.90 </p>
<p style="margin-right: 0px; margin-left: 0px; font-stretch: normal; font-size: 12px; line-height: normal; font-family: "Courier New";">
Total Effect 0.08913 -0.03616 0.21 0.28 </p>
<p style="margin-right: 0px; margin-left: 0px; font-stretch: normal; font-size: 12px; line-height: normal; font-family: "Courier New";">
Prop. Mediated (control) 0.66249 -8.39598 6.99 0.28 </p>
<p style="margin-right: 0px; margin-left: 0px; font-stretch: normal; font-size: 12px; line-height: normal; font-family: "Courier New";">
Prop. Mediated (treated) 0.86221 -11.28999 7.74 0.28 </p>
<p style="margin-right: 0px; margin-left: 0px; font-stretch: normal; font-size: 12px; line-height: normal; font-family: "Courier New";">
ACME (average) 0.08711 0.03747 0.17 <2e-16 ***</p>
<p style="margin-right: 0px; margin-left: 0px; font-stretch: normal; font-size: 12px; line-height: normal; font-family: "Courier New";">
ADE (average) 0.00202 -0.10271 0.13 0.98 </p>
<p style="margin-right: 0px; margin-left: 0px; font-stretch: normal; font-size: 12px; line-height: normal; font-family: "Courier New";">
Prop. Mediated (average) 0.76235 -10.18858 7.36 0.28 </p>
<p style="margin-right: 0px; margin-left: 0px; font-stretch: normal; font-size: 12px; line-height: normal; font-family: "Courier New";">
---</p>
<p style="margin-right: 0px; margin-left: 0px; font-stretch: normal; font-size: 12px; line-height: normal; font-family: "Courier New";">
Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1</p>
<p style="margin-right: 0px; margin-left: 0px; font-stretch: normal; font-size: 12px; line-height: normal; font-family: "Courier New";">
Sample Size Used: 265 </p>
<p style="margin-right: 0px; margin-left: 0px; font-stretch: normal; font-size: 12px; line-height: normal; font-family: "Courier New";">
Simulations: 100 </p>
<div><br>
</div>
</div>
</body>
</html>