2

I have some problems with the viterbiTraining function from the HMM package. I tried using it on a pretty straightforward hmm and a vector of observations.

Here's the code:

Emisije<-rep("IntervalC",length(Cl1.res))
Emisije[IntervalA[,1]]<-"IntervalA"
Emisije[IntervalB[,1]]<-"IntervalB"

The Emisije vector looks like this:

head(Emisije)

[1] "IntervalA" "IntervalA" "IntervalA" "IntervalC" "IntervalB" "IntervalA"

startProbs<-c(0.6873065,0.3126935)
transProbs<-matrix(c(0.8, 0.7, 0.2,0.3),ncol=2)
emissionProbs<-matrix(rep(1/3,6),ncol=3)

stanji<-initHMM(c("NizkaVar", "VisokaVar"), c("IntervalA", "IntervalB", 
    "IntervalC"), startProbs, transProbs, emissionProbs)

After running this everything works, except for the viterbiTraining function, which gives the following result:

viterbiTraining(stanji,Emisije)

Error in if (d < delta) { : missing value where TRUE/FALSE needed

Even the similar function baumWelch, which takes the exact same parameters, works without errors, so I really don't understand what's wrong here.

Can anyone please explain to me what I am doing wrong? Thank you in advance.

Community
  • 1
  • 1
  • What exactly is your variable `Emisije` or `CL1.res`? – J_F Sep 20 '16 at 12:28
  • The variable is written upside, it's a vector consisting of 646 strings. Each string is either `"IntervalA"`, `"IntervalB"` or `"IntervalC"`. The variable `Cl1.res` is not important here apart from its length (which I used for constructing the Emisije vector, as you can see in the original message). – Črt Grahonja Sep 20 '16 at 12:34
  • In my opinion this will not work with three (or more) symbols. All examples in the manual are with two symbols and when you want to extend them there will always be the error you reported – J_F Sep 20 '16 at 13:36
  • So there's nothing wrong with my code, then? – Črt Grahonja Sep 20 '16 at 13:51

0 Answers0