Functions & Formulae

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

Inverse probability of censoring weighting for dependent censoring

w_i(t) = prod_(k=0)^t 1 / P[C_i(k) = 0 | Cbar_i(k-1) = 0, Lbar_i(k), T_i > k]

Maps patients who remain under observation to weights equal to the inverse of their probability of having remained uncensored, given their covariate history, so that they also represent similar patients who were censored. Weighted versions of the Kaplan-Meier estimator, the Cox model and mean cost estimators then remove the bias that dependent censoring causes, provided every factor predicting both censoring and outcome is measured. The notation follows the Dependent Censoring article and its switchers-censored control arm.

  • Unstabilised IPCW weight updated over one interval

    w_t = w_prev / p_t

    Divides a patient's weight at the end of the previous interval by the probability of remaining unswitched (uncensored) through the current interval, given no earlier switch, baseline and time-dependent covariates and survival to the interval's start. Starting from 1, repeated division builds the product over intervals in the article's formula. Patients who cannot be censored in an interval keep their weight.

  • Stabilised IPCW weight updated over one interval

    sw_t = sw_prev * p_num / p_den

    Multiplies the previous stabilised weight by the probability of remaining uncensored given baseline covariates only, divided by the same probability given baseline and time-dependent covariates. The numerator shrinks the weights towards 1, which makes the weighted analysis more efficient; when the time-dependent covariates do not affect censoring every stabilised weight is 1.

  • IPCW-weighted Kaplan-Meier survival through one interval with two prognostic groups

    S_2 = S_1 * (1 - (w_1 * d_1 + w_2 * d_2) / (w_1 * n_1 + w_2 * n_2))

    Applies one Kaplan-Meier step with weighted counts: weighted deaths divided by the weighted number at risk give the interval's hazard, and survival is carried forward by the product-limit rule (unweighted form HE-FM-ADMC-002). Weighting non-switchers rebuilds the risk set that censoring at switch removed. Written for two prognostic groups; with more groups each adds a term to both sums.

  • Bang and Tsiatis simple weighted estimator of mean cost with censored data

    mu = (1 / N) * sum_(i=1)^N [Delta_i * A_i / S_c_i]

    Estimates mean cost over a restricted period from all N patients, counting only complete cases (death or full follow-up to the limit) and weighting each by the inverse of the Kaplan-Meier probability of remaining uncensored at its time, with censoring treated as the event. Censored patients contribute through the weights given to complete cases with longer follow-up. Survival methods applied directly to cumulative cost are not valid, because cost at censoring and cost at death are linked through the same patient's spending.

  • Mean survival from one-year survival and a constant later hazard, under dependent censoring

    T_bar = (1 - S_1) / (-log(S_1)) + S_1 / (-log(q_2))

    Extrapolates mean survival from one-year survival S_1 and conditional survival through year 2, q_2, assuming a constant hazard in year 1 and the year-2 hazard thereafter. The first term is the area under the curve in year 1 and the second the area of the exponential tail; it is the two-interval case of HE-FM-BTH-002, written in survival probabilities. Fed with a q_2 biased by dependent censoring, it shows how a small gap at two years becomes a large gap in life expectancy.