Causal mediation analysis: Estimation of effects for the single … · 2018-08-29 · Causal...

Preview:

Citation preview

Causal mediation analysis: Estimation of effectsfor the single mediator case

Trang Quynh Nguyen

Seminar on Statistical Methods for Mental Health ResearchJohns Hopkins Bloomberg School of Public Health

330.805.01 term 4 session 2 - April 7, 2016

1 / 53

Session overview

I Finish session 1

I Estimation methods for the single mediator caseI cases

I continuous outcome, with mediator of several kinds (continuous,binary/categorical, ordinal, or latent continuous)

I binary outcome, targeting effects on different scales (RD, RR, OR)that are marginal or conditional

I methods based on modeling the mediator and the outcomeI regression with analytical resultsI regression-based simulation

I next sessionI methods based on other combinations of modelsI survival outcome

2 / 53

Session 1: Definition of causal effects

Total effect (TEi ):

Yi (0)Yi (0,M(0))

−→ Yi (1)Yi (1,M(1))

TE decomposition 1: TEi = NDEi (·0) + NIEi (1·):

Yi (0,M(0)) −→ Yi (1,M(0)) −→ Yi (1,M(1))

TE decomposition 2: TEi = NIEi (0·) + NDEi (·1):

Yi (0,M(0)) −→ Yi (0,M(1)) −→ Yi (1,M(1))

Controlled direct effect (CDEi (m)):

Yi (0,m) −→ Yi (1,m)

3 / 53

Session 1: Definition of causal effects

Total effect (TE):

E[Y0]E[Y0M0 ]

−→ E[Y1]E[Y1M1 ]

TE decomposition 1: TE = NDE(·0) + NIE(1·):

E[Y0M0 ] −→ E[Y 1M0 ] −→ E[Y1M1 ]

TE decomposition 2: TE = NIE(0·) + NDE(·1):

E[Y0M0 ] −→ E[Y 0M1 ] −→ E[Y1M1 ]

Controlled direct effect (CDE(m)):

E[Y 0m] −→ E[Y 1m]

4 / 53

Session 1: Identification assumptions

Conditional sequential ignorability assumptions (Imai et al., 2010)

X : a set of measured pre-treatment covariates

i1. ignorability of treatment assigned: {Yt′m,Mt} ⊥ T |Xi2. ignorability of potential mediators: Yt′m ⊥ Mt |T ,X

Confounding assumptions (VanderWeele & Vansteelandt’s version)

C : a set of measured covariates

c1. no uncontrolled exposure-outcome confounding: Ytm ⊥ T |Cc2. no uncontrolled mediator-outcome confounding: Ytm ⊥ M|T ,C

c3. no uncontrolled exposure-mediator confounding: Mt ⊥ T |Cc4. no mediator-outcome confounder affected by exposure (L)

c1 + c3 = i1 c2 + c4 ≈ i2

5 / 53

Session 1: Identification assumptions

𝑀

𝑌 𝑇

𝑋1

𝑋3 i1

TE()

6 / 53

Session 1: Identification assumptions

𝑀

𝑌 𝑇

𝑋2 i2 𝐿

TE()

6 / 53

Session 1: Identification assumptions

𝑀

𝑌 𝑇

𝑋1

c1

TE()

6 / 53

Session 1: Identification assumptions

𝑀

𝑌 𝑇

𝑋2 𝐿 c2

TE()

6 / 53

Session 1: Identification assumptions

𝑀

𝑌 𝑇

𝑋3 c3

TE()

6 / 53

Session 1: Identification assumptions

𝑀

𝑌 𝑇

𝐿 c4

TE()

6 / 53

Session 1: Identification assumptions

𝑀

𝑌 𝑇

𝑋1

𝑋2 𝑋3 𝐿

i1-2 c1-4

TE()

6 / 53

Session 1: Identification assumptions

𝑀

𝑌 𝑇

𝑋1

𝑋2 𝑋3 𝐿

i1-2 c1-4

NDE and NIE require all c1-c4 (or i1-i2). CDE requires c1-c2.

6 / 53

Session 1: Identification assumptions

Pearl points out (Pearl, 2014)

I X (1),X (2),X (3) deconfound instead of are confoundersI X (1),X (2),X (3) do not need to be pre-exposure, just not influenced

by exposure

I can replace i1 (or c1+c3) by other ways of identifying Mt , Yt′m

7 / 53

Session 1: Identification intuition

Consider person i with Ti = 1.

Observe: Mi (1) = Mi = m∗ and Yi (1) = Yi (1,Mi (1)) = Yi (1,m∗) = Yi = y∗.

For NDE(·0) and NIE(1·), need Yi (0,Mi (0)) and Yi (1,Mi (0)).

1 step to Yi (0,Mi (0)):I under c1 (no uncontrolled T -Y confounding),

Yi (0,Mi (0)) is informed by the outcomes of persons j in the control conditionwho have the same values for covariates X (1): Yj = Yj (0,Mj (0))

⇒ Yi (0,Mi (0)) = y∗∗

2 steps to Yi (1,Mi (0)):I under c3 (no uncontrolled T -M confounding),

Mi (0) is informed by the mediator values of persons k in the control conditionwho have the same values for covariates X (3): Mk = Mk(0)

⇒ Mi (0) = m∗∗

I under c2+c4 (no uncontrolled M-Y confounding + no M-Y confounder affectedby T ),Yi (1,Mi (0)) is informed by the outcomes of persons l in the treatment conditionwho have the same values for covariates X (2) and whose mediator value is m∗∗:Yl = Yl (1,Ml (1)) = Yl (1,m∗∗)

⇒ Yi (1,Mi (0)) = y∗∗∗

8 / 53

Session 1: Identification intuition

Consider person i with Ti = 1.

Observe: Mi (1) = Mi = m∗ and Yi (1) = Yi (1,Mi (1)) = Yi (1,m∗) = Yi = y∗.

For NDE(·0) and NIE(1·), need Yi (0,Mi (0)) and Yi (1,Mi (0)).

1 step to Yi (0,Mi (0)):I under c1 (no uncontrolled T -Y confounding),

Yi (0,Mi (0)) is informed by the outcomes of persons j in the control conditionwho have the same values for covariates X (1): Yj = Yj (0,Mj (0))

⇒ Yi (0,Mi (0)) = y∗∗

2 steps to Yi (1,Mi (0)):I under c3 (no uncontrolled T -M confounding),

Mi (0) is informed by the mediator values of persons k in the control conditionwho have the same values for covariates X (3): Mk = Mk(0)

⇒ Mi (0) = m∗∗

I under c2+c4 (no uncontrolled M-Y confounding + no M-Y confounder affectedby T ),Yi (1,Mi (0)) is informed by the outcomes of persons l in the treatment conditionwho have the same values for covariates X (2) and whose mediator value is m∗∗:Yl = Yl (1,Ml (1)) = Yl (1,m∗∗)

⇒ Yi (1,Mi (0)) = y∗∗∗

8 / 53

Session 1: Identification intuition

Consider person i with Ti = 1.

Observe: Mi (1) = Mi = m∗ and Yi (1) = Yi (1,Mi (1)) = Yi (1,m∗) = Yi = y∗.

For NDE(·0) and NIE(1·), need Yi (0,Mi (0)) and Yi (1,Mi (0)).

1 step to Yi (0,Mi (0)):I under c1 (no uncontrolled T -Y confounding),

Yi (0,Mi (0)) is informed by the outcomes of persons j in the control conditionwho have the same values for covariates X (1): Yj = Yj (0,Mj (0))

⇒ Yi (0,Mi (0)) = y∗∗

2 steps to Yi (1,Mi (0)):I under c3 (no uncontrolled T -M confounding),

Mi (0) is informed by the mediator values of persons k in the control conditionwho have the same values for covariates X (3): Mk = Mk (0)

⇒ Mi (0) = m∗∗

I under c2+c4 (no uncontrolled M-Y confounding + no M-Y confounder affectedby T ),Yi (1,Mi (0)) is informed by the outcomes of persons l in the treatment conditionwho have the same values for covariates X (2) and whose mediator value is m∗∗:Yl = Yl (1,Ml (1)) = Yl (1,m∗∗)

⇒ Yi (1,Mi (0)) = y∗∗∗

8 / 53

Session 1: Identification intuition

Consider person i with Ti = 1.

Observe: Mi (1) = Mi = m∗ and Yi (1) = Yi (1,Mi (1)) = Yi (1,m∗) = Yi = y∗.

For NDE(·0) and NIE(1·), need Yi (0,Mi (0)) and Yi (1,Mi (0)).

1 step to Yi (0,Mi (0)):I under c1 (no uncontrolled T -Y confounding),

Yi (0,Mi (0)) is informed by the outcomes of persons j in the control conditionwho have the same values for covariates X (1): Yj = Yj (0,Mj (0))

⇒ Yi (0,Mi (0)) = y∗∗

2 steps to Yi (1,Mi (0)):I under c3 (no uncontrolled T -M confounding),

Mi (0) is informed by the mediator values of persons k in the control conditionwho have the same values for covariates X (3): Mk = Mk (0)

⇒ Mi (0) = m∗∗

I under c2+c4 (no uncontrolled M-Y confounding + no M-Y confounder affectedby T ),Yi (1,Mi (0)) is informed by the outcomes of persons l in the treatment conditionwho have the same values for covariates X (2) and whose mediator value is m∗∗:Yl = Yl (1,Ml (1)) = Yl (1,m∗∗)

⇒ Yi (1,Mi (0)) = y∗∗∗

8 / 53

Session 1: NDE/NIE identification – the mediation formula

Assume {i1,i2}/{c1-c4} and consider

TE = E[Y1M1 ]− E[Y0M0 ]

NDE(·0) = E[Y 1M0 ]− E[Y0M0 ]

NIE(1·) = E[Y1M1 ]− E[Y 1M0 ]

Imai et al.’s theorem about identification of E[YtMt′ ]:

in the simplified case with no X :

E[Y1M1 ] = E[Y |T = 1] =∑m

E[Y |T = 1,M = m]P(M = m|T = 1)

E[Y0M0 ]= E[Y |T = 0] =∑m

E[Y |T = 0,M = m]P(M = m|T = 0)

E[Y1M0 ] =∑m

E[Y |T = 1,M = m]P(M = m|T = 0)

9 / 53

Session 1: NDE/NIE identification – the mediation formula

Assume {i1,i2}/{c1-c4} and consider

TE = E[Y1M1 ]− E[Y0M0 ]

NDE(·0) = E[Y 1M0 ]− E[Y0M0 ]

NIE(1·) = E[Y1M1 ]− E[Y 1M0 ]

Imai et al.’s theorem about identification of E[YtMt′ ]:

in the simplified case with no X :

E[Y1M1 ] = E[Y |T = 1] =∑m

E[Y |T = 1,M = m]P(M = m|T = 1)

E[Y0M0 ] = E[Y |T = 0] =∑m

E[Y |T = 0,M = m]P(M = m|T = 0)

E[Y1M0 ] =∑m

E[Y |T = 1,M = m]P(M = m|T = 0)

9 / 53

Session 1: NDE/NIE identification – the mediation formula

Assume {i1,i2}/{c1-c4} and consider

TE = E[Y1M1 ]− E[Y0M0 ]

NDE(·0) = E[Y 1M0 ]− E[Y0M0 ]

NIE(1·) = E[Y1M1 ]− E[Y 1M0 ]

Imai et al.’s theorem about identification of E[YtMt′ ]:

in the simplified case with no X :

E[Y1M1 ] = E[Y |T = 1] =∑m

E[Y |T = 1,M = m]P(M = m|T = 1)

E[Y0M0 ] = E[Y |T = 0] =∑m

E[Y |T = 0,M = m]P(M = m|T = 0)

E[Y 1M0 ] =∑m

E[Y |T = 1,M = m]P(M = m|T = 0)

9 / 53

Session 1: NDE/NIE identification – the mediation formula

Assume {i1,i2}/{c1-c4} and consider

TE = E[Y1M1 ]− E[Y0M0 ]

NDE(·0) = E[Y 1M0 ]− E[Y0M0 ]

NIE(1·) = E[Y1M1 ]− E[Y 1M0 ]

Imai et al.’s theorem about identification of E[YtMt′ ]:

in the realistic case with X :

E[Y1M1 ] =∑x

∑m

E[Y |T = 1,M = m,X = x ]P(M = m|T = 1,X = x)P(X = x)

E[Y0M0 ] =∑x

∑m

E[Y |T = 0,M = m,X = x ]P(M = m|T = 0,X = x)P(X = x)

E[Y 1M0 ] =∑x

∑m

E[Y |T = 1,M = m,X = x ]P(M = m|T = 0,X = x)P(X = x)

10 / 53

Session 1: NDE/NIE identification – the mediation formula

Pearl’s (2011, 2012) causal mediation formula follows

NDE(0) = E[Y 1M0 ]− E[Y0M0 ]

=∑x

∑m

{E[Y |T = 1,M = m,X = x ]−E[Y |T = 0,M = m,X = x ]

}P(M = m|T = 0,X = x)P(X = x)

NIE(1) = E[Y1M1 ]− E[Y 1M0 ]

=∑x

∑m

E[Y |T = 1,M = m,X = x ]

[P(M = m|T = 1,X = x)−P(M = m|T = 0,X = x)

]P(X = x)

11 / 53

Session 1: Complex TE decompositions (so you know)

3-way (VanderWeele 2013)

TE = NDE(·0) + NIE(1·)= NDE(·0) + NIE(0·) + [NIE(1·)− NIE(0·)]

= NDE(·0) + NIE(0·) + INT

= PDE + PIE + INT (just switching names)

4-way using a reference mediator value (VanderWeele 2014)

TE = NDE(·0) + NIE(0·) + [NIE(1·)− NIE(0·)]

= CDE(mref) + [NDE(·0)− CDE(mref)] + NIE(0·) + [NIE(1·)− NIE(0·)]

= CDE(mref) + INTref + NIE(0·) + INTmed

= CDE(mref) + INTref + PIE + INTmed (just switching names)

mref should be a meaningful zero value, e.g., no bullying.

12 / 53

Session 1: References cited

Baron RM, Kenny DA. (1986) The moderator-mediator variable distinction in social psychological research: Conceptual, strategic, andstatistical considerations. Journal of Personality and Social Psychology, 51(6):1173-1182.

Imai K, Keele L, Tingley D. (2010). A general approach to causal mediation analysis. Psychological Methods, 15(4):309-34.

Judd CM, Kenny DA. (1981). Process analysis: Estimating mediation in treatment evaluations. Evaluation Review, 5(5):602-619.

Pearl J. (2001). Direct and Indirect Effects. In: Proceedings of the Seventeenth Conference on Uncertainty and Artificial Intelligence. SanFrancisco: Morgan Kaufmann, 411-420.

Pearl J. (2011). The mediation formula: A guide to the as- sessment of causal pathways in non-linear models. In C Berzuini, P Dawid, LBernardinelli (Eds.), Causal inference: Statistical perspectives and applications. Chichester, England: Wiley.

Pearl J. (2012) The causal mediation formula–a guide to the assessment of pathways and mechanisms. Prevention Science, 13(4):426-36.

Pearl J. (2014). Interpretation and Identification of Causal Mediation. Psychological Methods, 19(4):459-481.

Robins JM, Greenland S. (1992). Identifiability and exchangeability for direct and indirect effects. Epidemiology, 3(2):143-155.

VanderWeele TJ. (2013). A three-way decomposition of a total effect into direct, indirect, and interactive effects. Epidemiology,24(2):224-232.

VanderWeele TJ. (2014). A unification of mediation and interaction: A 4-way decomposition. Epidemiology, 25(5):749-61.

VanderWeele TJ, Vansteelandt S. (2009). Conceptual issues concerning mediation, interventions and composition. Statistics and ItsInterface, 2:457-468.

Wright S. (1934). The method of path coefficients. The Annals of Mathematical Statistics, 5(3):161-215.

13 / 53

Session overview

I Finish session 1

I Estimation methods for the single mediator caseI cases

I continuous outcome, with mediator of several kinds (continuous,binary/categorical, ordinal, or latent continuous)

I binary outcome, targeting effects on different scales (RD, RR, OR)that are marginal or conditional

I methods based on modeling the mediator and the outcomeI regression with analytical resultsI regression-based simulation

I next sessionI methods based on other combinations of modelsI survival outcome

14 / 53

ESTIMATION FOR THE SINGLE MEDIATOR CASE

The mediation formula suggests a model for the mediator and a model for theoutcome. This is the prominent approach.

The specific methods depend on

I what type of variables the mediator and outcome are

I what models we want to use for them

I for non-continuous outcome, how we define the causal effects

15 / 53

CONTINUOUS OUTCOME

We will use the most simple case with

a continuous outcome and a continuous mediator

to discuss estimation strategies.

These strategies apply to other cases as well.

DISCLAIMER: I have not tested any of the code, so please read documentation

carefully. And please let me know you find any errors.

16 / 53

Continuous outcome and continuous mediator –linear regression with analytic results (all 3 session 1 readings)

Assume linear models for the potential mediators and potential outcomes(here allowing treatment-mediator interaction):

Mi (t) = α0 + α1t + α2Xi + εMi,t

Yi (t,m) = β0 + β1t + β2m + β3tm + β4Xi + εYi,t,m

Under identifying assumptions, estimate parameters using regression models:

E[M|T = t,X = x] = α0 + α1t + α2x

E[Y |T = t,M = m,X = x] = β0 + β1t + β2m + β3tm + β4x

The second model provides controlled direct effects:

CDE(m) = E[Y 1m]− E[Y 0m] = (β1 + β3m)(1− 0)

The two models combined provide conditional mean potential outcomes:

E[YtMt′|X = x] = β0 + β1t + (β2 + β3t)(α0 + α1t

′ + α2x) + α4x

Conditional natural direct and indirect effects:

NDE(·t|X = x) = E[Y1Mt − Y0Mt |X = x] = [β1 + β3(α0 + α1t + α2x)](1− 0)

NIE(t · |X = x) = E[YtM1− YtM0

|X = x] = (β2 + β3t)α1(1− 0)

Marginal natural direct and indirect effects:

NDE(·t) = E[Y1Mt ]− E[Y0Mt ] = [β1 + β3(α0 + α1t + α2EX )](1− 0)

NIE(t·) = E[YtM1]− E[YtM0

] = (β2 + β3t)α1(1− 0)

If no interaction, NIE = CDE, and results agree with Baron and Kenny’s results.

17 / 53

Continuous outcome and continuous mediator –linear regression with analytic results (all 3 session 1 readings)

Assume linear models for the potential mediators and potential outcomes(here allowing treatment-mediator interaction):

Mi (t) = α0 + α1t + α2Xi + εMi,t

Yi (t,m) = β0 + β1t + β2m + β3tm + β4Xi + εYi,t,m

Under identifying assumptions, estimate parameters using regression models:

E[M|T = t,X = x] = α0 + α1t + α2x

E[Y |T = t,M = m,X = x] = β0 + β1t + β2m + β3tm + β4x

The second model provides controlled direct effects:

CDE(m) = E[Y 1m]− E[Y 0m] = (β1 + β3m)(1− 0)

The two models combined provide conditional mean potential outcomes:

E[YtMt′|X = x] = β0 + β1t + (β2 + β3t)(α0 + α1t

′ + α2x) + α4x

Conditional natural direct and indirect effects:

NDE(·t|X = x) = E[Y1Mt − Y0Mt |X = x] = [β1 + β3(α0 + α1t + α2x)](1− 0)

NIE(t · |X = x) = E[YtM1− YtM0

|X = x] = (β2 + β3t)α1(1− 0)

Marginal natural direct and indirect effects:

NDE(·t) = E[Y1Mt ]− E[Y0Mt ] = [β1 + β3(α0 + α1t + α2EX )](1− 0)

NIE(t·) = E[YtM1]− E[YtM0

] = (β2 + β3t)α1(1− 0)

If no interaction, NIE = CDE, and results agree with Baron and Kenny’s results.

17 / 53

Continuous outcome and continuous mediator –linear regression with analytic results (all 3 session 1 readings)

Assume linear models for the potential mediators and potential outcomes(here allowing treatment-mediator interaction):

Mi (t) = α0 + α1t + α2Xi + εMi,t

Yi (t,m) = β0 + β1t + β2m + β3tm + β4Xi + εYi,t,m

Under identifying assumptions, estimate parameters using regression models:

E[M|T = t,X = x] = α0 + α1t + α2x

E[Y |T = t,M = m,X = x] = β0 + β1t + β2m + β3tm + β4x

The second model provides controlled direct effects:

CDE(m) = E[Y 1m]− E[Y 0m] = (β1 + β3m)(1− 0)

The two models combined provide conditional mean potential outcomes:

E[YtMt′|X = x] = β0 + β1t + (β2 + β3t)(α0 + α1t

′ + α2x) + α4x

Conditional natural direct and indirect effects:

NDE(·t|X = x) = E[Y1Mt − Y0Mt |X = x] = [β1 + β3(α0 + α1t + α2x)](1− 0)

NIE(t · |X = x) = E[YtM1− YtM0

|X = x] = (β2 + β3t)α1(1− 0)

Marginal natural direct and indirect effects:

NDE(·t) = E[Y1Mt ]− E[Y0Mt ] = [β1 + β3(α0 + α1t + α2EX )](1− 0)

NIE(t·) = E[YtM1]− E[YtM0

] = (β2 + β3t)α1(1− 0)

If no interaction, NIE = CDE, and results agree with Baron and Kenny’s results.

17 / 53

Continuous outcome and continuous mediator –linear regression with analytic results (all 3 session 1 readings)

Assume linear models for the potential mediators and potential outcomes(here allowing treatment-mediator interaction):

Mi (t) = α0 + α1t + α2Xi + εMi,t

Yi (t,m) = β0 + β1t + β2m + β3tm + β4Xi + εYi,t,m

Under identifying assumptions, estimate parameters using regression models:

E[M|T = t,X = x] = α0 + α1t + α2x

E[Y |T = t,M = m,X = x] = β0 + β1t + β2m + β3tm + β4x

The second model provides controlled direct effects:

CDE(m) = E[Y 1m]− E[Y 0m] = (β1 + β3m)(1− 0)

The two models combined provide conditional mean potential outcomes:

E[YtMt′|X = x] = β0 + β1t + (β2 + β3t)(α0 + α1t

′ + α2x) + α4x

Conditional natural direct and indirect effects:

NDE(·t|X = x) = E[Y1Mt − Y0Mt |X = x] = [β1 + β3(α0 + α1t + α2x)](1− 0)

NIE(t · |X = x) = E[YtM1− YtM0

|X = x] = (β2 + β3t)α1(1− 0)

Marginal natural direct and indirect effects:

NDE(·t) = E[Y1Mt ]− E[Y0Mt ] = [β1 + β3(α0 + α1t + α2EX )](1− 0)

NIE(t·) = E[YtM1]− E[YtM0

] = (β2 + β3t)α1(1− 0)

If no interaction, NIE = CDE, and results agree with Baron and Kenny’s results.

17 / 53

Continuous outcome and continuous mediator –linear regression with analytic results (all 3 session 1 readings)

Assume linear models for the potential mediators and potential outcomes(here allowing treatment-mediator interaction):

Mi (t) = α0 + α1t + α2Xi + εMi,t

Yi (t,m) = β0 + β1t + β2m + β3tm + β4Xi + εYi,t,m

Under identifying assumptions, estimate parameters using regression models:

E[M|T = t,X = x] = α0 + α1t + α2x

E[Y |T = t,M = m,X = x] = β0 + β1t + β2m + β3tm + β4x

The second model provides controlled direct effects:

CDE(m) = E[Y 1m]− E[Y 0m] = (β1 + β3m)(1− 0)

The two models combined provide conditional mean potential outcomes:

E[YtMt′|X = x] = β0 + β1t + (β2 + β3t)(α0 + α1t

′ + α2x) + α4x

Conditional natural direct and indirect effects:

NDE(·t|X = x) = E[Y1Mt − Y0Mt |X = x] = [β1 + β3(α0 + α1t + α2x)](1− 0)

NIE(t · |X = x) = E[YtM1− YtM0

|X = x] = (β2 + β3t)α1(1− 0)

Marginal natural direct and indirect effects:

NDE(·t) = E[Y1Mt ]− E[Y0Mt ] = [β1 + β3(α0 + α1t + α2EX )](1− 0)

NIE(t·) = E[YtM1]− E[YtM0

] = (β2 + β3t)α1(1− 0)

If no interaction, NIE = CDE, and results agree with Baron and Kenny’s results.

17 / 53

Continuous outcome and continuous mediator –linear regression with analytic results (all 3 session 1 readings)

Assume linear models for the potential mediators and potential outcomes(here allowing treatment-mediator interaction):

Mi (t) = α0 + α1t + α2Xi + εMi,t

Yi (t,m) = β0 + β1t + β2m + β3tm + β4Xi + εYi,t,m

Under identifying assumptions, estimate parameters using regression models:

E[M|T = t,X = x] = α0 + α1t + α2x

E[Y |T = t,M = m,X = x] = β0 + β1t + β2m + β3tm + β4x

The second model provides controlled direct effects:

CDE(m) = E[Y 1m]− E[Y 0m] = (β1 + β3m)(1− 0)

The two models combined provide conditional mean potential outcomes:

E[YtMt′|X = x] = β0 + β1t + (β2 + β3t)(α0 + α1t

′ + α2x) + α4x

Conditional natural direct and indirect effects:

NDE(·t|X = x) = E[Y1Mt − Y0Mt |X = x] = [β1 + β3(α0 + α1t + α2x)](1− 0)

NIE(t · |X = x) = E[YtM1− YtM0

|X = x] = (β2 + β3t)α1(1− 0)

Marginal natural direct and indirect effects:

NDE(·t) = E[Y1Mt ]− E[Y0Mt ] = [β1 + β3(α0 + α1t + α2EX )](1− 0)

NIE(t·) = E[YtM1]− E[YtM0

] = (β2 + β3t)α1(1− 0)

If no interaction, NIE = CDE, and results agree with Baron and Kenny’s results.17 / 53

Continuous outcome & mediator – linear regression w/ analytic results

Implementation in SAS, SPSS (Valeri & VanderWeele 2013), Stata (Emsley et al.

2014): default NDE(·0), NIE(1·); CDE if specified, Delta/bootstrap SEs & CIs

Can be used for a broad combination of models.

SAS macro mediation:

%mediation(data=yrbs, yvar=depressSympts, avar=minority, mvar=bully,

cvar=grade11 grade12 age gender hhses2 hhses3 hhses4,

a0=0, a1=1, m=2.5, nc=8, yreg=linear, mreg=linear, interaction=true,

boot=true)

run;

SPSS macro mediation:

mediation data=yrbs /

yvar=depressSympts / avar=minority / mvar=bully /

cvar=grade11 grade12 age gender hhses2 hhses3 hhses4 /

NC=8 / a0=0 / a1=1 / m=2.5 /

yreg=LINEAR / mreg=LINEAR / interaction=TRUE /

boot=TRUE

Stata command paramed:

paramed depressSympts, avar=(minority) mvar(bully)

cvar(grade11 grade12 age gender hhses2 hhses3 hhses4)

a0=(0) a1(1) m(2.5) yreg(linear) mreg(linear)

boot reps(1000) seed(12345) level(95)18 / 53

Continuous outcome & mediator – linear regression w/ analytic results

sample output using the SAS macro: TOY example not including X variables

pages 42-43 in VanderWeele (2015)

19 / 53

Continuous outcome & mediator – linear regression w/ analytic results

NDEs and NIEs from Mplus: first compute means of X variables, then run:

MODEL:

bully ON minority (a1);

bully ON grade11 (a2);

bully ON grade12 (a3);

bully ON age (a4);

bully ON gender (a5);

bully ON hhses2 (a6);

bully ON hhses3 (a7);

bully ON hhses4 (a8);

[bully] (a0);

depressSympts ON minority (b1);

depressSympts ON bully (b2);

depressSympts ON minority_bully (b3);

depressSympts ON grade11 grade12 age gender hhses2 hhses3 hhses4;

MODEL CONSTRAINT:

NEW(nde0 nde1 nie0 nie1);

nde0 = b1 + b3*(a0 +a2*.33+a3*.29+a4*16.4+a5*.48+a6*.3+a7*.2+a8*.1);

nde1 = b1 + b3*(a0+a1+a2*.33+a3*.29+a4*16.4+a5*.48+a6*.3+a7*.2+a8*.1);

nie0 = b2 *a1;

nie1 = (b2+b3)*a1;

20 / 53

Continuous outcome & mediator – linear regression w/ analytic results

NDEs and NIEs from Mplus: or center X variables at their means:

VARIABLE:

...

DEFINE:

CENTER grade11 grade12 age gender hhses2 hhses3 hhses4 (GRANDMEAN);

MODEL:

bully ON minority (a1);

bully ON grade11 grade12 age gender hhses2 hhses3 hhses4;

[bully] (a0);

depressSympts ON minority (b1);

depressSympts ON bully (b2);

depressSympts ON minority_bully (b3);

depressSympts ON grade11 grade12 age gender hhses2 hhses3 hhses4;

MODEL CONSTRAINT:

NEW(nde0 nde1 nie0 nie1);

nde0 = b1 + b3* a0;

nde1 = b1 + b3*(a0+a1);

nie0 = b2 *a1;

nie1 = (b2+b3)*a1;

This is only good for this case of continuous mediator and outcome! 21 / 53

Continuous outcome and continuous mediator –regression-based simulation (Imai et al. 2010)

Works for a broad combination of parametric and non-parametric models.

Algorithm 1 – parametric bootstrap (bootstrap the parameters)I fit models

I sample sets of parameters from their estimated distribution, assumingmultivariate normal

I with each set of parameters:

I sample potential mediators and potential outcomesI compute NIE and NDE

I summarize the sample of NIE and NDE

Algorithm 2 – non-parametric bootstrap (bootstrap the data)I draw bootstrap samples from the data

I with each bootstrap dataset:

I fit modelsI using estimated parameters, sample potential mediators and potential

outcomesI compute NIE and NDE

I summarize the sample of NIE and NDE22 / 53

Continuous outcome & mediator – regression-based simulation

mediation package in R (Imai et al. 2010b, 2013; Tingley et al. 2014):

I natural effects only (no CDE); default output both NIE/NDE pairs

I also outputs proportion mediated

I allows different sets of X variables for the two models if wanted (I think)

I accommodates M-X interaction as well (covariates= option)

library(mediation)

mod.m <- lm(bully ~ minority + grade + age + gender + hhses, data=yrbs)

mod.y <- lm(depressSympts ~ minority*bully + grade + age + gender +

hhses, data=yrbs)

out <- mediate(mod.m, mod.y, sims=1000, boot=true, treat="minority",

mediator = "bully")

summary(out)

23 / 53

Continuous outcome & mediator – regression-based simulation

sample output using mediation package:

pages 12-13 in Imai et al. (2013)

24 / 53

CONTINUOUS OUTCOME

Now a slightly more complicated case:

a continuous outcome and a binary/categorical mediator

We’ll talk about the binary mediator situation.

With a 3-or-more-category mediator, use a polytomous logistic regression for

the mediator. The strategy for computing mean potential outcomes and causal

effects is the same.

25 / 53

Continuous outcome and binary mediator –regression with analytic results

Assume a model of choice for the potential mediators (eg linear, logit, probit,

log-linear – here probit shown) and a linear model for the potential outcomes.

Under identifying assumptions, estimate parameters using regression models:

probit[P(M = 1|T = t,X = x)] = α0 + α1t + α2x

E[Y |T = t,M = m,X = x] = β0 + β1t + β2m + β3tm + β4x

Based on the first model, we have conditional potential mediator probabilities:

P(Mt = 1|X = x) = Φ(α0 + α1t + α2x)

These plus the second model provide conditional means of potential outcomes:

E[YtMt′|X = x] = β0 + β1t + (β2 + β3t)Φ(α0 + α1t

′ + α2x) + β4x

Conditional natural direct and indirect effects:

NDE(·t|X = x) = E[Y1Mt − Y0Mt |X = x] = [β1 + β3Φ(α0 + α1t + α2x)]

NIE(t · |X = x) = E[YtM1− YtM0

|X = x] = (β2 + β3t)

[Φ(α0 + α1 + α2x)−Φ(α0 + α2x)

]Marginal natural direct and indirect effects:

NDE(·t) = E[Y1Mt − Y0Mt ] = [β1 + β3

∑x

Φ(α0 + α1t + α2x)P(X = x)]

NIE(t·) = E[YtM1− YtM0

] = (β2 + β3t)∑x

{[Φ(α0 + α1 + α2x)−Φ(α0 + α2x)

]P(X = x)

}

26 / 53

Continuous outcome and binary mediator –regression with analytic results

Assume a model of choice for the potential mediators (eg linear, logit, probit,

log-linear – here probit shown) and a linear model for the potential outcomes.

Under identifying assumptions, estimate parameters using regression models:

probit[P(M = 1|T = t,X = x)] = α0 + α1t + α2x

E[Y |T = t,M = m,X = x] = β0 + β1t + β2m + β3tm + β4x

Based on the first model, we have conditional potential mediator probabilities:

P(Mt = 1|X = x) = Φ(α0 + α1t + α2x)

These plus the second model provide conditional means of potential outcomes:

E[YtMt′|X = x] = β0 + β1t + (β2 + β3t)Φ(α0 + α1t

′ + α2x) + β4x

Conditional natural direct and indirect effects:

NDE(·t|X = x) = E[Y1Mt − Y0Mt |X = x] = [β1 + β3Φ(α0 + α1t + α2x)]

NIE(t · |X = x) = E[YtM1− YtM0

|X = x] = (β2 + β3t)

[Φ(α0 + α1 + α2x)−Φ(α0 + α2x)

]Marginal natural direct and indirect effects:

NDE(·t) = E[Y1Mt − Y0Mt ] = [β1 + β3

∑x

Φ(α0 + α1t + α2x)P(X = x)]

NIE(t·) = E[YtM1− YtM0

] = (β2 + β3t)∑x

{[Φ(α0 + α1 + α2x)−Φ(α0 + α2x)

]P(X = x)

}

26 / 53

Continuous outcome and binary mediator –regression with analytic results

Assume a model of choice for the potential mediators (eg linear, logit, probit,

log-linear – here probit shown) and a linear model for the potential outcomes.

Under identifying assumptions, estimate parameters using regression models:

probit[P(M = 1|T = t,X = x)] = α0 + α1t + α2x

E[Y |T = t,M = m,X = x] = β0 + β1t + β2m + β3tm + β4x

Based on the first model, we have conditional potential mediator probabilities:

P(Mt = 1|X = x) = Φ(α0 + α1t + α2x)

These plus the second model provide conditional means of potential outcomes:

E[YtMt′|X = x] = β0 + β1t + (β2 + β3t)Φ(α0 + α1t

′ + α2x) + β4x

Conditional natural direct and indirect effects:

NDE(·t|X = x) = E[Y1Mt − Y0Mt |X = x] = [β1 + β3Φ(α0 + α1t + α2x)]

NIE(t · |X = x) = E[YtM1− YtM0

|X = x] = (β2 + β3t)

[Φ(α0 + α1 + α2x)−Φ(α0 + α2x)

]Marginal natural direct and indirect effects:

NDE(·t) = E[Y1Mt − Y0Mt ] = [β1 + β3

∑x

Φ(α0 + α1t + α2x)P(X = x)]

NIE(t·) = E[YtM1− YtM0

] = (β2 + β3t)∑x

{[Φ(α0 + α1 + α2x)−Φ(α0 + α2x)

]P(X = x)

}

26 / 53

Continuous outcome and binary mediator –regression with analytic results

Assume a model of choice for the potential mediators (eg linear, logit, probit,

log-linear – here probit shown) and a linear model for the potential outcomes.

Under identifying assumptions, estimate parameters using regression models:

probit[P(M = 1|T = t,X = x)] = α0 + α1t + α2x

E[Y |T = t,M = m,X = x] = β0 + β1t + β2m + β3tm + β4x

Based on the first model, we have conditional potential mediator probabilities:

P(Mt = 1|X = x) = Φ(α0 + α1t + α2x)

These plus the second model provide conditional means of potential outcomes:

E[YtMt′|X = x] = β0 + β1t + (β2 + β3t)Φ(α0 + α1t

′ + α2x) + β4x

Conditional natural direct and indirect effects:

NDE(·t|X = x) = E[Y1Mt − Y0Mt |X = x] = [β1 + β3Φ(α0 + α1t + α2x)]

NIE(t · |X = x) = E[YtM1− YtM0

|X = x] = (β2 + β3t)

[Φ(α0 + α1 + α2x)−Φ(α0 + α2x)

]

Marginal natural direct and indirect effects:

NDE(·t) = E[Y1Mt − Y0Mt ] = [β1 + β3

∑x

Φ(α0 + α1t + α2x)P(X = x)]

NIE(t·) = E[YtM1− YtM0

] = (β2 + β3t)∑x

{[Φ(α0 + α1 + α2x)−Φ(α0 + α2x)

]P(X = x)

}

26 / 53

Continuous outcome and binary mediator –regression with analytic results

Assume a model of choice for the potential mediators (eg linear, logit, probit,

log-linear – here probit shown) and a linear model for the potential outcomes.

Under identifying assumptions, estimate parameters using regression models:

probit[P(M = 1|T = t,X = x)] = α0 + α1t + α2x

E[Y |T = t,M = m,X = x] = β0 + β1t + β2m + β3tm + β4x

Based on the first model, we have conditional potential mediator probabilities:

P(Mt = 1|X = x) = Φ(α0 + α1t + α2x)

These plus the second model provide conditional means of potential outcomes:

E[YtMt′|X = x] = β0 + β1t + (β2 + β3t)Φ(α0 + α1t

′ + α2x) + β4x

Conditional natural direct and indirect effects:

NDE(·t|X = x) = E[Y1Mt − Y0Mt |X = x] = [β1 + β3Φ(α0 + α1t + α2x)]

NIE(t · |X = x) = E[YtM1− YtM0

|X = x] = (β2 + β3t)

[Φ(α0 + α1 + α2x)−Φ(α0 + α2x)

]Marginal natural direct and indirect effects:

NDE(·t) = E[Y1Mt − Y0Mt ] = [β1 + β3

∑x

Φ(α0 + α1t + α2x)P(X = x)]

NIE(t·) = E[YtM1− YtM0

] = (β2 + β3t)∑x

{[Φ(α0 + α1 + α2x)−Φ(α0 + α2x)

]P(X = x)

}26 / 53

Continuous outcome & binary mediator – regression w/ analytic results

SAS macro mediation:

%mediation(data=yrbs, yvar=depressSympts, avar=minority, mvar=bully,

cvar=grade11 grade12 age gender hhses2 hhses3 hhses4,

a0=0, a1=1, nc=8, yreg=linear, mreg=logit, interaction=true,

boot=true)

run;

SPSS macro mediation:

mediation data=yrbs /

yvar=depressSympts / avar=minority / mvar=bully /

cvar=grade11 grade12 age gender hhses2 hhses3 hhses4 /

NC=8 / a0=0 / a1=1 / yreg=LINEAR / mreg=LOGIT / interaction=TRUE /

boot=TRUE

Stata command paramed:

paramed depressSympts, avar=(minority) mvar(bully)

cvar(grade11 grade12 age gender hhses2 hhses3 hhses4)

a0=(0) a1(1) yreg(linear) mreg(logit)

boot reps(1000) seed(12345) level(95)

Other options for mreg: probit, log-linear, linear

27 / 53

Continuous outcome and binary/categorical mediator –regression-based simulation

mediation package in R

library(mediation)

mod.m <- glm(bully ~ minority + grade + age + gender + hhses,

family=binomial, data=yrbs)

mod.y <- lm(depressSympts ~ minority*bully + grade + age + gender +

hhses, data=yrbs)

out <- mediate(mod.m, mod.y, sims=1000, boot=true, treat="minority",

mediator="bully")

summary(out)

28 / 53

CONTINUOUS OUTCOME

In the case with

a continuous outcome and an ordinal mediator

a key choice is whether we think the actual mediator is

I the observed categorical mediator variable, or

I a latent continuous variable underlying this variable.

If observed mediator, use same strategy for binary/categorical mediator, butmay model mediator using ordered logit/probit model.

If latent mediator, results are only slightly different from the continuous

mediator case, and should be able to implement in Mplus (I haven’t tested

this).

29 / 53

Continuous outcome, ordinal observed mediator –regression-based simulation

Analytic results for this case are not currently implemented in any software.

Can use regression-based simulation with the R package mediation.

library(MASS)

library(mediation)

mod.m <- polr(bully ~ minority + grade + age + gender + hhses,

method="logistic", data=yrbs)

mod.y <- lm(depressSympts ~ minority*bully + grade + age + gender +

hhses, data=yrbs)

out <- mediate(mod.m, mod.y, sims=1000, boot=true, treat="minority",

mediator="bully")

summary(out)

method options in polr: probit, loglog, cloglog, cauchit.

30 / 53

Continuous outcome, ordinal representing latentcontinuous mediator – regression with analytic results

Assume a probit model for the potential mediators and a linear model for thepotential outcomes:

Mi (t) = α1t + α2Xi + εMi,t, Mi (t) =

1 if Mi (t) ≤ τ1

2 if τ1 <Mi (t) ≤ τ2

...k if Mi (t) > τk−1

Yi (t,m) = β0 + β1t + β2m + β3tm + β4Xi + εYi,t,m(m represents values of M)

Under identifying assumptions, estimate parameters using SEM.

Conditional natural direct and indirect effects:

NDE(·t|X = x) = E[Y1Mt − Y0Mt |X = x] = [β1 + β3(α1t + α2x)]

NIE(t · |X = x) = E[YtM1− YtM0

|X = x] = (β2 + β3t)α1

Marginal natural direct and indirect effects:

NDE(·t) = E[Y1Mt ]− E[Y0Mt ] = [β1 + β3(α1t + α2EX )]

NIE(t·) = E[YtM1]− E[YtM0

] = (β2 + β3t)α1

31 / 53

Continuous outcome, ordinal representing latent continuous mediator –

linear regression w/ analytic results

Something like this in Mplus (not yet tested!):

MODEL:

bully ON minority (a1);

bully ON grade11 (a2);

bully ON grade12 (a3);

bully ON age (a4);

bully ON gender (a5);

bully ON hhses2 (a6);

bully ON hhses3 (a7);

bully ON hhses4 (a8);

int | minority XWITH bully; !if not work, try a 1-item factor for bully

depressSympts ON minority (b1);

depressSympts ON bully (b2);

depressSympts ON int (b3);

depressSympts ON grade11 grade12 age gender hhses2 hhses3 hhses4;

MODEL CONSTRAINT:

NEW(nde0 nde1 nie0 nie1);

nde0 = b1 + b3*( a2*.33+a3*.29+a4*16.4+a5*.48+a6*.3+a7*.2+a8*.1);

nde1 = b1 + b3*(a1+a2*.33+a3*.29+a4*16.4+a5*.48+a6*.3+a7*.2+a8*.1);

nie0 = b2 *a1;

nie1 = (b2+b3)*a1; 32 / 53

CONTINUOUS OUTCOME

In the case with

a continuous outcome and an latent continuous mediator

e.g., the mediator is a latent factor with multiple measurement items,estimation is similar to the case with a latent continuous mediator representedby an ordinal manifest variable.

In this case we need to make the additional assumption that the measurement

errors in the items are independent of T , Y and X .

33 / 53

Continuous outcome, latent continuous mediator – linear regression w/

analytic resultsMODEL:

f BY bully1 bully2 bully3 bully4 bully5;

f ON minority (a1);

f ON grade11 (a2);

f ON grade12 (a3);

f ON age (a4);

f ON gender (a5);

f ON hhses2 (a6);

f ON hhses3 (a7);

f ON hhses4 (a8);

int | minority XWITH f;

depressSympts ON minority (b1);

depressSympts ON f (b2);

depressSympts ON int (b3);

depressSympts ON grade11 grade12 age gender hhses2 hhses3 hhses4;

MODEL CONSTRAINT:

NEW(nde0 nde1 nie0 nie1);

nde0 = b1 + b3*( a2*.33+a3*.29+a4*16.4+a5*.48+a6*.3+a7*.2+a8*.1);

nde1 = b1 + b3*(a1+a2*.33+a3*.29+a4*16.4+a5*.48+a6*.3+a7*.2+a8*.1);

nie0 = b2 *a1;

nie1 = (b2+b3)*a1;34 / 53

BINARY OUTCOME

I there are different measures of effect

NDERD(·t) = P(Y1Mt = 1)− P(Y0Mt = 1)

NDERR(·t) =P(Y1Mt = 1)

P(Y0Mt = 1),

NDEOR(·t) =P(Y1Mt = 1)/P(Y1Mt = 0)

P(Y0Mt = 1)/P(Y0Mt = 0)

I some methods estimate marginal, others estimate conditional, effects

NDE(·t|X = x) 6= NDE(·t)

I methods that target marginal effects usually get to marginal effects viapredicting potential outcome probabilities P(YtMt′ = 1)

I methods that target conditional effects usually formulate conditionaleffects as direct functions of model parameters and X , bypassingcomputation of potential outcome probabilities

I RD-scale:average conditional effects over X −→ mean conditional effects

= marginal effects

I RR- or OR-scale:log-average-exponentiate −→ geometric mean of conditional effects

6= marginal effects

35 / 53

BINARY OUTCOME

I there are different measures of effect

NDERD(·t) = P(Y1Mt = 1)− P(Y0Mt = 1)

NDERR(·t) =P(Y1Mt = 1)

P(Y0Mt = 1),

NDEOR(·t) =P(Y1Mt = 1)/P(Y1Mt = 0)

P(Y0Mt = 1)/P(Y0Mt = 0)

I some methods estimate marginal, others estimate conditional, effects

NDE(·t|X = x) 6= NDE(·t)

I methods that target marginal effects usually get to marginal effects viapredicting potential outcome probabilities P(YtMt′ = 1)

I methods that target conditional effects usually formulate conditionaleffects as direct functions of model parameters and X , bypassingcomputation of potential outcome probabilities

I RD-scale:average conditional effects over X −→ mean conditional effects

= marginal effects

I RR- or OR-scale:log-average-exponentiate −→ geometric mean of conditional effects

6= marginal effects

35 / 53

BINARY OUTCOME

I there are different measures of effect

NDERD(·t) = P(Y1Mt = 1)− P(Y0Mt = 1)

NDERR(·t) =P(Y1Mt = 1)

P(Y0Mt = 1),

NDEOR(·t) =P(Y1Mt = 1)/P(Y1Mt = 0)

P(Y0Mt = 1)/P(Y0Mt = 0)

I some methods estimate marginal, others estimate conditional, effects

NDE(·t|X = x) 6= NDE(·t)

I methods that target marginal effects usually get to marginal effects viapredicting potential outcome probabilities P(YtMt′ = 1)

I methods that target conditional effects usually formulate conditionaleffects as direct functions of model parameters and X , bypassingcomputation of potential outcome probabilities

I RD-scale:average conditional effects over X −→ mean conditional effects

= marginal effects

I RR- or OR-scale:log-average-exponentiate −→ geometric mean of conditional effects

6= marginal effects

35 / 53

BINARY OUTCOME

I there are different measures of effect

NDERD(·t) = P(Y1Mt = 1)− P(Y0Mt = 1)

NDERR(·t) =P(Y1Mt = 1)

P(Y0Mt = 1),

NDEOR(·t) =P(Y1Mt = 1)/P(Y1Mt = 0)

P(Y0Mt = 1)/P(Y0Mt = 0)

I some methods estimate marginal, others estimate conditional, effects

NDE(·t|X = x) 6= NDE(·t)

I methods that target marginal effects usually get to marginal effects viapredicting potential outcome probabilities P(YtMt′ = 1)

I methods that target conditional effects usually formulate conditionaleffects as direct functions of model parameters and X , bypassingcomputation of potential outcome probabilities

I RD-scale:average conditional effects over X −→ mean conditional effects

= marginal effects

I RR- or OR-scale:log-average-exponentiate −→ geometric mean of conditional effects

6= marginal effects35 / 53

BINARY OUTCOME

Let’s start with the simplest case with

a binary outcome and a continuous mediator

and consider first marginal effects, then conditional effects.

36 / 53

Binary outcome and continuous mediator: marginal effects– regression with analytic results

One option: Assume a linear normal model for the potential mediators and aprobit model for the potential outcomes:

Mi (t) = α0 + α1t + α2Xi + εMi,t, εMi,t

∼ N(0, σ2M)

probit{P[Yi (t,m) = 1]} = β0 + β1t + β2m + β3tm + β4Xi

Under identifying assumptions, estimate parameters using regression models:

(M|T = t,X = x) = α0 + α1t + α2x + εM , Var(εM) = σ2M

probit[P(Y = 1|T = t,M = m,X = x)] = β0 + β1t + β2m + β3tm + β4x

Conditional potential outcome probabilities (Imai et al. 2009; Muthen 2011):

P(YtMt′= 1|X = x) = Φ

β0 + β1t + (β2 + β3t)(α0 + α1t′ + α2x) + α4x√(β2 + β3t)2σ2

M + 1

Marginal RD-scale natural direct and indirect effects:

NDERD(·t) = P(Y1Mt = 1)− P(Y0Mt = 1) =∑x

[P(Y1Mt = 1|X = x)−P(Y0Mt = 1|X = x)

]P(X = x)

NIERD(t·) = P(YtM1= 1)− P(YtM0

= 1) =∑x

[P(YtM1

= 1|X = x)−P(YtM0

= 1|X = x)

]P(X = x)

37 / 53

Binary outcome and continuous mediator: marginal effects– regression with analytic results

One option: Assume a linear normal model for the potential mediators and aprobit model for the potential outcomes:

Mi (t) = α0 + α1t + α2Xi + εMi,t, εMi,t

∼ N(0, σ2M)

probit{P[Yi (t,m) = 1]} = β0 + β1t + β2m + β3tm + β4Xi

Under identifying assumptions, estimate parameters using regression models:

(M|T = t,X = x) = α0 + α1t + α2x + εM , Var(εM) = σ2M

probit[P(Y = 1|T = t,M = m,X = x)] = β0 + β1t + β2m + β3tm + β4x

Conditional potential outcome probabilities (Imai et al. 2009; Muthen 2011):

P(YtMt′= 1|X = x) = Φ

β0 + β1t + (β2 + β3t)(α0 + α1t′ + α2x) + α4x√(β2 + β3t)2σ2

M + 1

Marginal RD-scale natural direct and indirect effects:

NDERD(·t) = P(Y1Mt = 1)− P(Y0Mt = 1) =∑x

[P(Y1Mt = 1|X = x)−P(Y0Mt = 1|X = x)

]P(X = x)

NIERD(t·) = P(YtM1= 1)− P(YtM0

= 1) =∑x

[P(YtM1

= 1|X = x)−P(YtM0

= 1|X = x)

]P(X = x)

37 / 53

Binary outcome and continuous mediator: marginal effects– regression with analytic results

One option: Assume a linear normal model for the potential mediators and aprobit model for the potential outcomes:

Mi (t) = α0 + α1t + α2Xi + εMi,t, εMi,t

∼ N(0, σ2M)

probit{P[Yi (t,m) = 1]} = β0 + β1t + β2m + β3tm + β4Xi

Under identifying assumptions, estimate parameters using regression models:

(M|T = t,X = x) = α0 + α1t + α2x + εM , Var(εM) = σ2M

probit[P(Y = 1|T = t,M = m,X = x)] = β0 + β1t + β2m + β3tm + β4x

Conditional potential outcome probabilities (Imai et al. 2009; Muthen 2011):

P(YtMt′= 1|X = x) = Φ

β0 + β1t + (β2 + β3t)(α0 + α1t′ + α2x) + α4x√(β2 + β3t)2σ2

M + 1

Marginal RD-scale natural direct and indirect effects:

NDERD(·t) = P(Y1Mt = 1)− P(Y0Mt = 1) =∑x

[P(Y1Mt = 1|X = x)−P(Y0Mt = 1|X = x)

]P(X = x)

NIERD(t·) = P(YtM1= 1)− P(YtM0

= 1) =∑x

[P(YtM1

= 1|X = x)−P(YtM0

= 1|X = x)

]P(X = x)

37 / 53

Binary outcome and continuous mediator: marginal effects– regression with analytic results

One option: Assume a linear normal model for the potential mediators and aprobit model for the potential outcomes:

Mi (t) = α0 + α1t + α2Xi + εMi,t, εMi,t

∼ N(0, σ2M)

probit{P[Yi (t,m) = 1]} = β0 + β1t + β2m + β3tm + β4Xi

Under identifying assumptions, estimate parameters using regression models:

(M|T = t,X = x) = α0 + α1t + α2x + εM , Var(εM) = σ2M

probit[P(Y = 1|T = t,M = m,X = x)] = β0 + β1t + β2m + β3tm + β4x

Conditional potential outcome probabilities (Imai et al. 2009; Muthen 2011):

P(YtMt′= 1|X = x) = Φ

β0 + β1t + (β2 + β3t)(α0 + α1t′ + α2x) + α4x√(β2 + β3t)2σ2

M + 1

Marginal RD-scale natural direct and indirect effects:

NDERD(·t) = P(Y1Mt = 1)− P(Y0Mt = 1) =∑x

[P(Y1Mt = 1|X = x)−P(Y0Mt = 1|X = x)

]P(X = x)

NIERD(t·) = P(YtM1= 1)− P(YtM0

= 1) =∑x

[P(YtM1

= 1|X = x)−P(YtM0

= 1|X = x)

]P(X = x)

37 / 53

Binary outcome and continuous mediator: marginal effects– regression with analytic results

One option: Assume a linear normal model for the potential mediators and aprobit model for the potential outcomes:

Mi (t) = α0 + α1t + α2Xi + εMi,t, εMi,t

∼ N(0, σ2M)

probit{P[Yi (t,m) = 1]} = β0 + β1t + β2m + β3tm + β4Xi

Under identifying assumptions, estimate parameters using regression models:

(M|T = t,X = x) = α0 + α1t + α2x + εM , Var(εM) = σ2M

probit[P(Y = 1|T = t,M = m,X = x)] = β0 + β1t + β2m + β3tm + β4x

Conditional potential outcome probabilities (Imai et al. 2009; Muthen 2011):

P(YtMt′= 1|X = x) = Φ

β0 + β1t + (β2 + β3t)(α0 + α1t′ + α2x) + β4x√(β2 + β3t)2σ2

M + 1

Marginal RR-scale natural direct and indirect effects:

NDERR(·t) =P(Y1Mt = 1)

P(Y0Mt = 1)=

∑x P(Y1Mt = 1)P(X = x)∑x P(Y0Mt = 1)P(X = x)

NIERD(t·) =P(YtM1

= 1)

P(YtM0= 1)

=

∑x P(YtM1

= 1)P(X = x)∑x P(YtM0

= 1)P(X = x)

38 / 53

Binary outcome and continuous mediator: marginal effects– regression and numerical integration

Another option: Assume a logit model for the potential outcomes, and a linearmodel for the potential mediators with a certain error distribution (here normal,but another distribution ok).

Under identifying assumptions, estimate parameters using regression models:

(M|T = t,X = x) = α0 + α1t + α2x + εM , εM ∼ N(0, σ2M)

logit[P(Y = 1|T = t,M = m,X = x)] = β0 + β1t + β2m + β3tm + β4x

No simple formula but can numerically compute potential outcome probabilities:

P(YtMt′= 1|X = x , εM = e) =

eβ0+β1t+(β2+β3t)(α0+α1t′+α2x+e)+β4x

1 + eβ0+β1t+(β2+β3t)(α0+α1t′+α2x+e)+β4x

P(YtMt′= 1|X = x) =

∑e

P(YtMt′= 1|X = x , εM = e)P(εM = e)

Natural direct and direct effects are then computed the same way as on the

previous slide.

39 / 53

Binary outcome and continuous mediator: marginal effects– regression-based simulation

Neither of the strategies just mentioned are currently implemented in anysoftware. You can program them!

Marginal RD-scale effects can be obtained using regression-based simulation

with the R package mediation:

library(mediation)

mod.m <- lm(bully ~ minority + grade + age + gender + hhses, data=yrbs)

mod.y <- glm(suicAttmpt ~ minority*bully + grade + age + gender +

hhses, family=binomial, data=yrbs)

out <- mediate(mod.m, mod.y, sims=1000, boot=true, treat="minority",

mediator = "bully")

summary(out)

40 / 53

Binary outcome & continuous mediator: conditional effects– regression with analytic results (VanderWeele & Vansteelandt 2010)

If the outcome is rare, assume a logistic model for the potential outcomes anda linear model for the potential mediators.

Under identifying assumptions, estimate parameters using regression models:

E[M|T = t,X = x] = α0 + α1t + α2x , Var(εM) = σ2M

logit[P(Y = 1|T = t,M = m,X = x)] = β0 + β1t + β2m + β3tm + β4x

Conditional OR-scale controlled direct effect (not requiring the rare outcomeassumption):

CDEOR(m|X = x) =odds(Y1m = 1 vs 0|X = x)

odds(Y0m = 1 vs 0|X = x)= eβ1+β3m

Conditional OR-scale natural direct and indirect effects are approximated asbelow (rare outcome needed for approximation):

NDEOR(·t|X = x) =odds(Y1Mt = 1 vs 0|X = x)

odds(Y0Mt = 1 vs 0|X = x)≈ eβ1+β3(α0+α1t+α2x+β2σ

2M )+0.5β2

3σ2M

NIEOR(t · |X = x) =odds(Y1M1

= 1 vs 0|X = x)

odds(YtM0= 1 vs 0|X = x)

≈ e(β2+β3t)α1

41 / 53

Binary outcome & continuous mediator: conditional effects– regression with analytic results (VanderWeele & Vansteelandt 2010)

If the outcome is not rare, assume a log-linear model for the potentialoutcomes and a linear model for the potential mediators.

Under identifying assumptions, estimate parameters using regression models:

E[M|T = t,X = x] = α0 + α1t + α2x , Var(εM) = σ2M

log[P(Y = 1|T = t,M = m,X = x)] = β0 + β1t + β2m + β3tm + β4x

Conditional RR-scale controlled direct effect:

CDERR(m|X = x) =P(Y1m = 1|X = x)

P(Y0m = 1|X = x)= eβ1+β3m

Conditional RR-scale natural direct and indirect effects:

NDERR(·t|X = x) =P(Y1Mt = 1|X = x)

P(Y0Mt = 1|X = x)= eβ1+β3(α0+α1t+α2x+β2σ

2M )+0.5β2

3σ2M

NIERR(t · |X = x) =P(Y1M1

= 1|X = x)

P(YtM0= 1|X = x)

= e(β2+β3t)α1

42 / 53

Binary outcome & continuous mediator: conditional effects –

regression w/ analytic results

SAS macro mediation (SPSS and Stata similar):

If the outcome is rare:

%mediation(data=yrbs, yvar=suicAttmpt, avar=minority, mvar=bully,

cvar=grade11 grade12 age gender hhses2 hhses3 hhses4,

a0=0, a1=1, m=2.5, nc=8, yreg=logit, mreg=linear, interaction=true,

boot=true)

run;

If the outcome is not rare:

%mediation(data=yrbs, yvar=suicAttmpt, avar=minority, mvar=bully,

cvar=grade11 grade12 age gender hhses2 hhses3 hhses4,

a0=0, a1=1, m=2.5, nc=8,

yreg=loglinear, mreg=linear, interaction=true,

boot=true)

run;

43 / 53

Binary outcome & continuous mediator: conditional effects– regression with analytic results

When the outcome is rare, OR-scale conditional effects from VanderWeele &Vansteelandt (2010) and Valeri & VanderWeele (2013) are approximate.

If want exact conditional effects (either OR- or RR-scale, preferably RR-scale),

could use P(YtM′t

= 1|X = x) from slide 37 or 39 to compute them.

44 / 53

BINARY OUTCOME

Let’s now consider the case with

a binary outcome and a binary mediator

45 / 53

Binary outcome and binary mediator: marginal effects– regression with analytic results

Assume models of choice for the potential mediators and potential outcomes –logit example here.

Under identifying assumptions, estimate parameters using regression models:

logit[P(M = 1|T = t,X = x)] = β0 + β1t + β2x

logit[P(Y = 1|T = t,M = m,X = x)] = θ0 + θ1t + θ2m + θ3tm + θ4x

Based on these models:

P(Mt = 1|X = x) =eβ0+β1t+β2x

1 + eβ0+β1t+β2x, P(Ytm = 1|X = x) =

eβ0+β1t+(β2+β3t)m+β4x

1 + eβ0+β1t+(β2+β3t)m+β4x

Combining the two:

P(YtMt′= 1|X = x) =

= P(Yt1 = 1|X = x)P(Mt′ = 1|X = x) + P(Yt0 = 1|X = x)P(Mt′ = 0|X = x)

=eβ0+(β1+β3)t+β2+β4x

1 + eβ0+(β1+β3)t+β2+β4x·

eα0+α1t′+α2x

1 + eα0+α1t′+α2x+

eβ0+β1t+β4x

1 + eβ0+β1t+β4x·

1

1 + eα0+α1t′+α2x

Marginal RD-scale natural direct and indirect effects:

NDERD(·t) = P(Y1Mt = 1)− P(Y0Mt = 1) =∑x

[P(Y1Mt = 1|X = x)−P(Y0Mt = 1|X = x)

]P(X = x)

NIERD(t·) = P(YtM1= 1)− P(YtM0

= 1) =∑x

[P(YtM1

= 1|X = x)−P(YtM0

= 1|X = x)

]P(X = x)

46 / 53

Binary outcome and binary mediator: marginal effects– regression with analytic results

Assume models of choice for the potential mediators and potential outcomes –logit example here.

Under identifying assumptions, estimate parameters using regression models:

logit[P(M = 1|T = t,X = x)] = β0 + β1t + β2x

logit[P(Y = 1|T = t,M = m,X = x)] = θ0 + θ1t + θ2m + θ3tm + θ4x

Based on these models:

P(Mt = 1|X = x) =eβ0+β1t+β2x

1 + eβ0+β1t+β2x, P(Ytm = 1|X = x) =

eβ0+β1t+(β2+β3t)m+β4x

1 + eβ0+β1t+(β2+β3t)m+β4x

Combining the two:

P(YtMt′= 1|X = x) =

= P(Yt1 = 1|X = x)P(Mt′ = 1|X = x) + P(Yt0 = 1|X = x)P(Mt′ = 0|X = x)

=eβ0+(β1+β3)t+β2+β4x

1 + eβ0+(β1+β3)t+β2+β4x·

eα0+α1t′+α2x

1 + eα0+α1t′+α2x+

eβ0+β1t+β4x

1 + eβ0+β1t+β4x·

1

1 + eα0+α1t′+α2x

Marginal RD-scale natural direct and indirect effects:

NDERD(·t) = P(Y1Mt = 1)− P(Y0Mt = 1) =∑x

[P(Y1Mt = 1|X = x)−P(Y0Mt = 1|X = x)

]P(X = x)

NIERD(t·) = P(YtM1= 1)− P(YtM0

= 1) =∑x

[P(YtM1

= 1|X = x)−P(YtM0

= 1|X = x)

]P(X = x)

46 / 53

Binary outcome and binary mediator: marginal effects– regression with analytic results

Assume models of choice for the potential mediators and potential outcomes –logit example here.

Under identifying assumptions, estimate parameters using regression models:

logit[P(M = 1|T = t,X = x)] = β0 + β1t + β2x

logit[P(Y = 1|T = t,M = m,X = x)] = θ0 + θ1t + θ2m + θ3tm + θ4x

Based on these models:

P(Mt = 1|X = x) =eβ0+β1t+β2x

1 + eβ0+β1t+β2x, P(Ytm = 1|X = x) =

eβ0+β1t+(β2+β3t)m+β4x

1 + eβ0+β1t+(β2+β3t)m+β4x

Combining the two:

P(YtMt′= 1|X = x) =

= P(Yt1 = 1|X = x)P(Mt′ = 1|X = x) + P(Yt0 = 1|X = x)P(Mt′ = 0|X = x)

=eβ0+(β1+β3)t+β2+β4x

1 + eβ0+(β1+β3)t+β2+β4x·

eα0+α1t′+α2x

1 + eα0+α1t′+α2x+

eβ0+β1t+β4x

1 + eβ0+β1t+β4x·

1

1 + eα0+α1t′+α2x

Marginal RD-scale natural direct and indirect effects:

NDERD(·t) = P(Y1Mt = 1)− P(Y0Mt = 1) =∑x

[P(Y1Mt = 1|X = x)−P(Y0Mt = 1|X = x)

]P(X = x)

NIERD(t·) = P(YtM1= 1)− P(YtM0

= 1) =∑x

[P(YtM1

= 1|X = x)−P(YtM0

= 1|X = x)

]P(X = x)

46 / 53

Binary outcome and binary mediator: marginal effects– regression with analytic results

Assume models of choice for the potential mediators and potential outcomes –logit example here.

Under identifying assumptions, estimate parameters using regression models:

logit[P(M = 1|T = t,X = x)] = β0 + β1t + β2x

logit[P(Y = 1|T = t,M = m,X = x)] = θ0 + θ1t + θ2m + θ3tm + θ4x

Based on these models:

P(Mt = 1|X = x) =eβ0+β1t+β2x

1 + eβ0+β1t+β2x, P(Ytm = 1|X = x) =

eβ0+β1t+(β2+β3t)m+β4x

1 + eβ0+β1t+(β2+β3t)m+β4x

Combining the two:

P(YtMt′= 1|X = x) =

= P(Yt1 = 1|X = x)P(Mt′ = 1|X = x) + P(Yt0 = 1|X = x)P(Mt′ = 0|X = x)

=eβ0+(β1+β3)t+β2+β4x

1 + eβ0+(β1+β3)t+β2+β4x·

eα0+α1t′+α2x

1 + eα0+α1t′+α2x+

eβ0+β1t+β4x

1 + eβ0+β1t+β4x·

1

1 + eα0+α1t′+α2x

Marginal RD-scale natural direct and indirect effects:

NDERD(·t) = P(Y1Mt = 1)− P(Y0Mt = 1) =∑x

[P(Y1Mt = 1|X = x)−P(Y0Mt = 1|X = x)

]P(X = x)

NIERD(t·) = P(YtM1= 1)− P(YtM0

= 1) =∑x

[P(YtM1

= 1|X = x)−P(YtM0

= 1|X = x)

]P(X = x)

46 / 53

Binary outcome and binary mediator: marginal effects– regression with analytic results

Assume models of choice for the potential mediators and potential outcomes –logit example here.

Under identifying assumptions, estimate parameters using regression models:

logit[P(M = 1|T = t,X = x)] = β0 + β1t + β2x

logit[P(Y = 1|T = t,M = m,X = x)] = θ0 + θ1t + θ2m + θ3tm + θ4x

Based on these models:

P(Mt = 1|X = x) =eβ0+β1t+β2x

1 + eβ0+β1t+β2x, P(Ytm = 1|X = x) =

eβ0+β1t+(β2+β3t)m+β4x

1 + eβ0+β1t+(β2+β3t)m+β4x

Combining the two:

P(YtMt′= 1|X = x) =

= P(Yt1 = 1|X = x)P(Mt′ = 1|X = x) + P(Yt0 = 1|X = x)P(Mt′ = 0|X = x)

=eβ0+(β1+β3)t+β2+β4x

1 + eβ0+(β1+β3)t+β2+β4x·

eα0+α1t′+α2x

1 + eα0+α1t′+α2x+

eβ0+β1t+β4x

1 + eβ0+β1t+β4x·

1

1 + eα0+α1t′+α2x

Marginal RR-scale natural direct and indirect effects:

NDERR(·t) =P(Y1Mt = 1)

P(Y0Mt = 1)=

∑x P(Y1Mt = 1)P(X = x)∑x P(Y0Mt = 1)P(X = x)

NIERD(t·) =P(YtM1

= 1)

P(YtM0= 1)

=

∑x P(YtM1

= 1)P(X = x)∑x P(YtM0

= 1)P(X = x)47 / 53

Binary outcome and binary mediator: marginal effects– regression-based simulation

The strategy just mentioned is not currently implemented in any software.

Marginal RD-scale effects can be obtained using regression-based simulation

with the R package mediation:

library(mediation)

mod.m <- glm(bully ~ minority + grade + age + gender + hhses,

family=binomial, data=yrbs)

mod.y <- glm(suicAttmpt ~ minority*bully + grade + age + gender +

hhses, family=binomial, data=yrbs)

out <- mediate(mod.m, mod.y, sims=1000, boot=true, treat="minority",

mediator = "bully")

summary(out)

48 / 53

Binary outcome and binary mediator: conditional effects– regression with analytic results (VanderWeele & Vansteelandt 2010)

If the outcome is rare, assume logistic models for the potential outcomes andpotential mediators.

Under identifying assumptions, estimate parameters using regression models:

logit[P(M = 1|T = t,X = x)] = α0 + α1t + α2x

logit[P(Y = 1|T = t,M = m,X = x)] = β0 + β1t + β2m + β3tm + β4x

Conditional OR-scale controlled direct effect (not requiring the rare outcomeassumption):

CDEOR(m|X = x) =odds(Y1m = 1 vs 0|X = x)

odds(Y0m = 1 vs 0|X = x)= eβ1+β3m

Conditional OR-scale natural direct and indirect effects are approximated asbelow (rare outcome needed for approximation):

NDEOR(·t|X = x) =odds(Y1Mt = 1 vs 0|X = x)

odds(Y0Mt = 1 vs 0|X = x)≈

eβ1 (1 + eβ2+β3+α0+α1t+α2x )

1 + eβ2+α0+α1t+α2x

NIEOR(t · |X = x) =odds(Y1M1

= 1 vs 0|X = x)

odds(YtM0= 1 vs 0|X = x)

≈(1 + eα0+α2x )(1 + eβ2+β3t+α0+α1+α2x )

(1 + eα0+α1+α2x )(1 + eβ2+β3t+α0+α2x )

49 / 53

Binary outcome and binary mediator: conditional effects– regression with analytic results (VanderWeele & Vansteelandt 2010)

If the outcome is not rare, assume a log-linear model for the potentialoutcomes and a logistic (?) model for the potential mediators.

Under identifying assumptions, estimate parameters using regression models:

logit[P(M = 1|T = t,X = x)] = α0 + α1t + α2x

log[P(Y = 1|T = t,M = m,X = x)] = β0 + β1t + β2m + β3tm + β4x

Conditional RR-scale controlled direct effect:

CDERR(m|X = x) =odds(Y1m = 1 vs 0|X = x)

odds(Y0m = 1 vs 0|X = x)= eβ1+β3m

Conditional RR-scale natural direct and indirect effects:

NDERR(·t|X = x) =odds(Y1Mt = 1 vs 0|X = x)

odds(Y0Mt = 1 vs 0|X = x)=

eβ1 (1 + eβ2+β3+α0+α1t+α2x )

1 + eβ2+α0+α1t+α2x

NIERR(t · |X = x) =odds(Y1M1

= 1 vs 0|X = x)

odds(YtM0= 1 vs 0|X = x)

=(1 + eα0+α2x )(1 + eβ2+β3t+α0+α1+α2x )

(1 + eα0+α1+α2x )(1 + eβ2+β3t+α0+α2x )

50 / 53

Binary outcome and binary mediator: conditional effects –

regression w/ analytic results

SAS macro mediation (SPSS and Stata similar):

If the outcome is rare:

%mediation(data=yrbs, yvar=suicAttmpt, avar=minority, mvar=bully,

cvar=grade11 grade12 age gender hhses2 hhses3 hhses4,

a0=0, a1=1, nc=8, yreg=logit, mreg=logit, interaction=true,

boot=true)

run;

If the outcome is not rare:

%mediation(data=yrbs, yvar=suicAttmpt, avar=minority, mvar=bully,

cvar=grade11 grade12 age gender hhses2 hhses3 hhses4,

a0=0, a1=1, nc=8, yreg=loglinear, mreg=logit, interaction=true,

boot=true)

run;

51 / 53

Session overview

I Finish session 1

I Estimation methods for the single mediator caseI cases

I continuous outcome, with mediator of several kinds (continuous,binary/categorical, ordinal, or latent continuous)

I binary outcome, targeting effects on different scales (RD, RR, OR)that are marginal or conditional

I methods based on modeling the mediator and the outcomeI regression with analytical resultsI regression-based simulation

I next sessionI methods based on other combinations of modelsI survival outcome

52 / 53

References cited

Emsley RA, Liu H, Dunn G, Valeri L, VanderWeele TJ. (2014). PARAMED: A command to perform causal mediation analysis usingparametric models. Technical Report.

Imai K, Keele L, Tingley D. (2010). A general approach to causal mediation analysis. Psychological Methods, 15(4):309-34.

Imai K, Keele L, Tingley D, et al. (2010b). Causal mediation analysis using R. Lecture Notes in Statistics. 196:129-154.

Imai K, Keele L, Tingley D, et al. (2013). Causal Mediation Analysis Using R. (An old version on CRAN)

Muthen BO. (2011). Applications of Causally Defined Direct and Indirect Effects in Mediation Analysis using SEM in Mplus.(http://www.statmodel2.com/download/causalmediation.pdf)

Pearl J. (2012) The causal mediation formula–a guide to the assessment of pathways and mechanisms. Prevention Science, 13(4):426-36.

Tingley D, Yamamoto T, Hirose K, et al. (2014). mediation: R Package for Causal Mediation Analysis. Journal of Statistical Software59(5):1-38.

Valeri L, VanderWeele TJ. (2013). Mediation analysis allowing for exposure-mediator interactions and causal interpretation: Theoreticalassumptions and implementation with SAS and SPSS macros. Psychological Methods. 18(2):137-150.

VanderWeele TJ. (2015). Explanation in Causal Inference: Methods for Mediation and Interaction. Oxford University Press: New York,NY.

VanderWeele TJ, Vansteelandt S. (2009). Conceptual issues concerning mediation, interventions and composition. Statistics and ItsInterface, 2:457-468.

VanderWeele TJ, Vansteelandt S. (2010). Odds ratios for mediation analysis for a dichotomous outcome. American Journal ofEpidemiology. 172(12):1339-1348.

53 / 53

Recommended