Calculates the conditional probability of one or more state sequences, given the corresponding observations sequences (and the model parameters.
pr(s, y, model=NULL, tpm, Rho, ispd=NULL, warn=TRUE)
Arguments
s: A sequence of states of the underlying Markov chain, or a list of such sequences or a list of lists (!!!) of such sequences.
y: A data set to which a hidden Markov model might be fitted, or a collection of such data sets in the form of an object of class "multipleHmmDataSets" as returned by rhmm()
if the argument nsim is greater than 1. In this latter case s must be a list of the same length as y, and pr() is applied recursively to each pair of entries of s and y.
If y consists of a single observation sequence, it is used with each of the state sequences in s in turn. Otherwise the length of the list y must be the same as the length of the list s. (If not, then an error is given). If y
is missing, it is extracted from model (whence it will not be of class "multipleHmmDataSets"!) provided that model and its y component are not NULL. Otherwise an error is given.
model: An object of class hmm.discnp as returned by hmm().
tpm: The transition probability matrix of the chain. Ignored (and extracted from model instead) if model is not NULL.
Rho: An object specifying the emission probabilities of observations, given the underlying state. See hmm(). Ignored (and extracted from model instead) if model
is not NULL.
ispd: The vector specifying the initial state probability distribution of the Markov chain. Ignored (and extracted from model
instead) if model is not NULL. If both ispd
and model are NULL then ispd is taken to be the stationary distribution of the chain, calculated from tpm.
warn: Logical scalar; should a warning be issued if Rho
hasn't got relevant dimension names? (Note that if this is so, then the corresponding dimension names are formed from the sorted unique values of y or of the appropriate column(s) of y. And if this is so, then the user should be sure that the ordering of the entries of Rho corresponds properly to the the sorted unique values of y.) This argument is passed to the utility function check.yval() which actually issues the warning if warn=TRUE.
Returns
The probability of s given y, or a vector of such probabilities if s and y are lists, or a list of such vectors if y is of class "multipleHmmDataSets".
The conditional probabilities will be tiny if the sequences involved are of any substantial length. Underflow may be a problem. The implementation of the calculations is not sophisticated.