gen linlin
gen linlin

Reputation: 31

How to use markovMSM package to test the Markov assumption based on the panel data?

I am currently working with panel data and would like to test the Markov assumption using either markovMSM or mstate. However, I am facing some confusion regarding the appropriate data format required for these analyses.

Consider I use msm package to fit Multi-state model, my data like this:

> msm::psor

    ptnum  months state hieffusn ollwsdrt
1       1  6.4606     1        0        1
2       1 17.0780     1        0        1
3       2 26.3217     1        0        0
4       2 29.4839     3        0        0
5       2 30.5763     4        0        0

But when I find the markoMSM or mstate required the long format, like this:

Data:
  id from to trans Tstart Tstop status   treat
1  1    2  1     3      0   151      0 Placebo
2  1    2  3     4      0   151      1 Placebo
3  2    2  1     3      0   251      1 Placebo
4  2    2  3     4      0   251      0 Placebo
5  2    1  2     1    251   434      1 Placebo
6  2    1  3     2    251   434      0 Placebo

Or using prepMSM based on the data format like this:

library(markovMSM)
data("colonMSM")
db_wide<-colonMSM
positions<-list(c(2, 3), c(3), c()) 
namesStates =  c("Alive", "Rec",  "Death")
tmat <-transMatMSM(positions, namesStates)
timesNames = c(NA, "time1","Stime")
status=c(NA, "event1","event")
trans = tmat
db_long<- prepMSM(data=db_wide, trans, timesNames, status)

> head(db_wide)
  time1 event1 Stime event      rx sex age obstruct perfor adhere nodes
1   968      1  1521     1 Lev+5FU   1  43        0      0      0     5
2  3087      0  3087     0 Lev+5FU   1  63        0      0      0     1
3   542      1   963     1     Obs   0  71        0      0      1     7
4   245      1   293     1 Lev+5FU   0  66        1      0      0     6
5   523      1   659     1     Obs   1  69        0      0      0    22
6   904      1  1767     1 Lev+5FU   0  57        0      0      0     9
  differ extent surg node4
1      2      3    0     1
2      2      3    0     0
3      2      2    0     1
4      2      3    1     1
5      2      3    1     1
6      2      3    0     1
> head(db_long)
An object of class 'msdata'

Data:
  id from to trans Tstart Tstop time status
1  1    1  2     1      0   968  968      1
2  1    1  3     2      0   968  968      0
3  1    2  3     3    968  1521  553      1
4  2    1  2     1      0  3087 3087      0
5  2    1  3     2      0  3087 3087      0
6  3    1  2     1      0   542  542      1

Now I do not know how to convert the data format compatible with markovMSM, and specifically, does each row indicate that a patient was in state1 at a given time1 and remained in state0 until that time1? I do not what means a row from data based on markovMSM? My dataset consists of intermittent observations, meaning that I only have measurements recorded at specific time points rather than continuous tracking of patient states. Given this, I am not sure whether my panel data can be converted into a format compatible with markovMSM.

Additionally, if any part of my explanation is unclear, please let me know, and I will do my best to clarify. I truly appreciate your time and assistance.

Upvotes: 0

Views: 17

Answers (0)

Related Questions