In this post we’ll take a look at how to define a custom transition matrix for use with our multistate package in Stata.

The transition matrix

A transition matrix governs the movement of a process between possible states. Within multi-state survival analysis, and particularly, the implementation of multi-state models in Stata, the transition matrix contains the most crucial information, defining which transitions are possible, between a set of potential states. As always, it’s easier to explain through examples.

Survival analysis

Standard survival analysis, with a starting state and a finishing state, is a multistate model – it’s just the simplest case. Our transition matrix for this is,

. matrix define tmat = (.,1\.,.)
. matrix list tmat
tmat[2,2]
    c1  c2
r1   .   1
r2   .   .

The rows and columns represent states, and the elements of the matrix represent whether a transitions between a row state and a column state is possible. Elements with missing values, ".", imply a transition between a row state and a column state, is impossible. An element with a numeric value represents a transition that is possible. Let’s label our states.

. matrix colnames tmat = "alive" "dead"
. matrix rownames tmat = "alive" "dead"
. matrix list tmat
tmat[2,2]
       alive   dead
alive      .      1
 dead      .      .

Much clearer. The only transition that should be allowed is going from row "alive" to column "dead", and hence we have one possible transition, which we index with a 1. My "death" state is known as an absorbing state, because once you enter it, you can’t leave, i.e., the transition going from "dead" to "alive" has an element containing a missing value.

Competing risks

Let’s extend to competing risks. I’ll assume three different causes of death

  • Death due to cancer
  • Death due to cardiovascular disease (CVD)
  • Death due to other causes

Our transition matrix is,

. matrix define tmat = (.,1,2,3\.,.,.,.\.,.,.,.\.,.,.,.)
. matrix colnames tmat = "alive" "deadcancer" "deadcvd" "deadother"
. matrix rownames tmat = "alive" "deadcancer" "deadcvd" "deadother"
. matrix list tmat
tmat[4,4]
                 alive  deadcancer     deadcvd   deadother
     alive           .           1           2           3
deadcancer           .           .           .           .
   deadcvd           .           .           .           .
 deadother           .           .           .           .

which is hopefully starting to become self-explanatory. From the "alive" state, there are three possible transitions, going to each of the three potential causes of death. They are indexed uniquely, from left to right (note, these indices are used by predictms when we pass our transition models to get predictions from our multistate model. Of course, all the transitions from the death states to anywhere else are impossible, hence the rest of the transition matrix contains missing values.

Illness-death

The illness-death model introduces an intermediate state. Potential pathways include,

  • alive -> ill -> dead
  • alive -> dead

and of course observations may remain in any of the transient (a state that can be entered and left) states, at the end of follow-up. Our transition matrix is,

. matrix define tmat = (.,1,2\.,.,3\.,.,.)
. matrix colnames tmat = "alive" "ill" "dead"
. matrix rownames tmat = "alive" "ill" "dead"
. matrix list tmat
tmat[3,3]
       alive    ill   dead
alive      .      1      2
  ill      .      .      3
 dead      .      .      .

where transition 1 goes from "alive" to "ill", transition 2 goes from "alive" to "dead" (without becoming "ill"), and transition 3 goes from "ill" to "dead". This gives us what’s known as an upper triangular transition matrix.

Extended illness-death

The extended illness-death partitions the probability of being in the dead state into it’s components of dead without illness, and dead with illness.

. matrix define tmat = (.,1,2,.\.,.,.,3\.,.,.,.\.,.,.,.)
. matrix colnames tmat = "alive" "ill" "deadnotill" "deadill"
. matrix rownames tmat = "alive" "ill" "deadnotill" "deadill"
. matrix list tmat
tmat[4,4]
                 alive         ill  deadnotill     deadill
     alive           .           1           2           .
       ill           .           .           .           3
deadnotill           .           .           .           .
   deadill           .           .           .           .

Reversible illness-death

The reversible illness-death model allows recovery from the illness state, i.e., we get what’s known as a cyclic transition matrix. The structure is as follows,

. matrix define tmat = (.,1,2\3,.,4\.,.,.)
. matrix colnames tmat = "alive" "ill" "dead"
. matrix rownames tmat = "alive" "ill" "dead"
. matrix list tmat
tmat[3,3]
       alive    ill   dead
alive      .      1      2
  ill      3      .      4
 dead      .      .      .

where transition 1 goes from "alive" to "ill", transition 2 goes from "alive" to "dead" (without becoming "ill"), transition 3 goes from "ill" to "alive", and transition 4 goes from "ill" to "dead".

We can keep going…

There’s no limitations on the structure you can impose. The final example has an intermediate state and competing death states. Observations have the following potential routes:

  • diagnosis -> cvd -> deadcancer
  • diagnosis -> cvd -> deadother
  • diagnosis -> deadcancer
  • diagnosis -> deadother

with a transition matrix of,

. mat tmat = (.,1,2,3\.,.,4,5\.,.,.,.\.,.,.,.)
. mat colnames tmat = diag cvd deadcancer deadother
. mat rownames tmat = diag cvd deadcancer deadother
. mat list tmat
tmat[4,4]
                  diag         cvd  deadcancer   deadother
      diag           .           1           2           3
       cvd           .           .           4           5
deadcancer           .           .           .           .
 deadother           .           .           .           .

Note, we can define the same multi-state process with different transition matrices, they’re entirely dependent on how you order your states in the rows and columns.

Latest Resources

Specialist subjects

Real-world evidence (RWE)

Real-world evidence (RWE) Data and information that, unlike data generated in clinical trials conducted in controlled environments, has been obtained from everyday clinical practice, patient registers, or other sources outside the clinical trial setting.   RWE plays a crucial role in complementing traditional clinical trial data, providing insights into the safety, effectiveness, and overall performance […]
Read more

Videos

State-of-the-art statistical models for modern HTA

At @RedDoorAnalytics, we develop methodology and software for efficient modelling of biomarkers, measured repeatedly over time, jointly with survival outcomes, which are being increasingly used in cancer settings. We have also developed methods and software for general non-Markov multi-state survival analysis, allowing for the development of more plausible natural history models, where patient history can […]
Read more

Videos

Multilevel (hierarchical) survival models: Estimation, prediction, interpretation

Hierarchical time-to-event data is common across various research domains. In the medical field, for instance, patients are often nested within hospitals and regions, while in education, students are nested within schools. In these settings, the outcome is typically measured at the individual level, with covariates recorded at any level of the hierarchy. This hierarchical structure […]
Read more

Statistical Primers

What are competing risks?

Competing risks In survival analysis, competing risks refer to the situation when an individual is at risk of experiencing an event that precludes the event under study to occur. Competing risks commonly occur in studies of cause-specific mortality, as all other causes of death than the one under study might happen before the individuals “have […]
Read more

Statistical Primers

What is immortal time bias?

Immortal time bias Immortal time bias is a type of bias that can occur in observational research when the study design allows for a period of time during which the outcome of interest cannot occur, often referred to as “immortal time”. Simply put, immortal time bias occurs when information from a future event is incorporated into the […]
Read more

Statistical Primers

What is the proportional hazards assumption?

Proportional hazards Proportional hazards in survival analysis means that the rate at which an event of interest occurs over time for two or more groups or individuals is proportional over time. Specifically, it assumes that the hazard ratio, which represents the relative rate of an event occurring between two groups or individuals, is constant over […]
Read more

Statistical Primers

What is censoring?

Censoring refers to a situation in survival analysis where the event of interest is not observed for some of the individuals under study. In this Statistical Primer, we’ll define three types of censoring often seen in survival analysis studies. Censoring occurs when the information on the survival time is incomplete or only partially observed. Censoring […]
Read more

Statistical Primers

What is the Cox model?

The Cox model The Cox model, also known as the proportional hazards model, is a popular statistical tool used to analyse survival data. It was developed by British statistician Sir David Cox, and published in 1972. It has gained popularity largely by avoiding making parametric assumptions about the shape of the baseline rate in a […]
Read more

Statistical Primers

What is survival analysis?

Survival analysis is a statistical method used to analyse the time until an event of interest occurs. The key feature of survival analysis is that the outcome has two dimensions: – an event indicator (yes/no), and – the time spent at risk for the event All survival analyses require precise definitions of start and end of […]
Read more

Tutorials

Multivariate joint longitudinal-survival models

Joint longitudinal-survival models have been widely developed, but there are many avenues of research where they are lacking in terms of methodological development, and importantly, accessible implementations. We think merlin fills a few gaps. In this post, we’ll take a look at the extension to modelling multiple continuous longitudinal outcomes, jointly with survival. For simplicity, I’ll concentrate […]
Read more

Tutorials

Simulation and estimation of three-level survival models: IPD meta-analysis of recurrent event data

In this example I’ll look at the analysis of clustered survival data with three levels. This kind of data arises in the meta-analysis of recurrent event times, where we have observations (events or censored), k (level 1), nested within patients, j (level 2), nested within trials, i (level 3). Random intercepts The first example will […]
Read more

Tutorials

Probabilistic sensitivity analysis and survival models

Today we’re going to take a little look into probabilistic sensitivity analysis (PSA), and how it can be implemented within the context of survival analysis. Now PSA is used extensively in health economic modelling, where a particular parameter (or parameters) of interest, are altered or varied, to represent different scenarios and levels of variation. We […]
Read more
All Resources