KMW: Kaplan-Meier weights

Description Usage Arguments Value Author(s) References 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)

Gustavo Soutinho and Luis Meira-Machado

References

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

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
data("bladder4state")
obj<- multidf(time1=bladder4state$y1, event1=bladder4state$d1, 
             time=bladder4state$y1+bladder4state$y2,status=bladder4state$d2)
obj2<-obj[[1]]
kmw <- KMW(time = obj2$time, status = obj2$status)
require(survival)
bladder.surv <- survfit(Surv(time, status) ~ 1, obj2)
times <- summary(bladder.surv)$time
surv <- summary(bladder.surv)$surv
nevent <- summary(bladder.surv)$n.event
p <- match(obj2$time, times)
kmw2 <- -diff(c(1, surv))/nevent
kmw2 <- kmw2[p]*obj2$status
kmw2[is.na(kmw2)] <- 0
all.equal(kmw, kmw2)

gsoutinho/survrec documentation built on Dec. 20, 2021, 1:46 p.m.