*! version 1.0.1 2023-03-23

Syntax for stpm3km

Compare marginal survival predictions to Kaplan-Meier estimates
after fitting a stpm3 model.

By default only data included in the model is used. If you
want to include data not in the model then use then
noesample option. This can be useful for external validation.

stpm3km
[varname]
[if] [in] [, options,]

Options

option

cut(options) the breaks for the groups

noesample predict out of sample

factor states varname is a factor

failure calculate failure rather than survival

frame(framename) predictions will be saved to frame framename

nograph do not plot graph

groups(#) Number of groups for continuous covariates

nokm Do not include Kaplan-Meier estimates on graph

maxt(#) maximum follow-up time

ntimevar(#) Number of timepoints for standsurv

pitime(#) Time for prognostic index when time-dependent effects

Description

stpm3km can be used after fitting a stpm3 model.
Continous covariates are categorized into groups and the
marginal survival function is calculated within each group level
and compared to the corresponding Kaplan-Meier estimate.

If varname is not specified then the prognostic index is categorized.
Use factor variable notation, e.g. i.sex to denote that a variable is
categorical. Alternatively you can use the factor option.

The default number of groups is 5. This can be changed with the groups(#) option.
The groups will be of roughly equal frequencies. You can define your own groups using
the cut() option.

Options

cut(numlist) a numlist in ascending order giving the breaks for the groups
of varname or the prognostic index.

noesample allows data not included in the model to be used. This is
useful for external validation.

factor specifies that varname is a factor (categorical) variable.

frame(framename) saves the Kaplan-Meier and model based standardized
estimates to a frame.

nograph suppresses plotting of the graph. It only makes sense to use
this option in conjunction with the frame() option.

groups(#) specifies how many groups to create. The default is 5.
If there are many ties in varname there may be less groups then specified.

maxt(#) specifies the maxiumum follow-up time for survival predictions and for plotting
the Kaplan-Meier curve.

ntimevar(#) specifeis the number of timepoints to calculate the predicted survival curve
at. The default is 100.

pitime(#) is for use when the stpm3 model has time-dependent effects
and the user wants to use a prognostic index to define the groups.
The prognostic index will be time-dependent, so this option specifies which time
the prognostic index is calculated at.

Remarks

Some remarks

Examples

All examples use the Roterdam data available on my website.
First load and stset the data and then all examples are clickable.
You will need to clear data in memory before running.

. use "https://pclambert.net/data/rott2b.dta"

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

Example 1:

Fit stpm3 model

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

Compare marginal predictions in 5 groups (the default) based on prognostic index

. stpm3km

Compare marginal predictions in 4 groups based on distribution of age

. stpm3km age, groups(4)

Compare marginal predictions in based on factor variable hormon

. stpm3km hormon, factor

Author

Paul C. Lambert

Biostatistics Research Group

Department of Health Sciences

University of Leicester

and

Department of Medical Epidemiology and Biostatistics

Karolinska Institutet

E-mail: paul.lambert@le.ac.uk