viterbi: Viterbi Function

Description Usage Arguments Value References Examples

View source: R/viterbi.R

Description

This function computes the best sequence of states for a Hidden Markov Model

Usage

1
viterbi(hmm)

Arguments

hmm

a hmm object obtained from the setHMM function

Value

The function returns a vector q of integers indicating the best state sequence for a HMM

References

Rabiner, L. R. (1989). A tutorial on hidden Markov models and selected applications in speech recognition. Proceedings of the IEEE, 77(2), 257-286.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
data(copulahmmdata)
Obs <- copulahmmdata
n <- 20 #number of statistical units
n_tot <- dim(Obs)[1]
bt <- seq(1, n_tot, by = n)
distr <- c("exp", "gaussian")
#Initialize the HMM
parameters <- list( as.matrix(c(1,0.25)), matrix(c(3, -1, 1, 1), nrow = 2))
corr <- array(c(1, 0.4, 0.4, 1, 1, 0.1, 0.1, 1), dim = c(2, 2, 2))
hmm <- set_mhmm(Obs, bT = bt, nStates = 2, params = parameters, corr = corr, distr = distr)
# Compute the parameters of the HMM with the Baum-Welch algorithm
bw <- fitBM_mhmm(hmm)

v <- viterbi(bw)

hmmhdd documentation built on Sept. 4, 2019, 5:03 p.m.

Related to viterbi in hmmhdd...