The Viterbi algorithm is used for global decoding of the hidden state
sequence. Global decoding is based on the conditional probability
\(p(S_1, \ldots, S_T \mid Y_1, \ldots, Y_T)\), and consists of determining,
at each time point \(t = 1, \ldots, T\):
$$s*_t = \arg \max_{i=1}^N p(S_1 = s*_1, \ldots, S_{t-1} = s*_{t-1}, S_t = i, S_{t+1} = s*_{t+1}, \ldots, S_T = s*_{T} \mid Y_1, \ldots, Y_T)$$
where N is the total number of states.
The Viterbi algorithm is a dynamic programming algorithm that relies on
"delta" probabilities (see Rabiner, 1989), which are defined as the joint
probability of the most likely state sequence ending in state i at time t,
and all the observations up to time t. The implementation here normalizes
these probabilities on a time-point basis, dividing the delta probability
by the sum of the delta probabilities for that time point for all possible states
j (including state i)). The normalized delta probabilities for
each state are returned in columns 2:(nstates(object) + 1)
, whilst
column 1 contains the indices of the maximum a posteriori states.