# backward: Infer the backward probabilities for all the nodes of the... In treeHMM: Tree Structured Hidden Markov Model

## Description

`backward` calculates the backward probabilities for all the nodes

## Usage

 `1` ```backward(hmm, observation, bt_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 `bt_seq` A vector denoting the order of nodes in which the tree should be traversed in backward direction(from leaves to roots). Output of `bwd_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 backward probability for state X and observation at node k is defined as the probability of observing the sequence of observations e_k+1, ... ,e_n under the condition that the state at node k is X. That is:
`b[X,k] := Prob(E_k+1 = e_k+1, ... , E_n = e_n | X_k = X)`
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 backward 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

`forward`

## 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 bt_sq = bwd_seq_gen(hmmA) kn_st = data.frame(node=c(3),state=c("P"),stringsAsFactors = FALSE) #state at node 3 is known to be "P" BackwardProbs = backward(hmmA,obsv,bt_sq,kn_st) ```

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