simulate.hmmspec {mhsmm} | R Documentation |
Simulation of hidden Markov models
Description
Simulates data from a hidden Markov model
Usage
## S3 method for class 'hmmspec'
simulate(object, nsim, seed = NULL, rand.emission=NULL,...)
Arguments
object |
A |
nsim |
An integer or vector of integers (for multiple sequences) specifying the length of the sequence(s) |
seed |
|
rand.emission |
The function used to generate observations from the emission distribution |
... |
further arguments passed to or from other methods. |
Details
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.
Value
An object of class hmmdata
x |
A vector of length |
s |
A vector of length |
N |
A vector of the length of each observation sequence (used to segment x and s) |
Author(s)
Jared O'Connell jaredoconnell@gmail.com
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
hmmspec
, link{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, parms.emission=b,dens.emission=dnorm.hsmm)
train <- simulate(model, nsim=100, seed=1234, rand.emis=rnorm.hsmm)
plot(train)