0

rの「semimarkov」パッケージを使用して、多状態モデルを適合させようとしています。

以下は、私のコードの結果とエラーの抜粋です。

 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

誰かがエラーの理由とそれを修正する最善の方法を説明していただければ幸いです。ありがとう

4

1 に答える 1