0
$\begingroup$

I am new to msm package and markov models. I have a randomized trial dataset with readings from three time points: baseline, at 1 year, and at 2 year. I am trying to calculate annual transition probabilities and mean soujurn time for each state for the following two scenarios.

  1. NGT to iIFG and regression to NGT or progression to diabetes (i.e., NGT <-> iIFG -> diabetes)
  2. NGT to iIFG to diabetes (i.e., NGT -> iIFG -> diabetes)

States are glycemic states (NGT (state=1), iIFG (state=2), and diabetes (state=3)). Diabetes is the absorbing state.

Here is what my data looks like. Note that not all participants have reading from all 3 time points, but all of them have readings for atleast 2 time points (baseline and at 1 year). There are no NA values in the df. Time is in years. I set the time for baseline reading as 0.

showing some rows for example.

participant_num | time | state
2   0.0000000   2       
2   2.0123203   3       
3   0.0000000   1       
3   1.0157427   1       
3   2.0123203   1       
4   0.0000000   2       
4   1.0157427   2       
4   2.0123203   3       
5   1.0157427   2       
5   2.0123203   2       
7   0.0000000   1       
7   1.0157427   1       
7   2.0123203   2       
8   0.0000000   2       
8   1.0157427   2       
8   2.0123203   2       
9   0.0000000   2       
9   1.0157427   1       
9   2.0123203   1       
10  0.0000000   2       
10  1.0157427   1       
10  2.0123203   1

m1 <- statetable.msm(state, participant_num, data=df)
m1

     to
 from   1   2   3
    1 269 195   6
    2 162 626  58
    3   0   1  42

summary(df$time)
 
    Min. 1st Qu.  Median    Mean 3rd Qu.    Max. 
   0.000   0.000   1.185   1.039   2.012   2.585 

##scenario 1: NGT <-> iIFG -> diabetes

trans_mat <- matrix(c(1, 1,1,
                      1, 1, 1,
                      0, 0, 0),
                    nrow = 3, byrow = TRUE)
rownames(trans_mat) <- colnames(trans_mat) <- c("NGT", "iIFG", "Diabetes")

          NGT iIFG Diabetes
 NGT        1    1        1
 iIFG       1    1        1
 Diabetes   0    0        0

mm <- msm(state ~ time, subject=participant_num, data=df, deathexact=TRUE, gen.inits = TRUE, qmatrix=trans_mat)

Error in optim(method = "BFGS", control = list(), par = c(qbase = -0.943801885337371,  : 
  initial value in 'vmmin' is not finite

How should I solve this? Is my trans_mat wrong? or the format of my data is wrong? I would appreciate any help and suggestions. Thank you!

$\endgroup$
1
  • $\begingroup$ It certainly would help the software to supply a valid and non-singular starting transition matrix! $\endgroup$
    – whuber
    Commented May 3 at 16:45

1 Answer 1

0
$\begingroup$

Regarding your transition structure, while it doesn't solve your primary issue, your data seems intermittent so transition states should be adjacent. E.g., NGT does not switch directly to diabetes in any cycle, as the transition from NGT to iiFG occurred prior and was simply not observed. There is also no transition within its own state. I think it would be:

         matrix(c(0, 1, 0,

                 (1, 0, 1,

                 (0, 0, 0)

A similar question was asked here (Multi-State Numerical overflow using MSM package in R) that might be helpful. I encountered this same problem with msm in the past and found that I had a few observations in which the transition times were reversed, likely due to data entry errors. Upon correction the function worked.

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.