Learn R Programming

pec (version 1.0.7)

ipcw: Estimation of censoring probabilities

Description

This function is used internally by the function pec to obtain inverse of the probability of censoring weights.

Usage

ipcw(formula,
     data,
     model = c("cox", "marginal", "nonpar", "aalen", "none"),
     times,
     otimes)

Arguments

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
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.

Value

  • wtEstimated weights at times
  • wt.obsEstimated weights at individual time values otimes
  • fitThe fitted censoring model

Details

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!

See Also

pec

Examples

Run this code
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)

Run the code above in your browser using DataLab