Last data update: 2014.03.03

R: Viterbi Algorithm
viterbicontR Documentation

Viterbi Algorithm

Description

The function performs Viterbi algorithm (Viterbi, 1967). It can be applied to a ContObservHMM object after sufficient number of Baum-welch iterations (function baumwelchcont).

Usage

viterbicont(hmm)

Arguments

hmm

An object of the class ContObservHMM.

Value

An object of the class ContObservHMM (see section on the function hmmsetcont). The object can be analysed with the class-specific functions print, summary, and plot.

Author(s)

Mikhail A. Beketov

References

Viterbi, A.J. 1967. Error bounds for convolutional codes and an asymptotically optimum decoding algorithm. IEEE Transactions on Information Theory. 13: 260-269.

See Also

Functions: hmmsetcont, baumwelchcont, and statesDistributionsPlot.

Examples


Returns<-logreturns(Prices) # Getting a stationary process
Returns<-Returns*10 		# Scaling the values
hmm<-hmmsetcont(Returns) 	# Creating a HMM object
for(i in 1:6){hmm<-baumwelchcont(hmm)} # Baum-Welch is 
# executed 6 times and results are accumulated

hmmcomplete<-viterbicont(hmm) # Viterbi execution

par(mfrow=c(2,1))
plot(hmmcomplete, Prices, ylabel="Price") 
plot(hmmcomplete, ylabel="Returns") # the revealed 
# Markov chain and the observations are plotted

Results


R version 3.3.1 (2016-06-21) -- "Bug in Your Hair"
Copyright (C) 2016 The R Foundation for Statistical Computing
Platform: x86_64-pc-linux-gnu (64-bit)

R is free software and comes with ABSOLUTELY NO WARRANTY.
You are welcome to redistribute it under certain conditions.
Type 'license()' or 'licence()' for distribution details.

R is a collaborative project with many contributors.
Type 'contributors()' for more information and
'citation()' on how to cite R or R packages in publications.

Type 'demo()' for some demos, 'help()' for on-line help, or
'help.start()' for an HTML browser interface to help.
Type 'q()' to quit R.

> library(HMMCont)
> png(filename="/home/ddbj/snapshot/RGM3/R_CC/result/HMMCont/viterbicont.Rd_%03d_medium.png", width=480, height=480)
> ### Name: viterbicont
> ### Title: Viterbi Algorithm
> ### Aliases: viterbicont
> ### Keywords: Viterbi Hidden Markov Model
> 
> ### ** Examples
> 
> 
> Returns<-logreturns(Prices) # Getting a stationary process
> Returns<-Returns*10 		# Scaling the values
> hmm<-hmmsetcont(Returns) 	# Creating a HMM object
> for(i in 1:6){hmm<-baumwelchcont(hmm)} # Baum-Welch is 
> # executed 6 times and results are accumulated
> 
> hmmcomplete<-viterbicont(hmm) # Viterbi execution
> 
> par(mfrow=c(2,1))
> plot(hmmcomplete, Prices, ylabel="Price") 
> plot(hmmcomplete, ylabel="Returns") # the revealed 
> # Markov chain and the observations are plotted
> 
> 
> 
> 
> 
> dev.off()
null device 
          1 
>