| simulate.mmfit | R Documentation |
Simulates sequences from a fitted Markov model.
## S3 method for class 'mmfit'
simulate(object, nsim = 1, seed = NULL, ...)
object |
An object of class |
nsim |
An integer or vector of integers (for multiple sequences) specifying the length of the sequence(s). |
seed |
Optional. |
... |
further arguments passed to or from other methods. |
Notation (see smmR-package for the complete description of the models):
(Z_n)_{n \in \mathbb{N}} is a Markov chain of order
k on E, with s = \textrm{card}(E), initial
distribution init and transition matrix ptrans of dimension (s^k,
s).
If nsim is a single integer then a chain of that length is
produced. If nsim is a vector of integers, then length(nsim)
sequences are generated with respective lengths.
A list of vectors representing the sequences.
mm, fitmm
x <- mm(states = c("a", "b"), init = c(0.5, 0.5), k = 1,
ptrans = matrix(c(0.9, 0.1, 0.3, 0.7), nrow = 2, byrow = TRUE))
seqs <- simulate(x, nsim = 2000, seed = 1)
est <- fitmm(sequences = seqs, states = c("a", "b"), k = 1)
# Sequence simulated from the estimated model
head(simulate(est, nsim = 50, seed = 2)[[1]], 20)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.