simulate.mm {smmR} | R Documentation |
Simulates k-th order Markov chains
Description
Simulates k-th order Markov chains.
Usage
## S3 method for class 'mm'
simulate(object, nsim = 1, seed = NULL, ...)
Arguments
object |
An object of class mm. |
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. |
Details
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.
Value
A list of vectors representing the sequences.
See Also
Examples
states <- c("a", "c", "g", "t")
s <- length(states)
k <- 2
init <- rep.int(1 / s ^ k, s ^ k)
p <- matrix(0.25, nrow = s ^ k, ncol = s)
# Specify a Markov model of order 1
markov <- mm(states = states, init = init, ptrans = p, k = k)
seqs <- simulate(object = markov, nsim = c(1000, 10000, 2000), seed = 150)
[Package smmR version 1.0.3 Index]