Description Usage Arguments Value Examples
Simulating Hidden Markov objects
1 2 |
object |
Object of class 'hmm'. |
nsim |
Number of simulations. |
seed |
Seed to be used for random generation. |
include_state |
Logical, whether or not the hidden state should also be returned. |
... |
Additional arguments. |
If observations are available in the 'hmm' object, will return a matrix with 'nsim' rows, each of which being a simulation of equal length as the observed data. Otherwise, will return a vector of length 'nsim' of simulations from the model. In either case, if 'include_state' is 'TRUE', each simulation will be appended with a vector of equal length indicating the hidden state.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 | # Continuing examples from hmm page
# Normal distributions
X.normal <- simulate(hmm.normal, nsim=100)
summary(X.normal)
plot(X.normal)
hist(X.normal)
# Custom (uniform) distributions
Z.unif <- simulate(hmm.unif, nsim=200, include_state=TRUE)
X.unif <- Z.unif[1:100]
G.unif <- Z.unif[101:200]
plot(X.unif, type='h', col=G.unif, lwd=2)
# Custom (mixed) distributions
Z.mixture <- simulate(hmm.mixture, nsim=200, include_state=TRUE)
X.mixture <- Z.mixture[1:200]
G.mixture <- Z.mixture[201:400]
plot(X.mixture, type='h', col=G.mixture, lwd=2)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.