SlowGuess/NeurIPS_2023_OCR huggingface dataset:
Consider a structural causal model (SCM) with a treatment  $A$ , a mediator  $M$  and an outcome  $Y$  (Fig. 6a). We define the total causal effect (TE) of the treatment  $A$  on the outcome  $Y$  as the difference between setting the treatment  $A$  to a target treatment value  $\tilde{a}$  and no treatment  $\varnothing$  [Pearl, 2009]:
$$
\operatorname {T E} (\tilde {a}) = Y [ \tilde {a} ] - Y [ \varnothing ],
$$
where we use the short-hand notation  $[\tilde{a}]$  to denote an intervention:  $[\tilde{a}]\equiv \mathrm{do}(A = \tilde{a})$
In many situations, the total effect does not capture the target of the scientific investigation. For instance, in the surgery-diet-glucose (treatment-mediator-outcome) example of Section 5.1, we examine how much of the surgery's effect is due to the post-surgery diet or the rest of the metabolic processes. This question can be formulated as a causal (mediation) query, where we estimate the indirect effect flowing through the mediator  $M(A \to M \to Y)$ , separately from the direct effect flowing
through the path  $A \to Y$ . To measure the effect of a specific path, one can devise a pair of interventions on the treatment  $A$  and the mediator  $M$  so that only the specific target path is 'active'. A straightforward implementation of this idea leads to the definition of the controlled direct effect [CDE, Pearl, 2001]
(a) Classical.
Figure 6: Graphical models for causal mediation. Mediation is defined in (a) using nested counterfactuals, while in (b) using path-specific treatments  $A_{\rightarrow M}$  and  $A_{\rightarrow Y}$ .
$$
\begin{array}{l} \mathrm {C D E} (\tilde {a}, \tilde {m}) = Y [ A = \tilde {a}, M = \tilde {m} ] - Y [ A = \varnothing , M = \tilde {m} ] \\ = Y [ \tilde {a}, \tilde {m} ] - Y [ \varnothing , \tilde {m} ], \tag {11} \\ \end{array}
$$
where  $[\tilde{a},\tilde{m} ]$  denotes a pair of interventions on  $A$  and  $M$ :  $[\tilde{a},\tilde{m} ]\equiv \mathrm{do}(A = \tilde{a},M = \tilde{m})$ . The CDE is intuitively defined in Eq. (11) as the difference of the outcome  $Y$  when the mediator  $M$  is fixed to  $\tilde{m}$  while the treatment  $A$  is either  $\tilde{a}$  or  $\varnothing$ . In the surgery-diet-glucose example, this corresponds to the difference in the outcome  $Y$  while the patient is set to either (i) the surgery  $\tilde{a}$  and a certain diet  $\tilde{m}$  or (ii) no surgery  $\varnothing$  and the same diet  $\tilde{m}$ . Hence,  $\mathrm{CDE}(\tilde{a},\tilde{m})$  has a prescriptive interpretation as we prescribe both  $A$  and  $M$  to external intervention values, in contrast to the attributive interpretation that we are after to understand the underlying causal mechanisms [Pearl, 2001].
To understand the underlying causal mechanisms, we rather want to estimate the contribution of direct and indirect paths to the total causal effect. To achieve this, Pearl [2001] defines the natural direct effect (NDE) and the natural indirect effect (NIE). In natural effects, we devise a pair of interventions such that it sets a target path to a target intervention value while keeping the other path fixed in its natural state, i.e., the state that it would have attained without our external 'do'-intervention. Traditionally, the NDE and NIE are defined as a contrast between nested counterfactuals [Pearl, 2001]. Accordingly, the NDE is
$$
\begin{array}{l} \mathrm {N D E} (\tilde {a}) = Y [ A = \tilde {a}, M = \tilde {m} _ {[ A = \varnothing ]} ] - Y [ A = \varnothing , M = \varnothing ] \\ = Y [ \tilde {a}, \tilde {m} _ {[ A = \varnothing ]} ] - Y [ \varnothing , \varnothing ], \tag {12} \\ \end{array}
$$
where  $[\tilde{a},\tilde{m}_{[A = \emptyset ]}]\equiv \mathrm{do}(A = \tilde{a},M = \tilde{m}_{\mathrm{do}(A = \emptyset)})$  denotes a pair of interventions on  $A$  and  $M$  where the treatment  $A$  is set to  $\tilde{a}$  and the mediator  $M$  is set to  $\tilde{m}_{[A = \emptyset ]}$ , the value  $M$  would have attained without our doing any intervention on the treatment  $[A = \emptyset ]$ , i.e., no treatment. The counterfactual outcome  $Y[\tilde{a},\tilde{m}_{[A = \emptyset ]}]$  is called 'nested' since we set the treatment to two distinct values  $\tilde{a}$  and  $\varnothing$  for the same individual data point  $Y$ , which is not possible in a real-world scenario. Similarly, the NIE is
$$
\begin{array}{l} \mathrm {N I E} (\tilde {a}) = Y [ A = \tilde {a}, M = \tilde {m} _ {[ A = \tilde {a} ]} ] - Y [ A = \tilde {a}, M = \tilde {m} _ {[ A = \varnothing ]} ] \\ = Y [ \tilde {a}, \tilde {m} _ {[ A = \tilde {a} ]} ] - Y [ \tilde {a}, \tilde {m} _ {[ A = \varnothing ]} ]. \tag {13} \\ \end{array}
$$
The NDE and NIE with nested counterfactuals are identifiable under the following causal assumptions [Pearl, 2001, 2014, Imai et al., 2010b]:
$$
\begin{array}{l} (\mathbf {S A 1}): \quad p (\cdot | \operatorname {d o} (A = \tilde {a})) \equiv p (\cdot | A = \tilde {a}), \\ (\mathbf {S A 2}): \quad Y [ \tilde {a} _ {1}, \tilde {m} ] \perp M [ \tilde {a} _ {2} ]. \\ \end{array}
$$
The static assumption (SA1) states that there is no unobserved confounding (NUC) between the pairs \((A, M)\) and \((A, Y)\). Pearl [2014] interprets the static assumption (SA2) as the mediator-outcome relationship is deconfounded while keeping the treatment \(A\) fixed. Under these assumptions, the distribution of the counterfactual outcome \(Y[\tilde{a}, \tilde{m}_{[A = \emptyset]}\]\n\n
$$
P \left(Y [ \tilde {a}, \tilde {m} _ {[ A = \varnothing ]} ]\right) = \sum_ {m ^ {*}} P (Y \mid A = \tilde {a}, M = m ^ {*}) P (M = m ^ {*} \mid A = \varnothing). \tag {14}
$$
A.2 Dynamic Causal Mediation (with a Single Intervention)
We extend the static definitions of natural direct and indirect effects by formulating them as stochastic processes over a period  $[0, T]$ . This leads to a definition of dynamic causal mediation. For each patient, we define (i) a treatment process  $A$  that occurs only once at time  $t_a \in [0, T]$ , (ii) a mediator process  $M$  that is observed at  $I$  irregularly-sampled time points:  $\{(t_i, m_i)\}_{i=1}^I$ , and (iii) an outcome process  $Y$  that is observed at  $J$  irregularly-sampled time points:  $\{(t_j, y_j)\}_{j=1}^J$ . For a detailed problem formulation, see Section 2.1.
The identifiability in the nested-counterfactual based mediation is only possible if there exist no post-treatment confounders, i.e., confounder variables between a mediator and an outcome must not be causally affected by the treatment [Pearl, 2014]. However, in dynamic causal mediation, past mediators and outcomes causally affect future mediators and outcomes. This means that a past outcome measurement acts as a post-treatment confounder for a future mediator and a future outcome, and the NDE and NIE are non-identifiable without further assumptions [Pearl, 2014, Didelez, 2019].
To work around the post-treatment confounding problem, Zeng et al. [2021] assume that there exists no interaction from past outcomes to future mediators (See Fig. 2a). However, in a real-world healthcare setup, the mediator and outcome processes most likely interact, e.g., past glucose levels should affect future glucose levels as well as future meals. To overcome this limitation, we follow an interventionist approach to the causal mediation [Robins et al., 2022], similar to Didelez [2019], Aalen et al. [2020]. In this approach, we hypothetically duplicate the treatment  $A$  into two path-specific treatments: the direct-path treatment  $A_{\rightarrow Y}$  and the indirect-path treatment  $A_{\rightarrow M}$  (Fig. 6b). For instance, in the surgery-diet-glucose example, the direct-path treatment  $A_{\rightarrow Y}$  corresponds to changing only the metabolic processes (other than the diet), without affecting the diet. Using path-specific interventions  $A_{\rightarrow M}$  and  $A_{\rightarrow Y}$ , we define the NDE as
$$
\begin{array}{l} \mathrm {N D E} (\tilde {t} _ {a}) \equiv \boldsymbol {Y} _ {> \tilde {t} _ {a}} [ A _ {\rightarrow Y} = \tilde {t} _ {a}, A _ {\rightarrow M} = \tilde {t} _ {a} ] - \boldsymbol {Y} _ {> \tilde {t} _ {a}} [ A _ {\rightarrow Y} = \varnothing , A _ {\rightarrow M} = \tilde {t} _ {a} ] \\ \equiv \mathbf {Y} _ {> \tilde {t} _ {a}} [ \tilde {t} _ {a}, \tilde {t} _ {a} ] - \mathbf {Y} _ {> \tilde {t} _ {a}} [ \varnothing , \tilde {t} _ {a} ], \tag {15} \\ \end{array}
$$
where  $Y[\tilde{a}_1, \tilde{a}_2]$  is the potential outcome after setting the direct-path treatment  $A_{\rightarrow Y}$  to  $\tilde{a}_1$  and the indirect-path treatment  $A_{\rightarrow M}$  to  $\tilde{a}_2$ . Similarly, the NIE is defined as
$$
\begin{array}{l} \mathrm {N I E} \left(\tilde {t} _ {a}\right) \equiv \mathbf {Y} _ {> \tilde {t} _ {a}} [ A _ {\rightarrow Y} = \varnothing , A _ {\rightarrow M} = \tilde {t} _ {a} ] - \mathbf {Y} _ {> \tilde {t} _ {a}} [ A _ {\rightarrow Y} = \varnothing , A _ {\rightarrow M} = \varnothing ] \\ \equiv \mathbf {Y} _ {> \tilde {t} _ {a}} [ \varnothing , \tilde {t} _ {a} ] - \mathbf {Y} _ {> \tilde {t} _ {a}} [ \varnothing , \varnothing ]. \tag {16} \\ \end{array}
$$
Accordingly, we define the total effect as follows
$$
\mathrm {T E} \left(\tilde {t} _ {a}\right) = \mathrm {N D E} \left(\tilde {t} _ {a}\right) + \mathrm {N I E} \left(\tilde {t} _ {a}\right) = \mathbf {Y} _ {\geqslant \tilde {t} _ {a}} \left[ \tilde {t} _ {a}, \tilde {t} _ {a} \right] - \mathbf {Y} _ {\geqslant \tilde {t} _ {a}} [ \varnothing , \varnothing ]. \tag {17}
$$
A.2.1 Causal Assumptions
To identify the NDE and the NIE, we make the causal assumptions (A1, A2, A3):
Assumption A1: Continuous-time NUC. There are no unobserved confounders (NUC) between the treatment-mediator process pair  $(A, M)$  and the treatment-outcome process pair  $(A, Y)$ , i.e., the treatment is randomized. Hence, the interventional distribution of a treatment intervention and the conditional distribution of those who got treated are equivalent:
$$
p (\cdot \mid \operatorname {d o} (\boldsymbol {A} = \tilde {\boldsymbol {N}} _ {A})) \equiv p (\cdot \mid \boldsymbol {A} = \tilde {\boldsymbol {N}} _ {A}). \tag {18}
$$
Assumption A2: Local Independence of Mediator  $M$  and a Single Direct-Path Treatment  $\mathbf{A}_{\rightarrow Y}$ . Conditioned on the history  $\mathcal{H}_{<\tau}$  of the mediator and outcome processes up until time  $\tau$ , the mediator process  $M$  is independent of the direct-path treatment  $\mathbf{A}_{\rightarrow Y}$  locally at time  $\tau$ , for all times  $\tau \in [0, T]$ :
$$
\boldsymbol {A} _ {\rightarrow Y} \perp \perp M (\tau) \mid \boldsymbol {A} _ {\rightarrow M}, \mathcal {H} _ {<   \tau}, \quad \tau \in [ 0, T ]. \tag {19}
$$
Hence, there are no direct arrows from the direct-path treatment  $A_{\rightarrow Y}$  to the mediator process  $M$
Assumption A3: Local Independence of Outcome  $Y$  and a Single Indirect-Path Treatment  $A_{\rightarrow M}$ . Conditioned on the history  $\mathcal{H}_{<\tau}$  of the mediator and outcome processes up until time  $\tau$ , the outcome process  $Y(\tau)$  is independent of the indirect-path treatment  $A_{\rightarrow M}$  locally at time  $\tau$ , for all time  $\tau \in [0, T]$ :
$$
\boldsymbol {A} _ {\rightarrow M} \perp Y (\tau) \mid \boldsymbol {A} _ {\rightarrow Y}, \mathcal {H} _ {<   \tau}, \quad \tau \in [ 0, T ]. \tag {20}
$$
Hence, there are no direct arrows from the indirect-path treatment  $A_{\rightarrow M}$  to the outcome process  $\pmb{Y}$ .
The static version of the NUC assumption in (A1) is common in the existing literature on longitudinal causal mediation [Didelez, 2019, Aalen et al., 2020]. Here, we define it as a continuous-time NUC [Schulam and Saria, 2017] for completeness, as we also define the treatment  $A$  as a process in Section 2.1. (A2, A3) state that the path-specific treatments  $A_{\rightarrow Y}$  and  $A_{\rightarrow M}$  causally affect only their target path for a given time  $\tau$  conditioned on the past history. They can be seen as the continuous-time generalizations of the similar causal assumptions provided for discrete-time mediator-outcome measurements  $(M_1, Y_1, M_2, Y_2, \ldots, M_n, Y_n)$  in Didelez [2019] and Aalen et al. [2020]. An interesting connection is between (A2, A3) and the notion of local independence [Didelez, 2006, 2008, 2015], a dynamic interpretation of independence that is the continuous-time version of Granger causality [Granger, 1969]. In this regard, (A2, A3) state that the processes  $M$  and  $Y$  are locally independent of the direct- and indirect-path treatments  $A_{\rightarrow Y}$  and  $A_{\rightarrow M}$  respectively, given the history of the rest of the processes. Furthermore, (A2, A3) imply that there are no (continuous-time) unobserved confounders between the mediator and outcome processes, otherwise an unobserved confounder between them would render the process  $Y$  (or  $M$ ) and  $A_{\rightarrow M}$  (or  $A_{\rightarrow Y}$ ) dependent as we condition on the past history (See Didelez [2019] for a detailed explanation).
A.2.2 Proof of the Identifiability Result
For the total effect, we need to estimate the trajectories  $\mathbf{Y}_{\geqslant \tilde{t}_a}[\tilde{t}_a,\tilde{t}_a]$  and  $\mathbf{Y}_{\geqslant \tilde{t}_a}[\varnothing ,\varnothing ]$ , which are identifiable under (A1). For direct and indirect effects, we further need to estimate the counterfactual trajectory  $\mathbf{Y}_{> \tilde{t}_a}[\varnothing ,\tilde{t}_a]$ , i.e., the outcome process under a hypothetical intervention, which is identifiable under (A1, A2, A3). In the following, we show the identification result for the outcome process under a hypothetical intervention  $\mathbf{Y}_{>\tilde{t}_a}[\varnothing ,\tilde{t}_a]$ , since it is a generalization of the 'factual' trajectories  $\mathbf{Y}_{>\tilde{t}_a}[\tilde{t}_a,\tilde{t}_a]$  and  $\mathbf{Y}_{>\tilde{t}_a}[\varnothing ,\varnothing ]$ .
We consider a counterfactual trajectory  $\mathbf{Y}_{>\tilde{t}_a}$  under a paired intervention, e.g.  $[\varnothing ,\tilde{t}_a]$ , at  $R$  ordered query points  $\mathbf{q} = \{q_r\}_{r = 1}^R$ ,  $q_{r} > \tilde{t}_{a}$ :  $\mathbf{Y}_{\mathbf{q}}[\varnothing ,\tilde{t}_a] = \{Y(q_r)[\varnothing ,\tilde{t}_a]\}_{r = 1}^R$ . We start by explicitly writing the interventional trajectory in do-notation:
$$
P \left(\mathbf {Y} _ {\mathbf {q}} [ \varnothing , \tilde {t} _ {a} ]\right) = P \left(\mathbf {Y} _ {\mathbf {q}} \mid \operatorname {d o} \left(t _ {A _ {\rightarrow Y}} = \varnothing , t _ {A _ {\rightarrow M}} = \tilde {t} _ {a}\right)\right).
$$
Let  $M_{[q_r,q_{r + 1})}$  denote the mediator occurrences between two consecutive query points  $q_{r}$  and  $q_{r + 1}$  and  $M_{>\tilde{t}_a} = \cup_{r = 0}^{R - 1}M_{[q_r,q_{r + 1})}$ . We include the mediator process  $M_{> \tilde{t}_a}$  to the counterfactual trajectory  $Y_{\mathbf{q}}[\varnothing ,\tilde{t}_a]$ , and write the conditional distributions of  $Y_{\mathbf{q}}$  and  $M_{>\tilde{t}_a}$  using a factorization in temporal order:
$$
P \left(\mathbf {Y} _ {\mathbf {q}} [ \varnothing , \tilde {t} _ {a} ]\right) = \sum_ {M > \tilde {t} _ {a}} \prod_ {r = 0} ^ {R - 1} P \left( \right.Y _ {q _ {r + 1}} \mid \mathrm {d o} \left(t _ {A \rightarrow Y} = \varnothing , t _ {A \rightarrow M} = \tilde {t} _ {a}\right), M _ {\left[ \right. q _ {r}, q _ {r + 1}\left. \right)}, \mathcal {H} _ {\leq q _ {r}}\left. \right)
$$
$$
P \left(M _ {\left[ q _ {r}, q _ {r + 1} \right]}\right) \mathrm {d o} \left(t _ {A \rightarrow Y} = \varnothing , t _ {A \rightarrow M} = \tilde {t} _ {a}\right), \mathcal {H} _ {\leq q _ {r}}), \tag {21}
$$
where  $q_0 = \tilde{t}_a$  and  $\mathcal{H}_{\leq q_r}$  denotes the history that contains the past information on the path-specific treatments  $(A_{\rightarrow M}, A_{\rightarrow Y})$  and past mediators up to (non-inclusive)  $q_r$ , and past outcomes up until (inclusive)  $q_r$ :  $\mathcal{H}_{\leq q_r} = A_{\rightarrow M} \cup A_{\rightarrow Y} \cup \{(t_i, m_i) : t_i < q_r\} \cup \{(t_j, y_j) : t_j \leq q_r\}$ .
(A3) states that the outcome  $Y(q_{r + 1})$  is independent of the indirect-path treatment  $A\rightarrow M$  conditioned on the past history  $\mathcal{H}_{< q_{r + 1}}$  including the direct-path treatment  $A\to Y$ . Hence, we can change the value of the intervention on  $t_{A\to M}$  without changing the first conditional distribution term in Eq. (21). Using (A3), we re-write Eq. (21) as
$$
P \left(\mathbf {Y} _ {\mathbf {q}} [ \varnothing , \tilde {t} _ {a} ]\right) = \sum_ {M _ {> \tilde {t} _ {a}}} \prod_ {r = 0} ^ {R - 1} P \left(Y _ {q _ {r + 1}} \mid \mathrm {d o} \left(t _ {A _ {\rightarrow Y}} = \varnothing , t _ {A _ {\rightarrow M}} = \varnothing\right), M _ {[ q _ {r}, q _ {r + 1})}, \mathcal {H} _ {\leq q _ {r}}\right)
$$
$$
P \left( \right.M _ {\left[ \right. q _ {r}, q _ {r + 1}\left. \right)} \mid \mathrm {d o} \left(t _ {A \rightarrow Y} = \varnothing , t _ {A \rightarrow M} = \tilde {t} _ {a}\right), \mathcal {H} _ {\leq q _ {r}}\left. \right). \tag {22}
$$
Similarly, (A2) states that the mediators  $M_{[q_r,q_{r + 1})}$  are independent of the direct-path treatment  $A\to Y$  conditioned on the past history  $\mathcal{H}_{< q_r}$  including the indirect-path treatment  $A\rightarrow M$ . Using (A2), we re-write Eq. (22) as
$$
P \left(\mathbf {Y} _ {\mathbf {q}} [ \varnothing , \tilde {t} _ {a} ]\right) = \sum_ {\mathbf {M} _ {> \tilde {t} _ {a}}} \prod_ {r = 0} ^ {R - 1} P \left( \right.Y _ {q _ {r + 1}} \mid \mathrm {d o} \left(t _ {A \rightarrow Y} = \varnothing , t _ {A \rightarrow M} = \varnothing\right), M _ {\left[ \right. q _ {r}, q _ {r + 1}\left. \right)}, \mathcal {H} _ {\leq q _ {r}}\left. \right)
$$
$$
P \left( \right.M _ {\left[ \right. q _ {r}, q _ {r + 1}\left. \right)} \left. \right\rvert   \mathrm {d o} \left(t _ {A _ {\rightarrow Y}} = \tilde {t} _ {a}, t _ {A _ {\rightarrow M}} = \tilde {t} _ {a}\right), \mathcal {H} _ {\leq q _ {r}}). \tag {23}
$$
In Eq. (23), the target quantities are considered under 'factual' intervention pairs:
$$
\mathrm {d o} \left(t _ {A \rightarrow Y} = \varnothing , t _ {A \rightarrow M} = \varnothing\right) \equiv \mathrm {d o} \left(t _ {A} = \varnothing\right), \tag {24}
$$
$$
\mathrm {d o} \left(t _ {A \rightarrow Y} = \tilde {t} _ {a}, t _ {A \rightarrow M} = \tilde {t} _ {a}\right) \equiv \mathrm {d o} \left(t _ {A} = \tilde {t} _ {a}\right). \tag {25}
$$
Using Eqs. (24) and (25), we can simplify Eq. (23) as follows:
$$
P \left(\boldsymbol {Y} _ {\mathbf {q}} [ \varnothing , \tilde {t} _ {a} ]\right) = \sum_ {M _ {> \tilde {t} _ {a}}} \prod_ {r = 0} ^ {R - 1} P \left(Y _ {q _ {r + 1}} \mid \mathrm {d o} (t _ {A} = \varnothing), M _ {[ q _ {r}, q _ {r + 1})}, \mathcal {H} _ {\leq q _ {r}}\right)
$$
$$
P \left(M _ {\left[ q _ {r}, q _ {r + 1}\right)} \mid \mathrm {d o} \left(t _ {A} = \tilde {t} _ {a}\right), \mathcal {H} _ {\leq q _ {r}}\right). \tag {26}
$$
In Eq. (26), both terms in the product correspond to the mediator and outcome processes under the interventions  $[\varnothing ]$  and  $[\tilde{t}_o]$  respectively. These interventional distributions are identified under (A1), as it states that there are no unobserved confounders between the process pairs  $(A,M)$  and  $(A,Y)$ . Using (A1) on Eq. (26), we obtain the final identification result:
$$
P \left(\mathbf {Y} _ {\mathbf {q}} [ \varnothing , \tilde {t} _ {a} ]\right) = \sum_ {M > \bar {t} _ {a}} \prod_ {r = 0} ^ {R - 1} \underbrace {P \left(Y _ {q _ {r + 1}} \mid t _ {A} = \varnothing , M _ {[ q _ {r} , q _ {r + 1})} , \mathcal {H} _ {\leq q _ {r}}\right)} _ {\text {o u t c o m e t e r m ●}} \underbrace {P \left(M _ {[ q _ {r} , q _ {r + 1})} \mid t _ {A} = \tilde {t} _ {a} , \mathcal {H} _ {\leq q _ {r}}\right)} _ {\text {m e d i a t o r i n t e n s i t y ●}}. \tag {27}
$$
To estimate the direct and indirect effects, we model the two terms in Eq. (27) with an interacting mediator-outcome model.
A.3 Dynamic Causal Mediation (Generalization to a Treatment Sequence)
In this section, we extend the dynamic causal mediation definitions to multiple treatments. To achieve this, we define the treatment as a non-binary, non-unitary process  $\mathbf{A}:[0,T] \to \mathbb{N} \times \{\mathbb{R} \cup \{\varnothing\} \}$  similar to the mediator process  $M$ . Here, the difference between two processes  $\mathbf{A}$  and  $M$  is that we consider  $\mathbf{A}$  to be a known, deterministic sequence, while  $M$  to be unknown and stochastic. Hence, we assume that the treatment process  $\mathbf{A}$  is given as a sequence  $\mathbf{a} = \{a_n\}_{n=1}^N$ , where each treatment  $a_n = (t_n, d_n)$  is a tuple of a treatment time  $t_n \in [0,T]$  and a treatment type/dosage marker  $d_n \in \mathcal{A}$ . The type/dosage space can be chosen as a discrete space  $\mathcal{A} = \mathbb{Z}$  representing a set of treatment types, a continuous space  $\mathcal{A} = \mathbb{R}$  representing a set of dosages, or a combination of both spaces  $\mathcal{A} = \mathbb{N} \times \mathbb{R}$ .
We again hypothetically duplicate the treatment process  $\mathbf{A}$  into two path-specific treatment sequences: the direct-path treatments  $\mathbf{A}_{\rightarrow Y}$  and the indirect-path treatments  $\mathbf{A}_{\rightarrow M}$  (Fig. 6b). Using path-specific interventions  $\mathbf{A}_{\rightarrow M}$  and  $\mathbf{A}_{\rightarrow Y}$ , we define the NDE as
$$
\begin{array}{l} \mathrm {N D E} (\tilde {\mathbf {a}} _ {1}, \tilde {\mathbf {a}} _ {0}) \equiv Y _ {> \tilde {t} _ {a}} [ \boldsymbol {A} _ {\rightarrow Y} = \tilde {\mathbf {a}} _ {1}, \boldsymbol {A} _ {\rightarrow M} = \tilde {\mathbf {a}} _ {1} ] - Y _ {> \tilde {t} _ {a}} [ \boldsymbol {A} _ {\rightarrow Y} = \tilde {\mathbf {a}} _ {0}, \boldsymbol {A} _ {\rightarrow M} = \tilde {\mathbf {a}} _ {1} ] \\ \equiv \mathbf {Y} _ {> \tilde {t} _ {a}} [ \tilde {\mathbf {a}} _ {1}, \tilde {\mathbf {a}} _ {1} ] - \mathbf {Y} _ {> \tilde {t} _ {a}} [ \tilde {\mathbf {a}} _ {0}, \tilde {\mathbf {a}} _ {1} ], \tag {28} \\ \end{array}
$$
where  $Y[\tilde{\mathbf{a}}_0, \tilde{\mathbf{a}}_1]$  is the potential outcome after setting the direct-path treatment sequence  $A_{\rightarrow Y}$  to  $\tilde{\mathbf{a}}_0 = \{a_{0,1}, a_{0,2}, \ldots, a_{0,N_0}\}$  and the indirect-path treatment sequence  $A_{\rightarrow M}$  to  $\tilde{\mathbf{a}}_1 = \{a_{1,1}, a_{1,2}, \ldots, a_{1,N_1}\}$ . Similarly, the NIE is defined as
$$
\begin{array}{l} \mathrm {N I E} (\tilde {\mathbf {a}} _ {1}, \tilde {\mathbf {a}} _ {0}) \equiv Y _ {> \tilde {t} _ {a}} [ \boldsymbol {A} _ {\rightarrow Y} = \tilde {\mathbf {a}} _ {0}, \boldsymbol {A} _ {\rightarrow M} = \tilde {\mathbf {a}} _ {1} ] - Y _ {> \tilde {t} _ {a}} [ \boldsymbol {A} _ {\rightarrow Y} = \tilde {\mathbf {a}} _ {0}, \boldsymbol {A} _ {\rightarrow M} = \tilde {\mathbf {a}} _ {0} ] \\ \equiv \mathbf {Y} _ {> \tilde {t} _ {a}} \left[ \tilde {\mathbf {a}} _ {0}, \tilde {\mathbf {a}} _ {1} \right] - \mathbf {Y} _ {> \tilde {t} _ {a}} \left[ \tilde {\mathbf {a}} _ {0}, \tilde {\mathbf {a}} _ {0} \right]. \tag {29} \\ \end{array}
$$
$$
\mathrm {T E} \left(\tilde {\mathbf {a}} _ {1}, \tilde {\mathbf {a}} _ {0}\right) = \mathrm {N D E} \left(\tilde {\mathbf {a}} _ {1}, \tilde {\mathbf {a}} _ {0}\right) + \mathrm {N I E} \left(\tilde {\mathbf {a}} _ {1}, \tilde {\mathbf {a}} _ {0}\right) = \boldsymbol {Y} _ {> \tilde {t} _ {a}} \left[ \tilde {\mathbf {a}} _ {1}, \tilde {\mathbf {a}} _ {1} \right] - \boldsymbol {Y} _ {> \tilde {t} _ {a}} \left[ \tilde {\mathbf {a}} _ {0}, \tilde {\mathbf {a}} _ {0} \right]. \tag {30}
$$
A.3.1 Causal Assumptions
To identify the NDE and the NIE, we make the causal assumptions (A4, A5, A6):
Assumption A4: Continuous-time NUC [Hizh et al., 2023]. Let sequential treatments a occur at a discrete set of time points on a given interval, characterized by the conditional intensity function  $\lambda_{a}^{*}(t,d)$ . The conditional treatment intensity  $\lambda_{a}^{*}(t,d)$  of a treatment  $a = (t,d)$ , is independent of the potential outcome trajectory  $\mathbf{Y}_{> \tau}[\tilde{\mathbf{a}}]$ , conditioned on the past history  $\mathcal{H}_{< \tau}$ ,  $\forall t \in \mathbb{R}_{\geq 0}$ , where the history  $\mathcal{H}_{< \tau}$  contains the past treatments, mediators and outcomes.