censoring_distribution() gives the Kaplan-Meier estimate of the censoring distribution,
\(G(t)\), the probability of not being censored by time \(t\). The censorings are the
events of this curve, and the events count as censorings. At a time with both, everyone with
that time is at risk.
Usage
censoring_distribution(response, weights = NULL)
# S3 method for class 'censoring_distribution'
predict(object, times, left = FALSE, ...)
# S3 method for class 'censoring_distribution'
weights(object, tau = Inf, ...)
# S3 method for class 'censoring_distribution'
as.data.frame(x, row.names = NULL, optional = FALSE, ...)Arguments
- response
A right-censored
Surv()object.- weights
Optional case weights, one non-negative number per subject.
- object
A
censoring_distributionobject.- times
The times to read the curve at.
- left
Whether to read the curve just before each time, \(G(t-)\), rather than at it. The default is
FALSE.- ...
Unused.
- tau
A time after which subjects get a weight of 0. The default,
Inf, keeps them all.- x
A
censoring_distributionobject.- row.names, optional
Unused. They're part of the
as.data.frame()generic.
Value
A censoring_distribution object holding time (the distinct censoring times),
survival (\(G\) just after each), n, and n_censored.
Details
Its main use is inverse-probability-of-censoring (IPC) weighting. Weighting each subject with
an event by \(1 / G(T_i-)\), the curve just before their time, makes up for the subjects lost
to censoring before then. Use weights() for these weights, predict() to read the curve at
any times, and as.data.frame() for the curve itself.
Methods (by generic)
predict(censoring_distribution): \(G\) attimes, or just before them withleft = TRUE.weights(censoring_distribution): The IPC weights, one per subject: \(1 / G(T_i-)\) for a subject with an event, and 0 for a censored subject, a subject whose time is aftertau, or one with \(G(T_i-) = 0\). Case weights given tocensoring_distribution()shape \(G\) but aren't multiplied in.as.data.frame(censoring_distribution): The curve as a data frame with the columnstimeandsurvival, one row per distinct censoring time.
Examples
lung <- data.frame(
time = c(306, 455, 1010, 210, 883, 1022, 310, 361, 218, 166, 170, 654, 728, 71, 567, 144,
613, 707, 61, 88),
status = c(2, 2, 1, 2, 2, 1, 2, 2, 2, 2, 2, 2, 1, 2, 2, 1, 2, 2, 2, 2)
)
censoring <- censoring_distribution(Surv(lung$time, lung$status))
censoring
#> <censoring_distribution>
#> n = 20, censored = 4, censoring times = 4, G after the last = 0
# The probability of staying uncensored through one and two years
predict(censoring, times = c(365, 730))
#> [1] 0.9411765 0.7058824
# The IPC weights, 0 for the censored subjects
weights(censoring)
#> [1] 1.062500 1.062500 0.000000 1.062500 1.416667 0.000000 1.062500 1.062500
#> [9] 1.062500 1.062500 1.062500 1.062500 0.000000 1.000000 1.062500 0.000000
#> [17] 1.062500 1.062500 1.000000 1.000000