KMW: Kaplan-Meier weights

Description Usage Arguments Value Author(s) References See Also Examples

View source: R/KMW.R

Description

This function returns a vector with the Kaplan-Meier weights.

Usage

1
KMW(time, status)

Arguments

time

Survival time of the process.

status

Censoring indicator of the survival time of the process; 0 if the survival time is censored and 1 otherwise.

Value

Vector with Kaplan-Meier weights.

Author(s)

Luis Meira-Machado, Marta Sestelo and Gustavo Soutinho.

References

E. Kaplan and P. Meier. Nonparametric estimation from incomplete observations. Journal of the American Statistical Association, 53:457-481, 1958.

See Also

PKMW

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
obj <- with(colonIDM, survIDM(time1, event1, Stime, event))
kmw <- KMW(time = obj$Stime, status = obj$event)

require(survival)
colon.surv <- survfit(Surv(Stime, event) ~ 1, obj)
times <- summary(colon.surv)$time
surv <- summary(colon.surv)$surv
nevent <- summary(colon.surv)$n.event
p <- match(obj$Stime, times)
kmw2 <- -diff(c(1, surv))/nevent
kmw2 <- kmw2[p]*obj$event
kmw2[is.na(kmw2)] <- 0
all.equal(kmw, kmw2)

survidm documentation built on June 25, 2021, 1:07 a.m.