Solved – Use multi-state modelling (MSM) to predict individual transition probabilities in R

predictive-modelsrtransition matrix

I am using R package msm to model multi-state transitions in the sample dataset cav:

> head(cav)
   PTNUM      age    years dage sex pdiag cumrej state firstobs statemax
1 100002 52.49589 0.000000   21   0   IHD      0     1        1        1
2 100002 53.49863 1.002740   21   0   IHD      2     1        0        1
3 100002 54.49863 2.002740   21   0   IHD      2     2        0        2
4 100002 55.58904 3.093151   21   0   IHD      2     2        0        2
5 100002 56.49589 4.000000   21   0   IHD      3     2        0        2
6 100002 57.49315 4.997260   21   0   IHD      3     3        0        3

I use the following to model:

Q = rbind ( c(0,     0.25, 0,     0.25  ),
            c(0.166, 0   , 0.166, 0.166 ),
            c(0,     0.25, 0,     0.25  ),
            c(0,     0,    0,     0     ) )

cav.msm = msm(state ~ years, subject=PTNUM, data = cav, qmatrix = Q, deathexact = 4)

I can also use pnext.msm(cav.msm) to generate the probability of transition, resulting in:

        State 1             State 2             State 3                 State 4                 
State 1 0                   0.75 (0.70,0.80)    0                       0.25 (0.20,0.30)
State 2 0.37 (0.29,0.45)    0                   0.56 (0.44,0.66)        0.66 (0.02,0.21)
State 3 0                   0.30 (0.20,0.42)    0                       0.70 (0.58,0.80)
State 4 0                   0                   0                       0         

My Question

Is it possible to generate the transition probabilities for an INDIVIDUAL (new data) given their current state and other factors (e.g., modeling covariates with msm's covariates= parameter)

Maybe Solution?

If I run the following:

#gender as covariate
cavsex.msm = msm(state ~ years, subject=PTNUM, data=cav, qmatrix=Q, deathexact=4, covariates = ~ sex)

and then generate a probability of transition matrix using a specified value for the covariate:

#probability each state is next (given a specified gender)
covariates = list(sex=0)
pnm = pnext.msm(cavsex.msm,covariates)

Does this generate the predicted transition matrix given covariate values?

> print(pnm$estimates)

          State 1   State 2   State 3    State 4
State 1 0.0000000 0.7670212 0.0000000 0.23297881
State 2 0.3635454 0.0000000 0.5522745 0.08418016
State 3 0.0000000 0.3145707 0.0000000 0.68542935
State 4 0.0000000 0.0000000 0.0000000 0.00000000

Here it is for sex=1:

          State 1   State 2   State 3     State 4
State 1 0.0000000 0.6215845 0.0000000 0.378415538
State 2 0.4410597 0.0000000 0.5589102 0.000030109
State 3 0.0000000 0.1725361 0.0000000 0.827463858
State 4 0.0000000 0.0000000 0.0000000 0.000000000

Can this be generally interpreted as, from State 3, the probability of transitioning to State 2 on the next step is 17% if sex=1 and 32% of sex=0?

Best Answer

it is possible in multiple ways. You can either use pmatrix.msm and pass some covariates to compute the estimated transition probability matrix. The function allows you to define a covariate profile which can be very specific. It also permits the definition of a custom time sequence over which computing the estimates.

If you are interested in computing profiles using survival probabilities, then I suggest you to look also at the package msmtools which has been specifically developed to work together with msm. You can use the function survplot() to visualize a patient specific survival curve with respect to a given set of covariates.

franz