initial_probs的长度不等于状态数

时间:2018-10-15 19:07:42

标签: r hmmlearn seqhmm

我是R的新手。在制作Hidden markov模型时,我们必须提供以下参数;初始概率,发射概率,过渡概率,观测值。 但是我遇到了以下错误

  

initial_probs的长度不等于状态数

有人可以帮助我解决此错误吗? 预先感谢

编辑:这是我在Google云端硬盘上上传的示例数据

Sample data on google drive

这是代码

    library(HMM)
    library(seqHMM)
    library(TraMineR)
    library(markovchain)

    let_alphabet <- c("1", "0", "2", "3", "4", "5", "6", "7", "8", "9", "10", "S", "D", "UK")
    let_labels <- c("i","O","ii","iii","iv","v","vi","vii","viii","ix","x","Son","Daughter","Unknown")
    let_scodes <- c("1","0","P2","P3","P4","P5","P6","P7","P8","P9","P10","Sn","Daugt","NA")
    let_seq <- seqdef(letsdo, 1:3, alphabet = let_alphabet, states = let_scodes,labels = let_labels, xtstep = 14)

    init_hmm_let <- build_hmm(observations = let_seq, n_states = 2)
   #Transition prob
  trp <- seqtrate(let_seq)
#Initial prob
    inist <- c(0.53, 0.47)
#Emission Prob
    emisp <- matrix(NA, nrow = 2, ncol = 2)
    emisp[1,]<- c(0.51,0.48)
    emisp[2,]<- c(0.58,0.41)
#Building the model
    init_hmm_let <- build_hmm( observations = let_seq, transition_probs = trp,
                                 emission_probs = emisp, initial_probs = inist)

0 个答案:

没有答案