forward: Infer the forward probabilities for all the nodes of the...

Description Usage Arguments Details Value See Also Examples

Description

forward calculates the forward probabilities for all the nodes

Usage

1
forward(hmm, observation, ft_seq, kn_states = NULL)

Arguments

hmm

hmm Object of class List given as output by initHMM

observation

A list consisting "k" vectors for "k" features, each vector being a character series of discrete emmision values at different nodes serially sorted by node number

ft_seq

A vector denoting the order of nodes in which the tree should be traversed in forward direction(from roots to leaves). Output of fwd_seq_gen function.

kn_states

(Optional) A (L * 2) dataframe where L is the number of training nodes where state values are known. First column should be the node number and the second column being the corresponding known state values of the nodes

Details

The forward probability for state X up to observation at node k is defined as the probability of observing the sequence of observations e_1,..,e_k given that the state at node k is X. That is:
f[X,k] := Prob( X_k = X | E_1 = e_1,.., E_k = e_k)
where E_1...E_n = e_1...e_n is the sequence of observed emissions and X_k is a random variable that represents the state at node k

Value

(N * D) matrix denoting the forward probabilites at each node of the tree, where "N" is possible no. of states and "D" is the total number of nodes in the tree

See Also

backward

Examples

1
2
3
4
5
6
7
8
tmat = matrix(c(0,0,1,0,0,0,0,1,0,0,0,0,0,1,1,0,0,0,0,0,0,0,0,0,0),
                5,5, byrow= TRUE ) #for "X" (5 nodes) shaped tree
hmmA = initHMM(c("P","N"),list(c("L","R")), tmat) #one feature with two discrete levels "L" and "R"
obsv = list(c("L","L","R","R","L")) #emissions for the one feature for the 5 nodes in order 1:5
ft_sq = fwd_seq_gen(hmmA)
kn_st = data.frame(node=c(3),state=c("P"),stringsAsFactors = FALSE) 
                   #state at node 3 is known to be "P"
ForwardProbs = forward(hmmA,obsv,ft_sq,kn_st)

treeHMM documentation built on Dec. 16, 2019, 1:38 a.m.

Related to forward in treeHMM...