hmm {mhsmm}R Documentation

hidden Markov model

Description

Estimates parameters of a HMM using the EM algorithm.

Usage

hmm(x,start.val,f=dnorm.hsmm,mstep=mstep.norm,tol=1e-08,maxit=1000) 

Arguments

x A hsmm.data object (see Details)
start.val Starting parameters for the model (see Details)
f Density function of the emmission distribution
mstep Re-estimates the parameters of density function on each iteration
maxit Maximum number of iterations
tol Convergence tolerance

Value

start A vector of the starting probabilities for each state
a The transition matrix of the embedded Markov chain
emission A list of the parameters of the emission distribution

Author(s)

Jared O'Connell

References

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

See Also

sim.hmm, sim.mhmm, predict.hmm

Examples

J<-3
initial <- rep(1/J,J)
P <- matrix(c(.8,.5,.1,0.05,.2,.5,.15,.3,.4),nrow=J)
b <- list(mu=c(-3,0,2),sigma=c(2,1,.5))
model <- hmmspec(init=initial, trans=P, emission=b, r=rnorm.hsmm)
model

train <- simulate(model, nsim=300, seed=1234)
plot(train,xlim=c(0,100))

init0 <- rep(1/J,J)
P0 <- matrix(1/J,nrow=J,ncol=J)
b0 <- list(mu=c(-3,1,3),sigma=c(1,1,1))
startval <- hmmspec(init=init0, trans=P0,emission=b0) 
h1 = hmm(train,startval,f=dnorm.hsmm,mstep=mstep.norm)

plot(h1$loglik,type='b',ylab='Log-likelihood',xlab='Iteration')
summary(h1)

[Package mhsmm version 0.1.0 Index]