View source: R/smmnonparametric.R
| smmnonparametric | R Documentation | 
Creates a non-parametric model specification for a semi-Markov model.
smmnonparametric(
  states,
  init,
  ptrans,
  type.sojourn = c("fij", "fi", "fj", "f"),
  distr,
  cens.beg = FALSE,
  cens.end = FALSE
)
| states | Vector of state space of length  | 
| init | Vector of initial distribution of length  | 
| ptrans | Matrix of transition probabilities of the embedded Markov
chain  | 
| type.sojourn | Type of sojourn time (for more explanations, see Details). | 
| distr | 
 
 | 
| cens.beg | Optional. A logical value indicating whether or not sequences are censored at the beginning. | 
| cens.end | Optional. A logical value indicating whether or not sequences are censored at the end. | 
This function creates a semi-Markov model object in the non-parametric case, taking into account the type of sojourn time and the censoring described in references. The non-parametric specification concerns sojourn time distributions defined by the user.
The difference between the Markov model and the semi-Markov model concerns the modeling of the sojourn time. With a Markov chain, the sojourn time distribution is modeled by a Geometric distribution (in discrete time). With a semi-Markov chain, the sojourn time can be any arbitrary distribution.
We define :
 the semi-Markov kernel q_{ij}(k) = P( J_{m+1} = j, T_{m+1} - T_{m} = k | J_{m} = i );
 the transition matrix (p_{trans}(i,j))_{i,j} \in states of the embedded Markov chain J = (J_m)_m, p_{trans}(i,j) = P( J_{m+1} = j | J_m = i );
 the initial distribution \mu_i = P(J_1 = i) = P(Z_1 = i), i \in 1, 2, \dots, s;
 the conditional sojourn time distributions (f_{ij}(k))_{i,j} \in states,\ k \in N ,\ f_{ij}(k) = P(T_{m+1} - T_m = k | J_m = i, J_{m+1} = j ),
f is specified by the argument distr in the non-parametric case.
In this package we can choose different types of sojourn time. Four options are available for the sojourn times:
 depending on the present state and on the next state (f_{ij});
 depending only on the present state (f_{i});
 depending only on the next state (f_{j});
 depending neither on the current, nor on the next state (f).
Let define kmax the maximum length of the sojourn times.
If  type.sojourn = "fij", distr is an array of dimension (s, s, kmax).
If type.sojourn = "fi" or "fj", distr must be a matrix of dimension (s, kmax).
If type.sojourn = "f", distr must be a vector of length kmax.
If the sequence is censored at the beginning and/or at the end, cens.beg
must be equal to TRUE and/or cens.end must be equal to TRUE.
All the sequences must be censored in the same way.
Returns an object of class smm, smmnonparametric.
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.
simulate, fitsmm, smmparametric
states <- c("a", "c", "g", "t")
s <- length(states)
# Creation of the initial distribution
vect.init <- c(1 / 4, 1 / 4, 1 / 4, 1 / 4)
# Creation of the transition matrix
pij <- matrix(c(0, 0.2, 0.5, 0.3, 
                0.2, 0, 0.3, 0.5, 
                0.3, 0.5, 0, 0.2, 
                0.4, 0.2, 0.4, 0), 
              ncol = s, byrow = TRUE)
# Creation of a matrix corresponding to the 
# conditional sojourn time distributions
kmax <- 6
nparam.matrix <- matrix(c(0.2, 0.1, 0.3, 0.2, 
                          0.2, 0, 0.4, 0.2, 
                          0.1, 0, 0.2, 0.1, 
                          0.5, 0.3, 0.15, 0.05, 
                          0, 0, 0.3, 0.2, 
                          0.1, 0.2, 0.2, 0), 
                        nrow = s, ncol = kmax, byrow = TRUE)
semimarkov <- smmnonparametric(states = states, init = vect.init, ptrans = pij, 
                               type.sojourn = "fj", distr = nparam.matrix)
semimarkov
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.