我需要在这个错误上得到一些帮助。我正在尝试使用R中的HMM包构建一个HMM模块。我无法理解我的代码有什么问题。错误出现在使用Baum-Welch算法训练HMM时。
lathmm = initHMM(c("S","M1","M2","M3","M4","E"),c("m","i"),c(1,0,0,0,0,0),
+ matrix(c( 0,0,0,0,0,0,
+ 1,0,0,0,0,0,
+ 0,1,0,0,0,0,
+ 0,0,1,0,0,0,
+ 0,0,0,1,0,0,
+ 0,0,0,0,1,1
+ ),6,6),
+ matrix(c(0,.5,.5,.5,.5,.5,
+ 0,.5,.5,.5,.5,.5
+ ),6,2))
>
> print(lathmm)
$States
[1] "S" "M1" "M2" "M3" "M4" "E"
$Symbols
[1] "m" "i"
$startProbs
S M1 M2 M3 M4 E
1 0 0 0 0 0
$transProbs
to
from S M1 M2 M3 M4 E
S 0 1 0 0 0 0
M1 0 0 1 0 0 0
M2 0 0 0 1 0 0
M3 0 0 0 0 1 0
M4 0 0 0 0 0 1
E 0 0 0 0 0 1
$emissionProbs
symbols
states m i
S 0.0 0.0
M1 0.5 0.5
M2 0.5 0.5
M3 0.5 0.5
M4 0.5 0.5
E 0.5 0.5
-> 初始化HMM时没有问题。
Baum-Welch训练:
> prot = sample(c(rep("m",100),rep("m",300)))
> bw = baumWelch(lathmm,prot,10)
Error in if (d < delta) { : missing value where TRUE/FALSE needed
-> 这是错误信息。
有谁可以帮我解决这个问题。我不确定这个模块出了什么问题。