sim.hmm {hmm.discnp} | R Documentation |
Simulates one or more replicates of discrete data
from a model such as is fitted by the function hmm()
.
sim.hmm(nsim, tpm, Rho, nrep=1)
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. |
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)
.
Rolf Turner r.turner@auckland.ac.nz http://www.math.unb.ca/~rolf
hmm()
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)