# NOT RUN {
# Treat time to death and plasma cell malignancy as competing risks
etime <- with(mgus2, ifelse(pstat==0, futime, ptime))
event <- with(mgus2, ifelse(pstat==0, 2*death, 1))
event <- factor(event, 0:2, labels=c("censor", "pcm", "death"))
# FG model for PCM
pdata <- finegray(Surv(etime, event) ~ ., data=mgus2)
fgfit <- coxph(Surv(fgstart, fgstop, fgstatus) ~ age + sex,
weight=fgwt, data=pdata)
# Compute the weights separately by sex
adata <- finegray(Surv(etime, event) ~ . + strata(sex),
data=mgus2, na.action=na.pass)
# }
Run the code above in your browser using DataLab