*! version 1.0.0

A guide to competing risks models in stpm3

In stpm3 it is possible to fit cause-specific competing risks models.
These models can then be combined to predict a variety of useful competing
risks based measures.

The best way to use this help file is to start without
a dataset in memory and load the data and then click through the different
sections of code.

use https://www.pclambert.net/data/rott2b

(click to load data (clear current data first))

Model 1 - cause-specific model (cancer)

The model will include one binary covariate, hormon,
and a continous covariate, age, modelled using natural splines,
using the extended function, @ns().

When using stset we need to use the option failure(cause = 1)
so that deaths due to cancer are considered as events.

Predictions of cause-specific survival will be made at each level of hormon
for a 60 year old.
This can be done through the use of two at() options in the
predict command.

The predictions are saved to a frame and then plotted.

stset os, failure(cause = 1) scale(12) exit(time 120)

stpm3 @ns(age,df(3)) i.hormon, scale(lncumhazard) df(5)

estimates store cancer

predict S0_age60 S1_age60, surv ci at1(age 60 hormon 0) at2(age 60 hormon 1) timevar(0 10) frame(cancer, replace)

frame cancer: frame cancer: line S0_age60 S1_age60 tt

(click to run.)

Note that estimate store cancer has been used as this will be needed
when calculating the cause-specific cumulative incidence function later.

Model 2 - cause-specific model (other causes)

The same covariates as above will be used, i.e. hormon
and age, modelled using natural splines.

We need to use stset again, but now use the option failure(cause = 2)
so that deaths due to other causes are considered as events.

The predict statement is the same as above, but predictions
will be saved to a different frame.

stset os, failure(cause = 2) scale(12) exit(time 120)

stpm3 @ns(age,df(3)) i.hormon, scale(lncumhazard) df(5)

estimates store other

predict S0_age60 S1_age60, surv ci at1(age 60 hormon 0) at2(age 60 hormon 1) timevar(0 10) frame(other, replace)

frame other: line S0_age60 S1_age60 tt

(click to run.)

Predicting cause-specific cumulative incidence functions

The cause specific survival-hazard functions are predictions from a single model.
However, these do not give "real world" probabilities of survival/death.
The cause-specific cumulative incidence function (CIF) gives the probability of death
accouting for competing risks, which means that predictions will depend upon
more tham one model. In the Roterdam example, there are two competing risks and
so predictions depend upon the cause-specific cancer model and the
cause-specific other causes model. These can be passed to the predict
command using the crmodels() option.

predict CIF0_age60 CIF1_age60, cif crmodels(cancer other) ci timevar(0 10) at1(age 60 hormon 0) at2(age 60 hormon 1) frame(cif, replace)

frame cif: line CIF0_age60_cancer CIF0_age60_other tt

(click to run.)

Predicting all-cause functions

It is also possible to predict the all cause survival or hazard functions.
This can be useful, for example, when producing stacked plots.

predict F0_age60 F1_age60, failure ci crmodels(cancer other) at1(age 60 hormon 0) at2(age 60 hormon 1) frame(cif, merge)

frame cif: twoway (area CIF0_age60_cancer tt) (rarea CIF0_age60_cancer F0_age60 tt), legend(order(1 "cancer" 2 "other"))

(click to run.)