simulate.dsmm {dsmmR} | R Documentation |
Simulate a sequence under a drifting semi-Markov kernel.
Description
Generic function that simulates a number of states nsim
under the rule of a drifting semi-Markov kernel, which is retrieved from the
object obj
, which in turn inherits from the S3 class dsmm
.
Usage
## S3 method for class 'dsmm'
simulate(object, nsim = NULL, seed = NULL, seq_length = NULL, klim = 100, ...)
Arguments
object |
An object of S3 class |
nsim |
Optional. An integer specifying the number of simulations to be made
from the drifting semi-Markov kernel. The maximum value of |
seed |
Optional. An integer specifying the initialization of the random number generator. |
seq_length |
Optional. A positive integer that will ensure the simulated
sequence will not have a total length greater than |
klim |
Optional. Positive integer. Passed down to |
... |
Optional. Attributes passed down from the |
Value
A character vector based on nsim
simulations, with a
maximum length of seq_length
.
See Also
About random number generation in R: RNG
.
Fitting a model through a sequence from this function: fit_dsmm.
For the theoretical background of drifting semi-Markov models: dsmmR.
Examples
# Setup.
seq <- create_sequence("DNA", len = 1000)
states <- sort(unique(seq))
d <- 1
obj_model_3 <- fit_dsmm(sequence = seq,
states = states,
degree = d,
f_is_drifting = TRUE,
p_is_drifting = FALSE)
# Using the method `simulate.dsmm()`.
simulated_seq <- simulate(obj_model_3, seed = 1)
short_sim <- simulate(obj = obj_model_3, nsim = 10, seed = 1)
cut_sim <- simulate(obj = obj_model_3, seq_length = 10, seed = 1)
str(simulated_seq)
str(short_sim)
str(cut_sim)