ipcw {pec} | R Documentation |
This function is used internally by the function pec
to obtain inverse of the probability of censoring weights.
ipcw(formula, data, model = c("cox", "marginal", "nonpar", "aalen", "none"), times, otimes)
formula |
A survival formula like, Surv(time,status)~1,
where as usual status=0 means
censored. The status variable is internally reversed for estimation
of censoring rather than survival probabilities. Some of the
available models (see argument model )
will use predictors on the right hand side of the formula. |
data |
The data used for fitting the censoring model |
model |
Censoring model used for estimation of the (conditional) censoring distribution. |
times |
Time values at which the probabilities of not being censored are returned |
otimes |
The time values, usually the original event times in the data.frame data ,
at which lagged individual probabilities of not being censored are
returned.
|
Inverse of the probability of censoring weights (IPCW) usually refer to the probabilities of not being censored at certain time points. These probabilities are also the values of the conditional survival function of the censoring time given covariates. The function ipcw estimates the conditional survival function of the censoring times and derives the weights.
Currently the data set should be order by time to get the value wt.obs
in
the right order for some choices of model
!
wt |
Estimated weights at times |
wt.obs |
Estimated weights at individual time values otimes |
fit |
The fitted censoring model |
Thomas A. Gerds tag@biostat.ku.dk
library(survival) data(pbc) pbc <- pbc[order(pbc$time),] # using the marginal Kaplan-Meier for the censoring times WKM=ipcw(Surv(time,status)~edema,data=pbc,model="marginal",times=sort(unique(pbc$time)),otimes=pbc$time) plot(WKM$fit) WKM$fit # using the Cox model for the censoring times given edema WCox=ipcw(Surv(time,status)~edema,data=pbc,model="cox",times=sort(unique(pbc$time)),otimes=pbc$time) WCox$fit plot(WKM$fit) lines(sort(unique(pbc$time)),1-WCox$wt[1,],type="l",col=2,lty=3,lwd=3) lines(sort(unique(pbc$time)),1-WCox$wt[2,],type="l",col=3,lty=3,lwd=3) # using the stratified Kaplan-Meier for the censoring times given edema WKM2=ipcw(Surv(time,status)~edema,data=pbc,model="nonpar",times=sort(unique(pbc$time)),otimes=pbc$time) plot(WKM2$fit,add=TRUE)