I am having trouble understanding how to use the method baumWelch in the package HMM.
According to the documentation we first have to initialize our hidden markov model
hmm = initHMM(c("A","B"), c("L","R"), transProbs=matrix(c(.8,.2,.2,.8),2),
emissionProbs=matrix(c(.6,.4,.4,.6),2)
This means that states are named "A" and "B" emissions are named "L" and "R" we have transmission and emission probabilities as well.
So far so good, but now the tutorial creates the list of observations:
observations = sample(c("L","R"),prob=c(.8,.2),size=100,replace=TRUE)
this is a one dimensional vector as a list of observations. According to description from Rabiner's classic paper that Forward and Backward probabilities are calculated on a sequence of observations such as the variable observations in the above code. i.e. We need a matrix of such observations in order to even remotely train anything. How do I do that here?
EDIT:
In the example above the emissions are "L" and "R". An obesevation sequence O should be created with those emissions. e.g. O = LRRRLLLRR, etc. suppose length is t
An observation of this sort is used in the forward algorithm which given a full markov model and an observation sequence O will generate a matrix of dimensions n x t where n is the number of states in our HMM the i j _th element of such a matrix is interpreted as "being at time j, having generated the first j elements of observational sequence and being in state i".
Now forward as well as backward and several other algorithms are used in the Baum-Welch training algorithms.
I believe that the input to Baum-Welch should a a list of observational sequences and NOT a list of emissions. In my version the dimensions of the matrix input should be t times m where t is the length of observational sequence and m is the number of such sequences.
How do I understand the input here? is it that we have a hundred observational sequences of length 1? How do I provide such a matrix to baumWelch method in HMM