Learn R Programming

riskRegression (version 0.0.8)

subjectWeights: Estimation of censoring probabilities at subject specific times

Description

This function is used internally to contruct pseudo values by inverse of the probability of censoring weights.

Usage

subjectWeights(formula,
     data,
     method = c("cox", "marginal","km", "nonpar", "aalen", "none"),
     lag)

Arguments

formula
A survival formula like, Surv(time,status)~1 or Hist(time,status)~1 where status=0 means censored. The status variable is internally reversed for estimation of censoring rather than survival probabilities. Some of the available models, see arg
data
The data used for fitting the censoring model
method
Censoring model used for estimation of the (conditional) censoring distribution.
lag
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)).

Value

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

Details

Inverse of the probability of censoring weights 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 subjectWeights estimates the conditional survival function of the censoring times and derives the weights. IMPORTANT: the data set should be ordered, order(time,-status) in order to get the weights in the right order for some choices of method.

Examples

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

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

# using the marginal Kaplan-Meier for the censoring times

WKM=subjectWeights(Hist(time,status)~X2,data=dat,method="marginal")
plot(WKM$fit)
WKM$fit
WKM$weights

# using the Cox model for the censoring times given X2

WCox=subjectWeights(Surv(time,status)~X2,data=dat,method="cox")
WCox
plot(WCox$weights,WKM$weights)

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

WKM2 <- subjectWeights(Surv(time,status)~X2,data=dat,method="nonpar")
plot(WKM2$fit,add=FALSE)

Run the code above in your browser using DataLab