| simulate.smmfit | R Documentation |
Simulates sequences from a fitted semi-Markov model.
## S3 method for class 'smmfit'
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) (see Details: without censoring, the sequences can be longer). |
seed |
|
... |
further arguments passed to or from other methods. |
Notation (see smmR-package for the complete description of the models):
(Z_k)_{k \in \mathbb{N}} is the semi-Markov chain,
(J_n)_{n \in \mathbb{N}} its embedded Markov chain
(initial distribution init, transition matrix p = ptrans),
(X_n)_{n \in \mathbb{N}^*} the sojourn times,
q_{ij}(k) = p_{ij} f_{ij}(k) the semi-Markov
kernel and s = \textrm{card}(E).
If nsim is a single integer then one sequence is simulated; if nsim
is a vector of integers, then length(nsim) sequences are simulated,
nsim giving their respective lengths.
The length of the simulated sequences depends on the censoring of the
model (arguments cens.beg and cens.end of smmparametric and
smmnonparametric, or of fitsmm):
without censoring (cens.beg = FALSE and cens.end = FALSE, the
default), all the sojourn times are entirely simulated, the last one
included, so that a sequence can be longer than requested: it stops
at the end of the sojourn in progress at the requested length;
with censoring at the beginning and/or at the end, the sequences have exactly the requested lengths (the first and/or the last sojourn times are cut).
A list of vectors representing the sequences.
V. S. Barbu, N. Limnios. (2008). Semi-Markov Chains and Hidden Semi-Markov Models Toward Applications - Their Use in Reliability and DNA Analysis. New York: Lecture Notes in Statistics, vol. 191, Springer.
smmnonparametric, smmparametric, fitsmm
states <- c("a", "b", "c")
ptrans <- matrix(c(0, 0.6, 0.4,
0.5, 0, 0.5,
0.7, 0.3, 0), nrow = 3, byrow = TRUE)
param <- matrix(c(0.3, 2, 0.6,
NA, NA, 0.8), nrow = 3)
x <- smmparametric(states = states, init = c(1/3, 1/3, 1/3),
ptrans = ptrans, type.sojourn = "fi",
distr = c("geom", "pois", "dweibull"), param = param)
# Estimation on a simulated sequence
seqs <- simulate(x, nsim = 5000, seed = 1)
est <- fitsmm(sequences = seqs, states = states, type.sojourn = "fi",
distr = c("geom", "pois", "dweibull"))
# Sequence simulated from the estimated model
head(simulate(est, nsim = 100, seed = 2)[[1]], 20)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.