Functions & Formulae

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

Survival estimation from left-truncated records with entry-restricted risk sets

P(T > t | T > l) = S(t) / S(l); n_j = sum_i I(L_i < t_j <= X_i); S(t) = prod_(t_j <= t) (1 - d_j / n_j)

Maps records with an entry time, an exit time and an event indicator to survival from the time origin when people come under observation only after the origin. Each person informs survival only beyond entry, conditional on surviving to entry, so risk sets and likelihood contributions start at entry. The notation follows the Left Truncation article and its six registry patients.

  • Survival conditional on reaching a late entry time

    S_cond = S_t / S_l

    A person who enters observation at time l after the origin informs only survival beyond l given survival to l. Dividing survival at t by survival at entry, both measured from the same origin, gives that conditional probability; it is the quantity a late entrant's follow-up estimates and the quantity the article's correction restores to its place.

  • Kaplan-Meier step with a risk set restricted to people who have already entered

    n_j = N_in - N_out; S_j = S_prev * (1 - d_j / n_j)

    Counts the risk set at an event time as those who have entered and not yet left. With follow-up intervals open at entry and closed at exit, a person is at risk at t_j when L_i < t_j <= X_i, so the count is the number who entered before t_j less the number who exited before t_j (anyone who left before t_j had also entered before it). The product-limit step itself is HE-FM-ADMC-002; only the risk set changes.

  • Exponential event rate and mean from person-time counted after entry

    lambda = D / PT; T_mean = 1 / lambda

    With an exponential curve, S(t) = exp(minus lambda t), the left-truncated log-likelihood sums delta_i log lambda minus lambda (X_i minus L_i), because the entry term minus log S(L_i) cancels the time before entry. It is maximised by the number of events over the person-time from entry to exit, and the fitted mean time from the origin is 1 / lambda.

  • Weibull log-likelihood contribution of a left-truncated record

    l_i = delta_i * (log(k / b) + (k - 1) * log(X_i / b)) - (X_i / b)^k + (L_i / b)^k

    Writes the article's contribution, delta_i log f(X_i) plus (1 minus delta_i) log S(X_i) minus log S(L_i), for a Weibull curve with S(t) = exp(minus (t / b)^k) and density (k / b)(t / b)^(k minus 1) S(t). The last term, (L_i / b)^k, is what a fit without entry times leaves out. Summed over records and maximised over k and b it gives the left-truncated Weibull fit used for extrapolation; with k = 1 it reduces to the exponential case of HE-FM-LTR-003.