Solution (source code)

= Solution

<Causal mediation analysis> decomposes the <total causal effect> of an exposure into a pathway operating through a mediator and a pathway not operating through that mediator. Let $M(x)$ be the potential mediator under exposure $x$, and let $Y(x,m)$ be the potential outcome under exposure $x$ with mediator set to $m$. One conventional decomposition uses
$$
\operatorname{NDE}
=\mathbb E[Y(1,M(0))-Y(0,M(0))]
$$
for the <natural direct effect>, and
$$
\operatorname{NIE}
=\mathbb E[Y(1,M(1))-Y(1,M(0))]
$$
for the <natural indirect effect>. In words, the direct effect changes exposure while holding the mediator at the value it would naturally have under no exposure; the indirect effect changes only that natural mediator value while holding exposure fixed at one.