Viterbi algorithm for state decoding in HMMs
viterbi.RdThe Viterbi algorithm decodes the most probable state sequence of an HMM.
Arguments
- delta
initial distribution; either
a vector of length
nStates,a matrix of dimension
c(nTracks, nStates)iftrackIDis provided, ora model object as for
mod, so thatmodcan be passed as the first argument
- Gamma
transition probability matrix; either
a matrix of dimension
c(nStates, nStates),an array of dimension
c(nStates, nStates, nTracks)iftrackIDis provided,an array of dimension
c(nStates, nStates, nObs)for time-varying transition probabilities, oran array of dimension
c(nStates, nStates, L)for periodic transition probabilities, iftodis provided
- allprobs
matrix of state-dependent probabilities or density values of dimension
c(nObs, nStates)- trackID
optional vector of length
nObscontainingnTracksunique IDs that separate tracks. The observations of each track need to be consecutive.- mod
optional model object containing
delta,Gamma,allprobs, and optionallytrackID. When usingRTMB::MakeADFunorqremlwithforwardin the likelihood, these are reported automatically after model fitting and the object returned byobj$report(),lamaorqremlcan be passed directly.- tod
optional integer vector of length
nObswith values in 1, ..., L, indexing the slices ofGammafor periodic models
See also
Other decoding functions:
stateprobs(),
stateprobs_g(),
stateprobs_p(),
viterbi_g(),
viterbi_p()