$m_{23}$   $m_{13}$    $l_{23}$   $l_{13}$    $l_{03}$

  :  Extended data set for the example in Table 1[]{data-label="tab:ma"}

**Step 5–** Compute weights by applying the fitted models from steps 1 and 3 to the new data set. At visit $k$, the weight for the $i^{th}$ individual is $w_{i}(k, a,a^*) = w_{i}^{ttm}(a)\cdot w_{i}^{med}(k,a,a^*),$ where: $$w_i^{ttm}(a) = \sum_{a = 0}^{P-1} \frac{I(A_i = a)}{{\text{Pr}}(A_i = a|L_{0i} = l_{0i})}$$ and $$w_{i}^{med}(k,a,a^*) = \prod_{s: t_s \le t_k} \frac{{\text{Pr}}(M_{s,i} = m_{s,i}|A_i = a^*, \overline{M}_{s - 1,i} = \overline{m}_{s - 1,i}, \overline{L}_{s,i} = \bar{l}_{s,i}, T_i\ge t_s)}{{\text{Pr}}(M_{s,i} = m_{s,i}|A_i = a, \overline{M}_{s - 1,i} = \overline{m}_{s - 1,i}, \overline{L}_{s,i} =\overline{l}_{s,i}, T_i\ge t_s)}$$ where the subscript $ttm$ and $med$ denotes treatment and mediator, respectively. At the end of the follow-up time, the weight for a patient having $T_i = t_i$ is $w_{i}(t_i, a,a^*) = w_{i}(\lfloor t_i \rfloor ,a,a^*)$.

**Step 6–** Fit the natural effect cause-specific proportional hazard model (1) and (2) by proportiona hazard regression of the cause-specific event time on $A$ and $A^*$ on the basis of the expanded data set, using the weights computed in the previous step.

**Step 7–** Derive confidence intervals for the parameters in model (1) and (2) by using the non-parametric bootstrap. For this, one first 