我是 R 新手。在制作隐马尔可夫模型时,我们必须提供以下参数;初始概率、发射概率、过渡概率、观测值。但我收到以下错误
initial_probs 的长度不等于状态数
有人可以帮我解决这个错误吗?提前致谢
编辑:这是我在谷歌驱动器上上传的示例数据
这是代码
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)