View source: R/hmm_functions.R
simulate.hmmspec | R Documentation |
Simulates data from a hidden Markov model
## S3 method for class 'hmmspec'
simulate(object, nsim, seed = NULL, rand.emission=NULL,...)
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. |
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 |
s |
A vector of length |
N |
A vector of the length of each observation sequence (used to segment x and s) |
Jared O'Connell jaredoconnell@gmail.com
Rabiner, L. (1989), A tutorial on hidden Markov models and selected applications in speech recognition, Proceedings of the IEEE, 77, 257-286.
hmmspec
, link{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, parms.emission=b,dens.emission=dnorm.hsmm)
train <- simulate(model, nsim=100, seed=1234, rand.emis=rnorm.hsmm)
plot(train)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.