get.P: Transition function of a semi-Markov chain

View source: R/smm.R

get.PR Documentation

Transition function of a semi-Markov chain

Description

Computes the transition function P of the semi-Markov chain (Z_k)_{k \in \mathbb{N}}, P_{ij}(k) = P(Z_k = j \mid Z_0 = i) (Barbu and Limnios, 2008, Definition 3.8, p. 51, and Equation (3.33), p. 59):

P = \psi * (I - H),

where \psi is the Markov renewal function (get.psi), H the diagonal matrix of the sojourn time cumulative distribution functions (get.H) and * the matrix convolution product (matrixConvolution).

Usage

get.P(x, k, states = x$states, var = FALSE, klim = 10000)

Arguments

x

An object of S3 class smm (smmparametric or smmnonparametric) or smmfit (see fitsmm).

k

A positive integer giving the time horizon.

states

Vector giving the subset A of states for which the transition function is computed (by default, all the states; see Details).

var

Logical. If TRUE the asymptotic variance is computed.

klim

Optional. The time horizon used to approximate the series in the computation of the mean recurrence times (cf. meanRecurrenceTimes) for the asymptotic variance.

Details

Notation (see smmR-package for the complete description of the models): (Z_k)_{k \in \mathbb{N}} is the semi-Markov chain, q its kernel, H and \psi are defined in get.H and get.psi, and s = \textrm{card}(E).

When states is a strict subset A of E, the function computes \psi_{AA} * (I - H)_{AA}, where \psi_{AA} is the Markov renewal function of the restriction q_{AA} of the kernel to A: its element (i, j) at time k is the probability that the chain stays in A up to time k and is in state j at time k, given Z_0 = i:

P(Z_k = j,\ Z_l \in A,\ l = 0, \dots, k \mid Z_0 = i), \quad i, j \in A.

With A = U, the set of up states, this is the function P_{11} of Barbu and Limnios (2008, Proposition 5.1 and its second proof, pp. 105-106), and the sum over j of these probabilities is the reliability of the system starting from i (see reliability).

With var = TRUE, the asymptotic variance of the estimator of P_{ij}(k) is computed (Barbu and Limnios, 2008, Equation (4.29), p. 91); this is relevant for a fitted model (class smmfit).

Value

If var = FALSE, a numeric array of dimension (a, a, k + 1), where a = \textrm{card}(A) (a = s by default), whose slice l + 1 is the matrix P(l), for l = 0, \dots, k; the rows and columns follow the order of x$states. If var = TRUE, a list with the following components:

x

The array described above;

sigma2

An array of the same dimension giving the asymptotic variances \sigma_{P}^{2}(i, j, k).

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

get.psi, get.H, matrixConvolution, availability, reliability, get.limitDistribution

Examples

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)

P <- get.P(x, k = 20)
P[, , 6]                 # P(5)
rowSums(P[, , 21])       # each P(k) is a stochastic matrix

# Probability to stay in {"a", "b"} up to time 5
Pab <- get.P(x, k = 5, states = c("a", "b"))
rowSums(Pab[, , 6])


smmR documentation built on Nov. 28, 2026, 1:06 a.m.