simulate.hsmmspec: Simulation for HSMMs

View source: R/hsmm_functions.R

simulate.hsmmspecR Documentation

Simulation for HSMMs

Description

Simulates values for a specified hidden semi-Markov model

Usage

## S3 method for class 'hsmmspec'
simulate(object, nsim, seed = NULL,rand.emission=NULL,...)

Arguments

object

A hsmmspec object

nsim

An integer or vector of integers (for multiple sequences) specifying the number of states to generate per sequence

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 HSMM of that length is produced. If nsim is a vector of integers, then length(nsim) sequences are generated with respective lengths. Note thate length is the number of states visited, each state will have a sojourn time typically >1 so the vector will be longer than nsim

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

Guedon, Y. (2003), Estimating hidden semi-Markov chains from discrete sequences, Journal of Computational and Graphical Statistics, Volume 12, Number 3, page 604-639 - 2003

See Also

hsmmfit, hsmmspec, predict.hsmm

Examples

J <- 3
init <- c(0,0,1)
P <- matrix(c(0,.1,.4,.5,0,.6,.5,.9,0),nrow=J)
B <- list(mu=c(10,15,20),sigma=c(2,1,1.5))
d <- list(lambda=c(10,30,60),shift=c(10,100,30),type='poisson')
model <- hsmmspec(init,P,parms.emission=B,sojourn=d,dens.emission=dnorm.hsmm)
train <- simulate(model,rand.emis=rnorm.hsmm,nsim=100,seed=123456)
plot(train,xlim=c(0,400))

mhsmm documentation built on Aug. 23, 2023, 9:06 a.m.