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.
|
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.
|
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 a hidden Markov model. The values of
those observations are integers between 1 and nrow(Rho)
.
hmm()
P <- matrix(c(0.7,0.3,0.1,0.9),2,2,byrow=TRUE) R <- matrix(c(0.33,0.24,0.05,0.24,0.23, 0.23,0.33,0.25,0.06,0.04), 5,2,byrow=TRUE) y.sim <- sim.hmm(300,P,R,20)