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 dsmm, dsmm_fit_nonparametric, dsmm_nonparametric, dsmm_fit_parametric or dsmm_parametric.

nsim

Optional. An integer specifying the number of simulations to be made from the drifting semi-Markov kernel. The maximum value of nsim is the model size which is specified in obj, which is also the default value. We define a special case for nsim = 0, where only the initial distribution is considered and only the simulation of its sojourn time will be made, without the next state.

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 seq_length (however, it is possible for the total length to be less than seq_length).

klim

Optional. Positive integer. Passed down to get_kernel for the parametric object, with class dsmm_parametric. Default value is 100.

...

Optional. Attributes passed down from the simulate method.

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)

[Package dsmmR version 1.0.2 Index]