| viterbi {hmm.discnp} | R Documentation |
Calculates ``the'' most probable state sequence underlying each of one or more replicate observation sequences.
viterbi(y, object = NULL, tpm, Rho, ispd=NULL)
y |
The observations for which the underlying most probable
hidden states are required. May be a sequence of observations,
or a list each entry of which constitutes an independent sequence
of observations. If y is missing (and if object
is not NULL) then y is extracted from object,
provided that the y component of object is present.
Otherwise an error is given. |
object |
An object describing a hidden Markov model, as
fitted to the data set y by hmm(). |
tpm |
The transition probability matrix for a hidden
Markov model; ignored if object is non-null. |
Rho |
A matrix specifying the probability distributions
of the observations for a hidden Markov model; ignored if
object is non-null. Should bear some reasonable relationship
to y. If Rho has row names then these must
include all values of the observations. If Rho does
not have row names then the values of the observations must
be integers between 1 and nrow(Rho). |
ispd |
The initial state probability distribution for a hidden
Markov model; ignored if object is non-null. Should
bear some reasonable relationship to y. If object
and ispd are both NULL then ispd is set
equal to the stationary distribution calculated from tpm. |
Applies the Viterbi algorithm to calculate ``the'' most probable robable state sequence underlying each observation sequences.
If y consists of a single observation sequence, the
value is the underlying most probable observation sequence,
or a matrix whose columns consist of such sequences if there
is more than one (equally) most probable sequence.
If y consists of a list of observation sequences, the
value is a list each entry of which is of the form described
above.
There may be more than one equally most probable state sequence underlying a given observation sequence. This phenomenon appears to be unlikely to occur in practice.
Rolf Turner
r.turner@auckland.ac.nz
http://www.math.unb.ca/~rolf
Rabiner, L. R., "A tutorial on hidden Markov models and selected applications in speech recognition," Proc. IEEE vol. 77, pp. 257 – 286, 1989.
# See the help for sim.hmm() for how to generate y.num and y.let.
## Not run:
fit.num <- hmm(y.num,K=2,verb=TRUE)
v.1 <- viterbi(object=fit.num)
v.2 <- viterbi(y.num,tpm=P,Rho=R) # P and R as in the
# help for sim.hmm().
# The order of the states has gotten swapped; 3-v.1[[1]] is much
# more similar to v.2[[1]] than is v.1[[1]].
fit.let <- hmm(y.let,K=2,verb=TRUE)
v.3 <- viterbi(object=fit.let) # Works.
v.4 <- viterbi(y.let,tpm=P,Rho=R) # Throws an error (R has no row names.)
## End(Not run)