# Simulated data
set.seed(123321)
t <- rexp(200)
ic <- sample(0:2,200,replace=TRUE)
z <- matrix(runif(600),nrow=200)
colnames(z) <- c("z1","z2","z3")
dat <- data.frame(t,ic,z)
# Model fitting with a Kaplan-Meier weight
print(out.KM <- crr.wt(Crsk(t,ic)~z1+z2+z3,data=dat,weight="KM",cause=1))
# Model fitting with a Cox weight
print(out.COX <- crr.wt(Crsk(t,ic)~z1+z2+z3,data=dat,weight="COX",cause=1,Cens(t,ic)~z1+z2))
# Summary information
summary(out.COX)
# Prediction of cumulative incidence proability
newdata <- data.frame(c(.2,.3,.5),c(.9,.1,.6),c(.3,.9,.2))
colnames(newdata) <- c("z1","z2","z3")
pred.COX <- predict(out.COX,z=newdata)
# Plots of prediction
plot(pred.COX)
plot(pred.COX,multiple=1)
plot(pred.COX,multiple=1,se=1)
Run the code above in your browser using DataLab