adjusted.KM: Adjusted Survival Curves by Using IPW and Kaplan-Meier...

Description Usage Arguments Details Value Author(s) References Examples

View source: R/prog.R

Description

This function allows for computing adjusted survival curves by weighting the individual contributions by the inverse of the probability to be in the group. The user enters individual survival data and the weights previously calculated (by using logistic regression for instance). The usual Kaplan-Meier estimator is adapted in order to obtain the adjusted survival.

Usage

1
adjusted.KM(times, failures, variable, weights)

Arguments

times

A numeric vector with the follow up times.

failures

A numeric vector with the event indicators (0=right censored, 1=event).

variable

A numeric vector with the binary variable under interest (only two groups).

weights

The weights for correcting the contribution of each individual. By default, the weights are all equalled to 1 and the survival curves correspond to the usual Kaplan-Meier estimator.

Details

For instance, w may be equal to 1/p, where p is the estimated probability of the individual to be in its group. The probabilities p are often estimated by a logistic regression in which the dependent binary variable is the group. The possible confounding factors are the explanatory variables of this model.

Value

Table

This data frame presents the survival probabilities (survival) in each group (variable) according to the times. The number of individuals at risk (n.risk) and the number of observed events are also provided (n.event).

Author(s)

Y. Foucher <Yohann.Foucher@univ-nantes.fr> and

F. Le Borgne <florent.le-borgne@etu.univ-nantes.fr>

References

Le Borgne F, Giraudeau B, Querard AH, Giral M and Foucher Y. Comparisons of the performances of different statistical tests for time-to-event analysis with confounding factors: practical illustrations in kidney transplantation. Statistics in medicine. 30;35(7):1103-16, 2016. <doi:10.1002/ sim.6777>

Cole S and Hernan M. Adjusted survival curves with inverse probability weights. Computer methods and programs in biomedicine, 75(1):45-49, 2004. <doi:10.1016/j.cmpb.2003.10.004>

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
data(DIVAT)

# Kaplan-Meier estimator
res.km <- adjusted.KM(times=DIVAT$times, failures=DIVAT$failures,
  variable=DIVAT$ecd, weights=NULL)
plot(NULL,xlim=c(0,13),ylim=c(0,1),ylab="Graft and patient survival",
 xlab="Time post-transplantation (years)")
lines(res.km$times[res.km$variable==1], res.km$survival[res.km$variable==1],
type="s",col=2,lty=2,lwd=2)
lines(res.km$times[res.km$variable==0], res.km$survival[res.km$variable==0],
type="s",col=1,lty=2,lwd=2)

# adjusted Kaplan-Meier estimator by IPW
Pr0 <- glm(ecd ~ 1, family = binomial(link="logit"), data=DIVAT)$fitted.values[1]
Pr1 <- glm(ecd ~ age + hla + retransplant, data=DIVAT,
 family=binomial(link = "logit"))$fitted.values
W <- (DIVAT$ecd==1) * (1/Pr1) + (DIVAT$ecd==0) * (1)/(1-Pr1)
res.akm <- adjusted.KM(times=DIVAT$times, failures=DIVAT$failures,
 variable=DIVAT$ecd, weights=W)
lines(res.akm$times[res.akm$variable==1], res.akm$survival[res.akm$variable==1],
 type="s",col=2,lwd=2)
lines(res.akm$times[res.akm$variable==0], res.akm$survival[res.akm$variable==0],
 type="s",col=1,lwd=2)

nb.risk1<-function(x) {sum(DIVAT$times[DIVAT$ecd==0]>x)}
nb.risk2<-function(x) {sum(DIVAT$times[DIVAT$ecd==1]>x)}
segments(x0=0, y0=0.1, x1=13, y1=0.1) 
text(x=6, y=0.12, "number of at-risk patients", cex=0.8)
tps <- seq(1,12,by=1)
text(x=tps, y=rep(0.07,length(tps)), as.character(sapply(tps, FUN="nb.risk1")),
 cex=0.8, col=1)
text(x=tps, y=rep(0.02,length(tps)), as.character(sapply(tps, FUN="nb.risk2")),
 cex=0.8, col=2)
legend("topright", legend=c("Unadjusted estimator for SCD",
 "Adjusted estimator for SCD", "Unadjusted estimator for ECD",
 "Adjusted estimator for ECD"), col=c(1,1,2,2),
 lty=c(2,1,2,1), lwd=2, cex=0.8)

IPWsurvival documentation built on May 1, 2019, 10:15 p.m.