simulate.hmmspec {mhsmm} | R Documentation |
Simulates data from a hidden Markov model
## S3 method for class 'hmmspec': simulate(object, nsim, seed = NULL, ...)
object |
A hmmspec object |
nsim |
An integer or vector of integers (for multiple sequences) specifying the length of the sequence(s) |
seed |
seed for the random number generator |
... |
further arguments passed to or from other methods. |
If nsim
is a single integer then a HMM of that length is produced. If nsim
is a vector of integers, then length(nsim)
sequences are generated with respective lengths.
An object of class hmmdata
x |
A vector of length sum(N) - the sequence(s) of observed values |
s |
A vector of length sum(N) - the sequence(s) of hidden states |
N |
A vector of the length of each observation sequence (used to segment x and s) |
Jared O'Connell
Rabiner, L. (1989), A tutorial on hidden Markov models and selected applications in speech recognition, Proceedings of the IEEE, 77, 257-286.
hmmspec, simulate.hmm, hmm, predict.hmm
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) train <- simulate(model, nsim=100, seed=1234) plot(train)