Skip to contents

Computes inverse probability of censoring weights (IPCW) for right-censored survival data using the pec::ipcw() function based on a Kaplan-Meier estimate of the censoring distribution \(C\).

Usage

ipcw_weights(data, tau, time_var = "t", status_var = "delta")

Arguments

data

A data frame containing the survival data. Must include columns for the observed time and event indicator.

tau

Numeric scalar. The time horizon at which the survival probability is to be estimated.

time_var

Character. The name of the variable in data representing the observed time to event or censoring. Default is "t".

status_var

Character. The name of the variable in data representing the event indicator (1 if event occurred, 0 if censored). Default is "delta".

Value

A numeric vector of IPCW weights, ordered as in the original data. The weights are not normalized (do not sum to one).

Details

Weighting observations by their Inverse Probability of Censoring has been proposed to prevent bias introduced by removing censored individuals (Vock et al. 2016; Ginestet et al. 2021; Blanche et al. 2023) and improve model performance.

\[ \tilde{w}_i = \left\lbrace \begin{array}{ll} 0, & c_i < \tau \wedge t^*_i \cr \frac{1}{P(C > \tau \mid X = x_i)}, & \tau < c_i \wedge t^*_i \cr \frac{1}{P(C > t_i \mid X = x_i)}, & t^*_i < c_i \wedge \tau \end{array} \right. \]

The function uses the pec::ipcw() (Gerds 2023) function to compute the IPCW weights. They are not normalized (do not sum to one).

References

Blanche PF, Holt A, Scheike T (2023). “On logistic regression with right censored data, with or without competing risks, and its use for estimating treatment effects.” Lifetime Data Analysis, 29(2), 441–482. ISSN 1380-7870, doi:10.1007/s10985-022-09564-6 .

Gerds TA (2023). pec: Prediction Error Curves for Risk Prediction Models in Survival Analysis. R package version 2023.04.12, https://CRAN.R-project.org/package=pec.

Ginestet GP, Kotalik A, Vock DM, Wolfson J, Gabriel EE (2021). “Stacked Inverse Probability of Censoring Weighted Bagging A Case Study In the InfCareHIV Register.” Journal of the Royal Statistical Society Series C: Applied Statistics, 70, 51–65. doi:10.1111/rssc.12448 .

Vock DM, Wolfson J, Bandyopadhyay S, Adomavicius G, Johnson PE, Vazquez-Benitez G, O'Connor PJ (2016). “Adapting machine learning techniques to censored time-to-event health record data A general-purpose approach using inverse probability of censoring weighting.” Journal of Biomedical Informatics, 61, 119–131. doi:10.1016/j.jbi.2016.03.009 .

See also

IPCWJK for more information and ipcwmodel for implementations of ready to use models.

Examples

data <- data.frame(
  t = c(5, 8, 12, 15, 20),
  delta = c(1, 0, 1, 0, 1)
)
w <- ipcw_weights(data, tau = 10)