HFMviterbi: Calculates the most probable Hidden State path

Description Usage Arguments Details Value Author(s) Examples

View source: R/HFMviterbi.R

Description

The function calculates the most probable hidden state path for an observation sequence.

Usage

1
2
HFMviterbi(observationSequence,nHStates,dataNodeIndices,priorInit,
transmatInit,transInitDiv,type,emissionProb=c(),sigma=c(), mu=c())

Arguments

observationSequence

The observation sequence, either a matrix of size KxN, whereas K is the dimension of the data and N the lenght of the sequence or of size 1xK whereas the entries are discrete.

nHStates

Number of hidden states H

dataNodeIndices

The data structure. A list of the toplogy of every data entry of the format [parentIndex childIndex].

priorInit

The state probabilities

transmatInit

The transtition probabilities for sequential transitions (H x H)

transInitDiv

The transtition probabilities for splitting events (H x (H*H)

type

Type of the data. ('d' discrete or 'c' continous)

emissionProb

Emission probilities for discrete data, a matrix of size E x H, whereas E are the number of discrete observable states.

sigma

Covariance matrix for continous data

mu

Means for continous data

Details

The algorithm calculates the most probable hidden state path for an observation matrix.

Value

A list of two entries: Path matrix: 1. Column: Node index 2. Column: Hidden state 3. Column: Branch of the tree 4. Column: Parent branch

Accossiation of tree branches to parent branches: 1. Column: Parent branch 2. Column child branch.

Author(s)

Henrik Failmezger, failmezger@googlemail.com

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
## Fit a continous treeHFM ## 
nHStates = 2;
########create observation sequences########
obs1 <- rbind(runif(10,0,1),runif(10,0,1))
obs2 <- rbind(runif(8,0,1),runif(8,0,1))
data=list()
data[[1]]=obs1
data[[2]]=obs2
######### create guesses for gaussian covariance matrix and means #########
mc2 <- Mclust(t(cbind(obs1,obs2)), G=2)
muInit=mc2$parameters$mean;
SigmaInit=mc2$parameters$variance$sigma
#########create tree topology####################################
nodeIndices1=cbind(c(0,1,2,3,3,4,5,6,7,8),c(1,2,3,4,5,6,7,8,9,10));
nodeIndices2=cbind(c(0,1,2,3,4,4,5,6),c(1,2,3,4,5,6,7,8));
dataNodeIndices=list()
dataNodeIndices[[1]]=nodeIndices1;
dataNodeIndices[[2]]=nodeIndices2;
######### create guesses for prior and transition matrices#########
prior1=array(1,nHStates);
priorInit = array(1,nHStates)/nHStates;
transmatInit = matrix(1,nHStates,nHStates)*(1/nHStates);
transInitDiv= matrix(1,nHStates,nHStates*nHStates)*(1/(nHStates*nHStates))
#
hfm=HFMfit(data,nHStates,dataNodeIndices,priorInit,transmatInit,transInitDiv,'c',
SigmaInit=SigmaInit, muInit=muInit);
# calculate Viterbi path
viterbi=HFMviterbi(obs1,nHStates,nodeIndices1,hfm$initProb,hfm$transMatSeq,hfm$transMatDiv,
'c',sigma=hfm$sigma, mu=hfm$mu);

treeHFM documentation built on May 30, 2017, 3:01 a.m.

Related to HFMviterbi in treeHFM...