*! version 1.0.3 25Nov2016
help stcrprep
also see: stcrreg, stcox

Title

stcrprep -- Prepare data for competing risks analysis using time-dependent weights

Syntax

stcrprep [if] [in], events(varname) [options]

Options
byg(varlist) calculate censoring weights separately by varlist

byh(varlist) calculate delayed entry weights separately by varlist

censvalue(#) value for censoring for events variable

epsilon(#) value to add to ensure censoring occurs after event

events(varname) name of variable defining different events

keep(varlist) name of variables to keep in dataset

noshorten do not collapse over same weights within individuals

trans(numlist) Values of events variables that define the transitions of interest

The following options are use when a parametric model is used for the censoring distribution.
wtstpm2 estimate censoring distribution using stpm2

censcov(varlist) variables to include in censoring model

censdf(#) degrees of freedom for the baseline censoring distribution

censtvc(varlist) variables with time-dependent effects for censoring distribution

censtvcdf(#) degrees of freedom for time-dependent effects for censoring distribution

Description

stcrprep prepares data for estimating and modelling cause-specific cumulative incidence functions using
time-dependent weights. Once the data has been prepared and the weights incorporated using stset it is possible to obtain a graph of the non-parametric estimates of the cause-specific cumulative incidence function using sts graph.
In addition a model that estimates subhazard ratios (equivalent to the Fine and Gray model) can be fitted using stcox. It is also possible to fit parametric models to directly estimate the cause-specific CIF.

The data must be stset before using stcrprep. As the data is expanded the id() option of stset must be used. There should only be 1 row of data per subject before using stcrprep.

Note the stcrprep currently allows for delayed entry when using the Kaplan-Meier method to derive weights, but not currently when using fitting a parametric model for using the wtstpm2 option.
However, the delayed entry implementation is experimental and has not been fully tested, so please use with caution.

The command is based on the R function, crprep written by Ronald Geskus, which is part of the mstate package available from Cran (http://cran.r-project.org).

Options

byg(varlist) calculate censoring weights separately by varlist.

byh(varlist) calculate left truncation weights separately by varlist.

censvalue(#) value that denotes a censored observation in the variable used to define the different events.
The default value is 0

epsilon(#) values added to survival time when calculating probability of censoring to ensure that events occur before censoring.

event(varname) name of the variable defining the different events. This is a compulsory option

keep(varlist) names of variables to keep in expanded dataset. This is generally a list of the variables that you want to include in the analysis.

noshorten do not collapse over rows with equal weights.

trans(numlist) Values of events variable that are the event types of interest. stcrprep will create the
weights for any of the events listed in this option. By default all events are included with these
denoted by the failcode variable in the new data set.

The following options fits a parametric model using stpm2 for the censoring distribution.

wtstpm2 requests that the censoring distribution is estimated by fitting a flexible
parametric survival model using stpm2.

censcov(varlist) covariates to include in the model for the censoring distribution.

censdf(#) gives the degrees of freedom used for the baseline when using stpm2 to obtain the
censoring distribution. The default is 5 df.

censtvc(varlist) gives any variables to be included as time-dependent effects when using stpm2 to estimate the censoring distribution.

censtvcdf(#) gives the degrees of freedom used for any time-dependent effects when using stpm2 to obtain the
censoring distribution. The default is 3 df.

Remarks

Using stcrprep to Fit Fine and Gray models with large data sets can be substantially faster than using stcrreg. this is because the time-dependent weights needed in the estimation process only have to be calculated once rather than
each time a model is fitted.

Example 1: Use sts graph to plot cumulative incidence functions.

Load and stset the data

. use "http://www.stata-journal.com/software/sj4-2/st0059/prostatecancer"
. stset time, failure(status=1,2,3) id(id) scale(12)

Use stcrprep to expand data and calculate weights

. stcrprep, events(status) byg(treatment) keep(treatment)
. gen event = failcode == status

Incorporate weights when using stset

. stset tstop [iw=weight_c], failure(event==1) enter(tstart)

Plot cumulative incidence functions

. forvalues i = 1/3 {
local event: label (failcode) `i'
sts graph if failcode==`i', by(treatment) failure ///
title("`event'") name(`event',replace)
}

Example 2: Use stcox to fit a Fine and Gray model

Load and stset the data

. use "http://www.stata-journal.com/software/sj4-2/st0059/prostatecancer"
. stset time, failure(status=1,2,3) id(id) scale(12)

Expand data. Here we only keep the data relevant for modelling the CIF for cancer.

. stcrprep, events(status) keep(treatment age) trans(1)
. gen event = failcode == status

Incorporate weights when using stset

. stset tstop [pw=weight_c], failure(event==1) enter(tstart)

Using stcox will now fit a Fine and Gray model

. stcox treatment age

Assessing proportional subhazards assumption

. estat phtest, plot(treatment) yline(0 `=_b[treatment]')
. estat phtest, detail

Example 3: Fit a parametric model for the CIF

Load and stset the data

. use "http://www.stata-journal.com/software/sj4-2/st0059/prostatecancer"
. stset time, failure(status=1,2,3) id(id) scale(12)

Expand data. Use a parametric model for the censoring distribution.
Allow censoring distribution to depend on treatment/age.
Split every 0.25 years after competing events

. stcrprep, events(status) keep(treatment age) wtstpm2 censcov(treatment age) every(0.25)
. gen event = failcode == status

Incorporate weights when using stset

. stset tstop [iw=weight_c], failure(event==1) enter(tstart)

Fit parametric model for the CIF using stpm2

. stpm2 treatment if failcode == 1, scale(hazard) df(4)

Plot CIFs

. predict CIF if failcode ==1, failure
. twoway (line CIF _t if treatment == 0, sort) (line CIF _t if treatment == 1, sort)

Author

Paul Lambert, University of Leicester, UK.
(paul.lambert@leicester.ac.uk)

The command is based on the R function, crprep written by Ronald Geskus, which is part of the mstate package
available from(http://cran.r-project.org).

References

R. B. Geskus. Cause-specific cumulative incidence estimation and the Fine and Gray model under both left truncation and right censoring. Biometrics 2011:67:39-49.

L. de Wreede, M. Fiocco, H. Putter. mstate: An R package for the analysis of competing risks and multi-state models Journal of Statistical Software, 2011, 38

Also see

Online: [ST] stcox ST: sts graph;
[ST] stset