Learn R Programming

pec (version 2.0.8)

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,
     method = c("cox", "marginal", "nonpar", "aalen", "none"),
     times,
     subjectTimes,
     subjectTimesLag=1,
     what)

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
method
Censoring model used for estimation of the (conditional) censoring distribution.
times
For what="IPCW.times" a vector of times at which to compute the probabilities of not being censored.
subjectTimes
For what="IPCW.subjectTimes" a vector of individual times at which the probabilities of not being censored are computed.
subjectTimesLag
If equal to 1 then obtain G(T_i-|X_i), if equal to 0 estimate the conditional censoring distribution at the subjectTimes, i.e. (G(T_i|X_i)).
what
Decide about what to do: If equal to "IPCW.times" then weights are estimated at given times. If equal to "IPCW.subjectTimes" then weights are estimated at individual subjectTimes.

Value

  • timesThe times at which weights are estimated
  • IPCW.timesEstimated weights at times
  • IPCW.subjectTimesEstimated weights at individual time values subjectTimes
  • fitThe fitted censoring model
  • methodThe method for modelling the censoring distribution
  • callThe call

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 method!

See Also

pec

Examples

Run this code
dat=prodlim:::SimSurv(300)

dat <- dat[order(dat$time),]

# using the marginal Kaplan-Meier for the censoring times

WKM=ipcw(Hist(time,status)~X2,data=dat,method="marginal",times=sort(unique(dat$time)),subjectTimes=dat$time)
plot(WKM$fit)
WKM$fit

# using the Cox model for the censoring times given X2

WCox=ipcw(Surv(time,status)~X2,data=dat,method="cox",times=sort(unique(dat$time)),subjectTimes=dat$time)
WCox$fit

plot(WKM$fit)
lines(sort(unique(dat$time)),1-WCox$IPCW.times[1,],type="l",col=2,lty=3,lwd=3)
lines(sort(unique(dat$time)),1-WCox$IPCW.times[5,],type="l",col=3,lty=3,lwd=3)

# using the stratified Kaplan-Meier for the censoring times given X2

WKM2=ipcw(Surv(time,status)~X2,data=dat,method="nonpar",times=sort(unique(dat$time)),subjectTimes=dat$time)
plot(WKM2$fit,add=FALSE)

Run the code above in your browser using DataLab