0

I am trying to fit a multistate model using the 'semimarkov' package in r.

Below are extract of my code the result and the error I could.

 id    state.h state.j            time1 LOC sex
102          1       2         4.000000   0   0
102          2       3         5.850000   0   0
104          1       2         4.991781   0   0 
104          2       3         6.021918   0   0 
112          1       2         5.983562   0   0 
12           2       3         7.016438   0   0

table.state(myuse,states=c("1","2","3"))
# $table.state
#    1   2   3
# 1  0 176 146
# 2 40   0  69
# 3  0   0   0

# $Ncens
# [1] 0

states_1 <- c("1","2","3")
mtrans_1 <- matrix(FALSE, nrow = 3, ncol = 3)
mtrans_1[1, 2:3] <- TRUE
mtrans_1[2, c(1,3)] <- c("E","E")
mtrans_1[3, c(1,2)]<-FALSE
LOC<-as.data.frame(myuse$LOC)

fit <- semiMarkov(data=myuse, states=states_1, mtrans=mtrans_1, cov=LOC)
# Iter: 1 fn: 1422.0248    Pars:   6.14509  3.14830  6.92670  7.09842  2.07645  0.80075  0.54658  0.36697 -0.45446 -0.62291 -0.02601 -0.21957
# Iter: 2 fn: 1422.0248    Pars:   6.14506  3.14823  6.92674  7.09846  2.07645  0.80074  0.54658  0.36697 -0.45447 -0.62292 -0.02598 -0.21955
# solnp--> Completed in 2 iterations
# Error in data.frame(Index = c(1:nprob, rep("-", s)), Transition = transitionsP,  : 
  arguments imply differing number of rows: 5, 4

I would appreciate if someone could explain to me why the error and how best to fix it. Thanks

jlhoward
  • 58,004
  • 7
  • 97
  • 140
mymymine
  • 49
  • 7
  • Most likely you have failed to ensure your `data` and/or `states` inputs are in the exact structure required. Double-check the help page and your inputs. – Carl Witthoft Aug 03 '14 at 11:58
  • @CarlWitthoft I am sure I did specify my mtrans accordingly. I had gone through the help page but could place what the issue was. SemiMarkov package allows for illness-death model as long as the correctly specified in "mtrans" that I did using the "mtrans" for illness-death model as specified in the file. – mymymine Aug 03 '14 at 13:39
  • If that table.state object is supposed to be a transition matrix, then it appears it is malformed. There are no transitions from state 3. – IRTFM Aug 03 '14 at 19:11
  • There is non because state 3 is an absorbing state.Even in my data structure there is to transition out of state 3. – mymymine Aug 03 '14 at 20:13

1 Answers1

0

I have several suggestions: - look carefully at the required data input for the semiMarkov() function, and don't forget to look at the required classes and order of the columns as this can only be in 1 format - look at the mtrans distribution matrix and only use either "FALSE", "E" or "W" instead of TRUE - start by fitting a semimarkov model without covariates until that works