Learn R Programming

smmR (version 1.0.3)

smmnonparametric: Non-parametric semi-Markov model specification

Description

Creates a non-parametric model specification for a semi-Markov model.

Usage

smmnonparametric(
  states,
  init,
  ptrans,
  type.sojourn = c("fij", "fi", "fj", "f"),
  distr,
  cens.beg = FALSE,
  cens.end = FALSE
)

Arguments

states

Vector of state space of length \(s\).

init

Vector of initial distribution of length \(s\).

ptrans

Matrix of transition probabilities of the embedded Markov chain \(J=(J_m)_{m}\) of dimension \((s, s)\).

type.sojourn

Type of sojourn time (for more explanations, see Details).

distr
  • Array of dimension \((s, s, kmax)\) if type.sojourn = "fij";

  • Matrix of dimension \((s, kmax)\) if type.sojourn = "fi" or "fj";

  • Vector of length \(kmax\) if the type.sojourn = "f".

\(kmax\) is the maximum length of the sojourn times.

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.

Value

Returns an object of class smm, smmnonparametric.

Details

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.

References

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.

See Also

simulate, fitsmm, smmparametric

Examples

Run this code
# NOT RUN {
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
# }

Run the code above in your browser using DataLab