Function hidden_paths
computes the most probable path of
hidden states of a (mixture) hidden Markov model given the observed sequences.
hidden_paths(model, respect_void = TRUE)
The most probable paths of hidden states as an stslist
object
(see seqdef
). The log-probability is included as an attribute log_prob
.
A hidden Markov model of class hmm
or
a mixture HMM of class mhmm
.
If TRUE
(default), states at the time points
corresponding to TraMineR's void in the observed sequences are set to void
in the hidden state sequences as well.
hmm_biofam
for information on the model used in the example;
and seqIplot
, ssplot
, or mssplot
for plotting hidden paths.
# Load a pre-defined HMM
data("hmm_biofam")
# Compute the most probable hidden state paths given the data and the model
mpp <- hidden_paths(hmm_biofam)
# Plot hidden paths for the first 100 individuals
ssplot(mpp, type = "I", tlim = 1:100)
# Because the model structure is so sparse that the posterior probabilities are
# mostly peaked to single state at each time point, the joint probability of
# observations and most probable paths of hidden states is almost identical to
# log-likelihood:
sum(attr(mpp, "log_prob"))
logLik(hmm_biofam)
Run the code above in your browser using DataLab