我正在尝试使用包 MHMM BAYES 运行 HMM。我已经按照教程中的说明设置了我的代码(https://cran.r-project.org/web/packages/mHMMbayes/vignettes/tutorial-mhmm.html)见下文
m<-2
ndep<-9
qemiss <- c(2, 2, 2, 2, 2, 2, 2, 2, 2)
start_EM_F <- list(matrix(c(0.6, 0.4,
0.4, 0.6), byrow = TRUE, nrow = m,
ncol = q_emiss[1]), #ag_sniff
matrix(c(0.4, 0.6,
0.6, 0.4), byrow = TRUE, nrow = m,
ncol = q_emiss[2]), #allogroom
matrix(c(0.6, 0.4,
0.4, 0.6), byrow = TRUE, nrow = m,
ncol = q_emiss[3]), #face_sniff
matrix(c(0.6, 0.4,
0.4, 0.6), byrow = TRUE, nrow = m,
ncol = q_emiss[4]),# flank_sniff
matrix(c(0.9, 0.1,
0.1, 0.9), byrow = TRUE, nrow = m,
ncol = q_emiss[5]), #withdraw
matrix(c(0.3, 0.7,
0.3, 0.7), byrow = TRUE, nrow = m,
ncol = q_emiss[6]), #end
matrix(c(0.1, 0.9,
0.9, 0.1), byrow = TRUE, nrow = m,
ncol = q_emiss[7]), #kick
matrix(c(0.3, 0.7,
0.7, 0.3), byrow = TRUE, nrow = m,
ncol = q_emiss[8]), #pin
matrix(c(0.1, 0.9,
0.9, 0.1), byrow = TRUE, nrow = m,
ncol = q_emiss[9])) #bite
start_TMF <- diag(.6, m)
start_TMF[lower.tri(start_TMF) | upper.tri(start_TMF)] <- .4
set.seed(14532)
out_2st <- mHMM(s_data = LSAF,
gen = list(m = m, n_dep = ndep, q_emiss = qemiss),
start_val = c(list(start_TMF), start_EM_F),
mcmc = list(J = 1000, burn_in = 200))
但是,当我尝试运行模型时,出现以下错误:
Error in inp[, q] <- emiss[[q]][, x[i, q]] : replacement has length zero
我尝试检查类似的问题,但它们似乎没有帮助。