Title

graphms -- create a stacked transition probability graph

graphms is part of the multistate package, for use after calculating transition probabilities with predictms

Syntax

graphms , [options]

from(numlist) starting state(s) for predictions

at(numlist) calculate predictions for the defined at#() patterns; see details

timevar(varname) time variable used for the x-axis

Nstates(#) defines the number of potential states

All options are optional...if they are not specified, graphms will obtain the appropriate information from the
return list of predictms (if it is still in memory).

Description

graphms creates a stacked transition probability plot, following the estimation of a multi-state model
(using stmerlin or merlin) and prediction of such quantities using predictms. graphms uses
the _prob_at variables creates by predictms to create the plot.

graphms is part of the multistate package.

Options

from(numlist) define the starting state for all predictions. Multiple starting states can be defined,
which will create multiple graphs.

at(numlist) defines the at#() patterns to create plots for. If at(1) is specified, then plots will
be creates for the _prob_at1_* predictions. Multiple at()s can be specified.

timevar(varname) variable to use as the x-axis, i.e. the time points at which the _prob* predictions
were calculated at.

Nstates(#) defines the number of potential states.

Example 1:

This dataset contains information on 2982 patients with breast cancer. Baseline is defined as time of surgery, and patients can experience
relapse, relapse then death, or death with no relapse. Time of relapse is stored in rf, with event indicator rfi, and time of death
is stored in os, with event indicator osi.

Load example dataset:

. use http://fmwww.bc.edu/repec/bocode/m/multistate_example

msset the data (from the multistate package):

. msset, id(pid) states(rfi osi) times(rf os)

Store the transition matrix:

. mat tmat = r(transmatrix)

stset the data using the variables created by msset

. stset _stop, enter(_start) failure(_status=1)

We fit separate Weibull models, so a fully stratified model, also allowing transition specific age effects:

. stmerlin age if _trans1==1, distribution(weibull)

. estimate store m1

. stmerlin age if _trans2==1, distribution(weibull)

. estimate store m2

. stmerlin age if _trans3==1, distribution(weibull)

. estimate store m3

Calculate transition probabilities for a patient with age 50:

. predictms, transmatrix(tmat) models(m1 m2 m3) at1(age 50)

Create a stacked plot of transition probabilities:

. graphms

Author

Michael J. Crowther

Red Door Analytics

Stockholm, Sweden

E-mail: michael@reddooranalytics.se

Please report any errors you may find.

References

Crowther MJ. Extended multivariate generalised linear and non-linear mixed effects models.
https://arxiv.org/abs/1710.02223

Crowther MJ. merlin - a unified framework for data analysis and methods development in Stata.
https://arxiv.org/abs/1806.01615

Crowther MJ, Lambert PC. Parametric multi-state survival models: flexible modelling allowing transition-specific distributions with
application to estimating clinically useful measures of effect differences. Statistics in Medicine 2017;36(29):4719-4742.

de Wreede LC, Fiocco M, Putter H. mstate: An R Package for the Analysis of Competing Risks and Multi-State Models.
Journal of Statistical Software 2011;38:1-30.

Putter H, Fiocco M, Geskus RB. Tutorial in biostatistics: competing risks and multi-state models.
Statistics in Medicine 2007;26:2389-2430.

Weibull CE, Lambert PC, Eloranta S, Andersson TML, Dickman PW, Crowther MJ. A multi-state model incorporating
estimation of excess hazards and multiple time scales. Submitted.