sim.hmm {hmm.discnp}R Documentation

Simulate discrete data from a hidden Markov model.

Description

Simulates one or more replicates of discrete data from a model such as is fitted by the function hmm().

Usage

sim.hmm(nsim,tpm,Rho,ispd=NULL,yval=NULL)

Arguments

nsim Vector of the lengths of the sequences of observations to be generated.
tpm The transition probability matrix for the underlying hidden Markov chain(s). Note that the rows of tpm must sum to 1. Ignored if ncol(Rho)==1.
Rho A matrix specifying the probability of an observation taking on one of a set of possible values, given the state of the underlying hidden Markov chain. Note that the columns of Rho must sum to 1. If ncol(Rho)==1 the simulated data are i.i.d. from the distribution specified by the single column of Rho.
ispd A vector specifying the initial state probability distribution of the chain. If this is not specified it is taken to be the stationary distribution of the chain, calculated from tpm.
yval Vector of numbers or character strings constituting the possible values of the observations. If not supplied it is taken to equal 1:nrow(Rho).

Value

If length(nsim)==1 then the value returned is a vector of length nsim. If length(nsim)>1 then the value returned is a list of the same length as nsim, each component of which is an independent vector of simulated observations. The length of component i of this list is equal to nsim[i]. The values of the observations are entries of yval.

Author(s)

Rolf Turner r.turner@auckland.ac.nz
http://www.math.unb.ca/~rolf

See Also

hmm()

Examples

P <- matrix(c(0.7,0.3,0.1,0.9),2,2,byrow=TRUE)
R <- matrix(c(0.5,0,0.1,0.1,0.3,
              0.1,0.1,0,0.3,0.5),5,2)
set.seed(42)
y.num <- sim.hmm(rep(300,20),P,R)
y.let <- sim.hmm(rep(300,20),P,R,yval=letters[1:5])

[Package hmm.discnp version 0.1-1 Index]