with (i) a time-to-event endpoint $T_i$ and (ii) an index $D_i$ specifying whether the main event ($D_i = 1$) or the competing one ($D_i = 2$) happens. Denote $t_k$, $k = 1\ldots K$ the fixed time point after the onset of the exposure at which the measurements of $M_k$ and $L_k$ are pre-planned for all patients. Assume that these measurements are only recorded until the last visit $K$ or until event $D_i = 1$ or $D_i = 2$ happens, whichever comes first. The time-to-event endpoint may be censored administratively or due to loss to follow-up, in which case $D_i = 0$.

The causal diagram in figure 1 depicts the relationships between the variables over time. It also represents a non-parametric structural equation model with independent errors. In the diagram, $L_k$ includes the indicator $I(T\ge t_k)$ of having survived visit $k$. Throughout, we will denote the history of measurements up to visit $k$ using a bar, i.e. $\overline{M}_k = (M_0, M_1,\ldots M_k)$.

To define the direct and indirect effects of interest, we will make use of so-called path-specific effects, expressed as a (cause-specific) hazard ratio. In particular, we define the counterfactual variables $T_{a,a^*}$ and $D_{a,a^*}$ as the time to the main 