1 Introduction
2 Factual data structure
3 Counterfactual estimands
3.1 Total effect
3.2 Controlled direct effect
3.3 Separable effects
3.4 Estimands with composite outcomes
3.5 Estimands that condition on the event history
3.6 Principal stratum estimand
3.7 Natural direct effect
4 Choosing an estimand
5 Censoring
6 Identification of the causal estimands
6.1 Total effect
6.1.1 Graphical evaluation of the exchangeability conditions
6.2 Controlled direct effects
6.2.1 Graphical evaluation of the exchangeability conditions
6.3 Separable effects
6.3.1 Graphical evaluation of the identification conditions
6.4 Correspondence with continuous time estimands
6.4.1 Correspondence of identification conditions
Discrete quantity  Quantity in the counting process literature  

Counterfactual quantity  \(Y_k^{\overline{c}=0}\)  
\(D_k^{\overline{c}=0}\)  
Factual quantity  \(Y_k\)  \(N^c_{t_k}\) 
\(D_k\)  \(I(T^D \le t_k)\)  
Observed quantity  \(C_k\)  \(\int _0^{t_k} I(T^D\ge t)dC_t\) 
\(\sum _{j=1}^k I(C_{j}=0) \Delta Y_j\)  \(\int _0^{t_k} I(C\ge t)dN^c_t\)  
\(\sum _{j=1}^k I(C_{j}=0) \Delta D_j\)  \(\int _0^{t_k} I(C\ge t)dI(T^D \le t)\) 
6.4.2 Correspondence of identification formulas
Definition  Description  Alternative terminology 

\(E[Y_k^{a, \overline{c}=0}]\)  Expected event count without elimination of competing events  
\(E [Y_k^{a,\overline{d}=0,\overline{c}=0}]\)  Expected event count with elimination of competing events  
\(E[Y_{k}^{a_Y,a_D, \overline{c}=0}]\)  Expected event count under a decomposed treatment  Does not correspond to classical estimands 
6.4.3 Differences in interpretation
7 Estimation
7.1 Risk set estimators
7.2 Horvitz–Thompson and Hajek estimators

The estimator is generic in the sense that, given weight estimators it can be used to estimate the total effect, the controlled direct effect, and the separable effect, and other composite estimands (e.g. the ‘while alive’ strategy) as defined in Sect. 3.
Estimand  \(\varvec{ R_{t}^{i}},\varvec{ \overline{R}_{t}^{i}}\)  \(\varvec{ R_{t}^{i,D}}\)  \(\varvec{ \bar{\theta }^{i}_t }\) 

\(E[Y_k^{a,\overline{c}=0}]\)  \( R_{t}^{i} = {{\mathcal {W}}}_{C,t}^i \cdot W_A^{i}\)  1  1 
\(\overline{R}_{t}^{i} =\overline{ {\mathcal {W}} }_{C,t}^i \cdot \frac{1}{ \pi _A(A_i)}\)  −  1  
\(E[Y_k^{a,\overline{d}=\overline{c}=0}]\)  \( R_{t}^{i}= {{\mathcal {W}}}_{C,t}^i \cdot W_A^{i} \cdot {\mathcal {W}}_{D,t}^i\)  0  1 
\(\overline{R}_{t}^{i} = \overline{ {\mathcal {W}} }_{C,t}^i \cdot \frac{1}{ \pi _A(A_i)}\cdot \overline{{\mathcal {W}}}_{D,t}^i\)  −  1  
\(E[Y_k^{a_Y,a_D,\overline{c}=0}]\)  \(R_{t}^{i} = {{\mathcal {W}}}_{C,t}^i \cdot I(a=a_Y) W_A^{i} \cdot { {\mathcal {W}}}_{D,t}^i(a_Y,a_D) \cdot {{\mathcal {W}}}_{L_{D},t}^i(a_Y,a_D) \)  1  1 
\(\overline{R}_{t}^{i} =\overline{{\mathcal {W}}}_{C,t}^i \cdot \frac{ I(a=a_Y)}{\pi _A(A_i)} \cdot { {\mathcal {W}}}_{D,t}^i(a_Y,a_D) \cdot {{\mathcal {W}}}_{L_{D},t}^i(a_Y,a_D) \)  −  1  
\(R_{t}^{i} = {{\mathcal {W}}}_{C,t}^i \cdot I(a=a_D) W_A^{i} \cdot { {\mathcal {W}}}_{Y,t}^i(a_Y,a_D) \cdot {{\mathcal {W}}}_{L_{Y},t}^i(a_Y,a_D) \)  1  \(\theta _t^{Y,i}\)  
\(\overline{R}_{t}^{i} =\overline{{\mathcal {W}}}_{C,t}^i \cdot \frac{ I(a=a_D)}{\pi _A(A_i)} \cdot { {\mathcal {W}}}_{Y,t}^i(a_Y,a_D) \cdot {{\mathcal {W}}}_{L_{Y},t}^i(a_Y,a_D) \)  −  \(\theta _t^{Y,i}\)  
\(E[D_k^{a,\overline{c}=0}]\)  \( R_{t}^{i} = {{\mathcal {W}}}_{C,t}^i \cdot W_A^{i}\)  1  1 
\(\overline{R}_{t}^{i} =\overline{ {\mathcal {W}} }_{C,t}^i \cdot \frac{1}{ \pi _A(A_i)}\)  −  1  
\(E[D_k^{a_Y,a_D,\overline{c}=0}]\)  \(R_{t}^{i} = {{\mathcal {W}}}_{C,t}^i \cdot I(a=a_Y) W_A^{i} \cdot { {\mathcal {W}}}_{D,t}^i(a_Y,a_D) \cdot {{\mathcal {W}}}_{L_{D},t}^i(a_Y,a_D) \)  1  \(\theta _t^{D,i}\) 
\(\overline{R}_{t}^{i} =\overline{{\mathcal {W}}}_{C,t}^i \cdot \frac{I(a=a_Y)}{\pi _A(A_i)} \cdot { {\mathcal {W}}}_{D,t}^i(a_Y,a_D) \cdot {{\mathcal {W}}}_{L_{D},t}^i(a_Y,a_D) \)  −  \(\theta _t^{D,i}\)  
\(R_{t}^{i} = {{\mathcal {W}}}_{C,t}^i \cdot I(a=a_D) W_A^{i} \cdot { {\mathcal {W}}}_{Y,t}^i(a_Y,a_D) \cdot {{\mathcal {W}}}_{L_{Y},t}^i(a_Y,a_D) \)  1  1  
\(\overline{R}_{t}^{i} =\overline{{\mathcal {W}}}_{C,t}^i \cdot \frac{I(a=a_D)}{\pi _A(A_i)} \cdot { {\mathcal {W}}}_{Y,t}^i(a_Y,a_D) \cdot {{\mathcal {W}}}_{L_{Y},t}^i(a_Y,a_D) \)  −  1 
7.3 Estimating the weights

Solve (51) to obtain estimates of the weight processes.

Solve (47) to obtain \(\hat{Y}_t\) (and/or \(\hat{D}_t\)), which estimates the expected number of events under the chosen intervention at t.

Repeat the previous steps with a contrasting intervention on treatment to obtain the targeted causal contrast.

Evaluate the uncertainty of the estimators using nonparametric bootstrap.
R
packages \(\texttt {transform.hazards}\) and ahw
(available at github.com/palryalen/
). The code is found in the online supplementary material.Weight  Hazards in (50)  \(\bar{N}^i\) 

\(\overline{ {\mathcal {W}} }_{C,t}^i\)  \( \alpha _t^idt = P(t \le C^i < t+dtt \le T^{D,i}, t \le C^i, {\overline{L}}^i_{t}, {\overline{N}}^i_{t}, A^i) \)  \(I(C^i\le \cdot )\) 
\(\alpha _t^{*,i} dt = 0\)  
\({\mathcal {W}}_{C,t}^i\)  \( \alpha _t^idt = P(t \le C^i < t+dtt \le T^{D,i}, t \le C^i, {\overline{L}}^i_{t}, {\overline{N}}^i_{t}, A^i) \)  \(I(C^i\le \cdot )\) 
\(\alpha _t^{*,i} dt = P(t \le C^i < t+dtt \le T^{D,i}, t \le C^i, A^i) \)  
\( \overline{ {\mathcal {W}} }_{D,t}^i \)  \( \alpha _t^i dt = P(t \le T^{D,i} < t+dt t \le T^{D,i}, t \le C^i, {\overline{L}}^i_{t}, {\overline{N}}^i_{t},A^i) \)  \(N^{D,i}\) 
\( \alpha _t^{*,i} dt = 0 \)  
\({\mathcal {W}}_{D,t}^i\)  \( \alpha _t^i dt = P(t \le T^{D,i} < t+dt t \le T^{D,i}, t \le C^i, {\overline{L}}^i_{t}, {\overline{N}}^i_{t},A^i) \)  \(N^{D,i}\) 
\( \alpha _t^{*,i} dt = P(t \le T^{D,i} < t+dt t \le T^{D,i}, t \le C^i,A^i) \)  
\({\mathcal {W}}_{D,t}^i (a_Y,a_D)\)  \( \alpha _t^i dt = P(t \le T^{D,i} < t+dt t \le T^{D,i}, t \le C^i, {\overline{L}}^i_{t}, {\overline{N}}^i_{t},A=a_Y) \)  \(N^{D,i}\) 
\(\alpha _t^{*,i}dt = P(t \le T^{D,i} < t+dt t \le T^{D,i}, t \le C^i, {\overline{L}}^i_{t}, {\overline{N}}^i_{t},A=a_D)\)  
\({\mathcal {W}}_{L_{D},h,t}^i (a_Y,a_D)\)  \( \alpha _{h,t}^i dt = E[dN_{h,t}^i t \le T^{D,i}, t \le C^i, \overline{L}_{t}^i, \overline{N}^i_{t}, A=a_Y ] \)  \(N_h^i\) 
\( \alpha _{h,t}^{*,i} dt = E[dN_{h,t}^i  t \le T^{D,i}, t \le C^i, \overline{L}_{t}^i, \overline{N}^i_{t}, A=a_D]\)  
\({\mathcal {W}}_{Y,t}^i (a_Y,a_D)\)  \( \alpha _t^i dt = E[dN_t^i t \le T^{D,i}, t \le C^i, {\overline{L}}^i_{t}, {\overline{N}}^i_{t},A=a_D] \)  \(N^{i}\) 
\(\alpha _t^{*,i}dt = E[dN_t^i t \le T^{D,i}, t \le C^i, {\overline{L}}^i_{t}, {\overline{N}}^i_{t},A=a_Y]\)  
\({\mathcal {W}}_{L_{Y},h,t}^i (a_Y,a_D)\)  \( \alpha _{h,t}^i dt = E[dN_{h,t}^i t \le T^{D,i}, t \le C^i, \overline{L}_{t}^i, \overline{N}^i_{t}, A=a_D ] \)  \(N_h^i\) 
\( \alpha _{h,t}^{*,i} dt = E[dN_{h,t}^i  t \le T^{D,i}, t \le C^i, \overline{L}_{t}^i, \overline{N}^i_{t}, A=a_Y]\) 
7.4 Estimators under assumptions on \(L_k\)
8 Example: blood pressure treatment and acute kidney injury
0  1  2  3  

\(A=0\)  1273  36  1  2 
\(A=1\)  1253  52  4  2 
Weight  Hazards  Hazard models fitted 

\( {\mathcal {W}}_{C,t}^i\)  \( \alpha _t^idt\)  \(\beta _t^0 + \beta _t^A A + \beta _t^{L_0} L_0 + \beta _t^{L} L_t + \beta _t^{Y} Y_{t} \) 
\(\alpha _t^{*,i} dt\)  \(\beta _t^0 + \beta _t^A A\)  
\( {\mathcal {W}}_{D,t}^i\)  \( \alpha _t^idt\)  \(\beta _t^0 + \beta _t^A A + \beta _t^{L_0} L_0 + \beta _t^{L} L_t + \beta _t^{Y} Y_{t}\) 
\(\alpha _t^{*,i} dt\)  \(\beta _t^0 + \beta _t^A A\)  
\( {\mathcal {W}}_{Y,t}^i(a_Y,a_D)\)  \( \alpha _t^idt\)  \(\beta _t^0 + \beta _t^A I(A=a_Y) + \beta ^{L_0} L_0 + \beta _t^{L} L_t + \beta _t^{Y} Y_{t}\) 
\(\alpha _t^{*,i} dt\)  \(\beta _t^0 + \beta _t^A I(A=a_D) + \beta ^{L_0} L_0 + \beta _t^{L} L_t + \beta _t^{Y} Y_{t}\) 