Functions & Formulae

Each applied formula has its own function page, with a signature, implementations, and tests.

Observed follow-up, Kaplan-Meier survival and restricted mean under administrative censoring

f(e_i, d, T_i) = (Y_i, delta_i, S(t), RMST(tau), P_tail)

Maps each patient's entry date, the shared data cut-off and the event times seen by the cut-off to the observed follow-up and event indicator, then to the Kaplan-Meier survival curve, the restricted mean survival time up to the last observed follow-up and the share of mean survival that has to come from extrapolation beyond it. Staggered entry makes the censoring time differ between patients, so early recruits are observed for longer than late ones. The constant hazard estimated as events divided by person-time is the rate formula of the Adverse Event Rate page (HE-FM-AER-002), and mean survival with an exponential tail has the form of HE-FM-BTH-002 on the Bathtub Hazard page; neither is repeated here.

  • Administrative censoring time and observed follow-up from staggered entry and a data cut-off

    C_i = d - e_i; Y_i = min(T_i, C_i); delta_i = (T_i <= C_i)

    The administrative censoring time C_i of patient i is the gap between the calendar date of the data cut-off d and the patient's own entry date e_i. The observed follow-up Y_i is the smaller of the true event time T_i and C_i, and the event indicator delta_i is 1 when the event happened by the cut-off and 0 when the patient was censored. All times after entry are measured from entry or randomisation. When patients can also be lost to follow-up, the censoring time becomes the smaller of d minus e_i and the time of loss, and only the first part is administrative.

  • Kaplan-Meier survival under administrative censoring

    S_j = S_prev * (1 - d_j / n_j)

    The product-limit estimate multiplies survival before each distinct event time t_j by one minus the deaths at t_j divided by the number still at risk just before t_j. Chaining the step over all event times up to t gives the product of the factors, the Kaplan-Meier curve S(t). Patients censored at the cut-off leave the risk set at their censoring time, and because administrative censoring removes the latest recruits first, the number at risk falls steadily towards the end of follow-up.

  • Restricted mean survival time to the last observed follow-up

    RMST_tau = sum_(k=1)^K [S_k * L_k]

    The restricted mean survival time is the area under the Kaplan-Meier curve from time 0 to a restriction time tau no later than the last observed follow-up. Because the curve is a step function, the area is the sum over the K intervals between 0, the successive event times and tau of the survival in each interval multiplied by its length.

  • Share of mean survival from an exponential tail beyond the last observed follow-up

    A_tail = S_tau / h; P_tail = A_tail / (RMST_tau + A_tail)

    When survival at the last observed follow-up tau is S_tau and a constant hazard h is assumed afterwards, the area under the tail is S_tau divided by h. The share of mean survival that comes from that tail is the tail area divided by the restricted mean plus the tail area. The denominator is the mean survival of HE-FM-BTH-002 with the restricted mean in place of the closed-interval life-years, and a trial estimate of h is events divided by person-time, HE-FM-AER-002.