following this one were included into the mediator model. Next, we assessed whether there were important (i) treatment-baseline/longitudinal covariate interactions, (ii) time-baseline covariate interactions and (iii) baseline covariate-covariate interactions that should be adjusted for. For each step, an independent LASSO variable selection process was performed to select the most important interaction terms from all possible interactions of the same type. The interactions that were chosen in the previous step were always included in the model of the subsequent steps (which implies no shrinkage on these terms in the subsequent steps). The tuning parameter in each LASSO procedure was selected by leave-one-out cross-validation. The final model was refitted before calculating the mediation weights.

To derive the censoring weights, we first considered a cause-specific proportional hazard model adjusting for $M_{k}$, $L_k$, the exposure $A$ and the main effects of all baseline covariates $L_0$. To assess whether the censoring hazard at time $t$ had a residual dependence upon the history of $M$ and $L$ that preceded the time $t_{k}$ for $M$ and for $L$, we implemented a backward elimination process, using the Akaike information criterion to determine the first post-baseline measurement of $M$ and $L$ that were predictive for the censoring hazard at 