mps | R Documentation |
Calculates the most probable hidden state underlying each observation.
mps(y, model = NULL, tpm, Rho, ispd=NULL, warn=TRUE)
y |
The observations for which the underlying most
probable hidden states are required. May be a sequence
of observations in the form of a vector or a one or two
column matrix, or a list each component of which constitutes
a (replicate) sequence of observations. It may also be
an object of class If |
model |
An object describing a fitted hidden Markov
model, as returned by |
tpm |
The transition probability matrix for a hidden
Markov model; ignored if |
Rho |
An object specifying the probability distributions of
the observations (“emission” probabilities) for a hidden
Markov model. See |
ispd |
A vector specifying the initial state probability distribution for a hidden Markov model, or a matrix each of whose columns are trivial (“delta function”) vectors specifying the “most probable” initial state for each observation sequence. This argument is ignored if |
warn |
Logical scalar; in the bivariate setting, should a
warning be issued if the two matrices constituting |
For each t the maximum value of gamma_t(i), i.e. of the (estimated) probability that the state at time t is equal to i, is calculated, and the value of the state with the corresponding index is returned.
If y
is a single observation sequence, then the
value is a vector of corresponding most probable states.
If y
is a list of replicate sequences, then the value is
a list, the j-th entry of which constitutes the vector of
most probable states underlying the j-th replicate sequence.
If y
is of class "multipleHmmDataSets"
then the
value returned is a list of lists of the sort described above.
The sequence of most probable states as calculated by this function will not in general be the most probable sequence of states. It may not even be a possible sequence of states. This function looks at the state probabilities separately for each time t, and not at the states in their sequential context.
To obtain the most probable sequence of states use
viterbi()
.
Rolf Turner
r.turner@auckland.ac.nz
Rabiner, L. R., "A tutorial on hidden Markov models and selected applications in speech recognition," Proc. IEEE vol. 77, pp. 257 – 286, 1989.
hmm()
, rhmm()
,
viterbi()
## Not run: P <- matrix(c(0.7,0.3,0.1,0.9),2,2,byrow=TRUE) rownames(P) <- 1:2 R <- matrix(c(0.5,0,0.1,0.1,0.3, 0.1,0.1,0,0.3,0.5),5,2) set.seed(42) lll <- sample(250:350,20,TRUE) set.seed(909) y.num <- rhmm(ylengths=lll,nsim=1,tpm=P,Rho=R,drop=TRUE) fit.num <- hmm(y.num,K=2,verb=TRUE) s.1 <- mps(y.num,fit.num) s.2 <- mps(y.num,tpm=P,ispd=c(0.25,0.75),Rho=R) # The order of the states has got swapped; # note that ifelse(s.1[[1]]=="1","2","1") is much # more similar to s.2[[1]] than is s.1[[1]]. ## End(Not run)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.