*! version 1.0.0 02/03/2020

Title

msaj -- Aalen-Johansen estimates of transition probabilities

Syntax

msaj [if] [in] , [options]

by(varname) calculate by varname

transmatrix(matname) name of transition matrix

cr shortcut for competing risks

from(#) starting state from which predictions are made

ltruncated(#) time at which predictions are made from

exit(#) time at which predictions are made until

ci calculate confidence intervals (for probability estimates only)

se calculate standard errors (for probability estimates only)

los calculate length of stay estimates

Description

msaj calculates the Aalen-Johansen estimates of the transition probabilities. Probability estimates are output only for
observed event times, i.e. where _d == 1 (within the boundaries of ltruncated(#) and exit(#)). Length of stay estimates
are output for all observed times (within the boundaries of ltruncated(#) and exit(#)). Before using msaj, you
should use msset and then stset. See the example below.

Probability estimates are stored in new variables P_AJ_*, where star represents the numbered states in the multi-state model.

Standard errors are stored in new variables P_AJ_*_se, when the se option is specified.

Confidence intervals are stored in new variables P_AJ_*_lci and P_AJ_*_uci, when the ci option is specified.

Length of stay estimates are stored in new variables LOS_AJ_*, when the los option is specified.

msaj is part of the multistate package.

Options

by(varname) will calculate estimates separately by varname. Variable must be numeric. Estimates are not calculated
for varname equal to missing.

transmatrix(matname) specifies the transition matrix used in the multi-state model that was fitted. The matrix must
have missing entries on the diagonal. Transitions must be numbered as an increasing sequence of integers from 1,...,K.
This transition matrix should be the same as that used/produced by msset. transmatrix(matname) or cr
must be specified.

cr states that it is a competing risks analysis, i.e. all transitions are in the first row of the transition matrix.
This means that you do not need to specify the transmatrix(matname) option.

from(#) specifies the state you wish to make predicitons from (starting state). Default is state 1. The state must not
be an absorbing state.

ltruncated(#) specifies the time at which predictions are made from. It is time s when estimating the probability P(s,t).
The default is time 0. This must be strictly before the exit time.

exit(#) specifies the time at which predictions are made until. Default is the last observed event time, i.e. where
_d == 1. When the by(varname) option is also specified, the default exit time is the last observed event time
from any group, excluding when varname is missing. This default is used for all groups and so the estimates may be
extroplated past the last event time for some groups. Exit time must be strictly after the ltruncated time. Exit time must be
on or before the last observed time in the data.

ci calculates confidence intervals for the transition probabilities using Greenwood standard errors. See Andersen
et al (1993) and Allignol et al (2011) for details on how the standard errors were calculated. Estimates of confidence
intervals are truncated to ensure they lie in the [0,1] boundary.

se calculates Greenwood standard errors for the transition probabilities. See Andersen et al (1993) and Allignol
et al (2011) for details on how the standard errors were calculated.

los calculates length of stay estimates. These are calculated at all observed times (within the boundaries of
ltruncated(#) and exit(#)). They are calculated by integrating the area under the step probability function.

Examples

Load example dataset:

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

msset the data:

. 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)

Calculate transition probabilities using msaj

. msaj, transmat(tmat) ci

Probability in State 1 (alive) with confidence intervals

. line P_AJ_1* _t, sort connect(stairstep stairstep stairstep)

Probability in State 2 (recurrence) with confidence intervals

. line P_AJ_2* _t, sort connect(stairstep stairstep stairstep)

Probability in State 3 (dead) with confidence intervals

. line P_AJ_3* _t, sort connect(stairstep stairstep stairstep)

Calculate transition probabilities from state 2 at time 50 until time 150 using msaj

. cap drop P_AJ*

. msaj, transmat(tmat) from(2) ltruncated(50) exit(150) ci

Probability in State 2 (recurrence) from state 2 at time 50 until time 150

. line P_AJ_2* _t, sort connect(stairstep stairstep stairstep)

Calculate length of stay estimates using msaj

. cap drop P_AJ*

. msaj, transmat(tmat) los

Length of stay in State 1 (alive)

. line LOS_AJ_1 _t, sort

Length of stay in State 2 (recurrance)

. line LOS_AJ_2 _t, sort

Authors

Micki Hill, University of Leicester, UK.
(mh594@leicester.ac.uk)

Paul Lambert, University of Leicester, UK and Karolinska Institutet, Stockholm, Sweden.
(paul.lambert@leicester.ac.uk)

Michael Crowther, Red Door Analytics and Karolinska Institutet, Stockholm, Sweden.
(michael@reddooranalytics.se)

References

Allignol A, Schumacher M, Beyersmann J. Empirical transition matrix of multi-state models: The etm package. Journal of Statistical Software 2011;38(4):1-15.

Andersen PK, Borgan O, Gill RD, Keiding N. Statistical models based on counting processes. Springer Series in Statistics 1993.

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