Description Usage Arguments Value Author(s) References See Also Examples

These functions calculate the forward and backward variables for a given model and observation sequence. All computations are carried out in log-space.

1 2 3 4 |

`hmm` |
An object of class |

`obs` |
A vector containing the observation sequence. |

`backward`

returns the *N \times T* matrix of (log transformed) backward variables,
where *N* is the number of states of `hmm`

and *T* is the length of `obs`

.

`forward`

returns a list with components

`logProb` |
log[P( |

`alpha.scaled` |
The matrix of log transformed forward variables. This has the same dimensions
as the matrix returned by |

Peter Humburg

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

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 | ```
## create two state HMM with t distributions
state.names <- c("one","two")
transition <- c(0.1, 0.02)
location <- c(1, 2)
scale <- c(1, 1)
df <- c(4, 6)
model <- getHMM(list(a=transition, mu=location, sigma=scale, nu=df),
state.names)
## obtain observation sequence from model
obs <- sampleSeq(model, 100)
## calculate the probability of the observation given the model
fwd <- forward(model, obs)
fwd$logProb
## compute posterior probabilities
bwd <- backward(model,obs)
post <- bwd + fwd$alpha.scaled
post <- t(t(post) - apply(post,2,logSum))
## get sequence of most likely states
state.seq <- state.names[apply(post,2,which.max)]
``` |

Embedding an R snippet on your website

Add the following code to your website.

For more information on customizing the embed code, read Embedding Snippets.