R: Simulation of hidden Markov models

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 `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
`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 `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)

### 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)

[Package mhsmm version 0.4.16 Index]