help for predsurv(Roger Newson)

Compute predicted or baseline survival after streg or stcox

predsurv [if] [in] ,
time(#) generate(newvarname) [
type(type) cuminc fast
]

predbasesurv [if] [in] ,
time(#) [ generate(newvarname) gsurv(newvarname)
type(type)
]

where type specifies a numeric storage type.

Description

predsurv and predbasesurv are intended for use in a survival time dataset set up by stset.
predsurv is used after streg has been used to fit a survival time regression model.
It computes a survival probability or cumulative incidence for a user-specified survival time.
baseepredsurv is used after stcox has been used to fit a Cox regression model.
It computes a survival probability and/or a baseline survival probability for a user-specified survival time.
User-specified survival times are expressed in the units specified by the scale() option of stset.
Note that predsurv and predbasesurv can do out-of-sample prediction,
if streg or stcox has been used to fit a model on a subset of the data,
but predbasesurv will only give the correct answers in the test set
if the training set and the test set are combined in the same dataset.

Options for predsurv and predbasesurv

time(#) is required.
It specifies a survival time, for which survival probabilities are estimated.
Note that the times are assumed to be given in the units specified by the scale() option of stset,
as stored in the variable _t generated by stset.

generate(newvarname) is required.
It specifies the name of a new variable to be generated,
containing the survival probabilities or cumulative incidences (in the case of predsurv)
or the baseline survival probabilities if all covariates are zero (in the case of predbasesurv),
at the time specified by the time() option.

type(type) specifies a numeric storage type for the generated variable(s).
If absent, then float is assumed.

Options for predsurv only

cuminc specifies that the generated variable will be a cumulative incidence probability variable.
In default, it shall be a survival probablity variable.

fast is an option for programmers.
It specifies that predsurv will do no extra work to restore the original dataset
if the user presses Break.
It is necessary because predsurv makes temporary changes to the variable _t
generated by the stset command.
It can save time when working with very large datasets.

Options for predbasesurv only

gsurv(newvarname) specfies the name of a new variable to be generated,
containing the individual survival probabilities,
equal to the baseline survival probability if all covariates are zero
raised to the power of the hazard ratio for the individual observation.
Note that either or both of the options generate() and/or gsurv(),
specifying generated variables,
must be present for bpredbasesurv to work.

Remarks

predsurv is useful for out-of-sample predictions after streg.
The predicted survival probability can be used as a positive ordinal predictor of survival,
and the predicted cumulative incidence can be used as a negative ordinal predictor of survival,
much as the hazard ratio generated using predict after stcox
can be used as a negative ordinal predictor of survival.
Note that, for predsurv,
the training set can be separate from the test set,
because the model may be fitted in the training set,
and the estimation results can be re-used for prediction in the test set,
without any training set observations being present.

predbasesurv is useful for out-of-sample prediction after stcox.
It generates the baseline survival probability expected if all covariates are zero,
and/or the individual survival probability for each observation given the covariates in that observation.
Note that, for baselinesurv to work correctly,
the training set and the test set must be combined in the same dataset in memory,
and the Cox model must be fitted to the training set only.
The baseline survival variable for a given time() option
will have the same value within each stratum specified by the stratua() option of stcox,
but may vary from stratum to stratum.
If the stcox command did not have a strata() option,
then the baseline survival probability will be constant.
Either way, the survival probability for an individual,
in the time specified in the time() option,
is equal, for each lifetime specified by an observationn,
to the baseline survival probability raised to the power of the hazard ratio
for te covariate values in that observation.

Note that it is a good idea for covariates in a Cox regression model to be centered,
so that they are equal to zero in a sensible and plausible scenario.
For instance, the user may enter covariates into a Cox model
after subtracting their mean or median values.
If this is done, then the baseline survival probability specified by basepredsurv
will be the survival probability for the lifetime of a typical individual,
and will not be very close to zero or one.
If variables are not centered, then the baseline survival probability
may correspond to an extreme scenario,
like the case of a heart failure patient of age zero.
Ths is important if we are estimating survival probabilities for individual subjects
by raising the baseline survival probability to the power of the hazard ratio,
which probably will not be done very precisely
if the baseline survival probability is close to zero or one.

The fitting of survival models to a training set,
and the testing of their ordinal predictive power using out-of-sample prediction in a test set,
is discussed in Newson (2010).

Examples

These examples use the cancer dataset,
which the user can download using the webuse command.

Set-up

. webuse cancer, clear

. stset studytime died

. describe, full

. tab died, miss

. summ studytime, de

Fit model and compute median survival time and 12-month survival probability

. streg age, dist(weibull) strata(drug)

. predict medsurv

. summ medsurv, de

. predsurv, time(12) gene(surv12)

. summ surv12, de

Plot 12-month survival probability against median survival time

. scatter surv12 medsurv, yline(0.5) ylab(0(0.1)1) xline(12) xlab(0(6)60)

Note that the 12-month survival probability s12 is above (or below) 0.5
if and only if the median survival time medsurv is above (or below) 12 months.

The following example estimates 40-day survival probabilities in te stan3 dataset,
after grouping and centering covariates.

Input and describe dataset

. webuse stan3, clear

. describe, full

. stset

Group years into strata to reflect changes in treatment in 1970 and 1973

.generate pgroup = year

.recode pgroup min/69=1 70/72=2 73/max=3

Center age at 50 and year at 70

. summ age, de

. generate agem50=age-50

. summ year, de

. generate yearm70=year-70

Fit stratified Cox regression model

. stcox agem50 posttran surg yearm70, strata(pgroup) vce(robust)

Baseline and individual 40-day survival probabilities

. predbasesurv, time(40) generate(bsurv40) gsurv(surv40)

Show that baseline 40-day survival probabiility is a function of stratum

. tab bsurv40, m

. tab pgroup bsurv40, m

Distributon of 40-day survival probabilities for individual patients

. summ surv40, de

Author

Roger Newson, Imperial College London, UK.

Email: r.newson@imperial.ac.uk

References

Newson, R. B. 2010.
Comparing the predictive powers of survival models using Harrell's C or Somers' D.
Stata Journal 10: 339-358.
Download from
the Stata Journal website.

Also see

Manual: [ST] stset, [ST] streg, [ST] stcox

On-line: help for stset, streg, stcox