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, nrep=1)

Arguments

nsim The length of each sequence of observations.
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 data are i.i.d. from the distribution specified by the single column of Rho.
nrep The number of independent replicate sequences of observations.

Value

A matrix with nsim rows and nrep columns; if nrep==1, then the returned value is a vector of length nsim. Each column of the matrix forms an independent replicate of observations from the specified hidden Markov model. The values of those observations are integers between 1 and nrow(Rho).

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.sim <- sim.hmm(300,P,R,20)

[Package hmm.discnp version 0.0-9 Index]