get_kernel {dsmmR}R Documentation

Obtain the Drifting semi-Markov kernel

Description

This is a generic method that computes and returns the drifting semi-Markov kernel.

Usage

get_kernel(obj, t, u, v, l, klim = 100)

Arguments

obj

An object that inherits from the S3 classes dsmm, dsmm_fit_parametric, or dsmm_fit_nonparametric, dsmm_nonparametric or dsmm_parametric.

t

Optional, but recommended. Positive integer specifying the instance tt of the visited states.

u

Optional. Can be either of the two options below:

  • Character specifying the previous state uu, e.g. u = "a".

  • Positive integer, specifying a state in the state space EE. For example, if E={a,c,g,t}E = \{a, c, g, t\} and u = 1, it corresponds to the state aa, if u = 2, it corresponds to the state cc.

v

Optional. Can be either of the two options below:

  • Character specifying the next state vv, e.g. v = "c".

  • Positive integer, specifying a state in the state space EE. For example, if E={a,c,g,t}E = \{a, c, g, t\} and v = 3, it corresponds to the state cc, if v = 4, it corresponds to the state tt.

l

Optional. Positive integer specifying the sojourn time ll that is spent in the previous state uu.

klim

Optional. Positive integer. Used only when obj inherits from the S3 classes dsmm_parametric or dsmm_fit_parametric. Specifies the time horizon used to approximate the d+1d + 1 sojourn time distributions if ff is drifting, or just 11 sojourn time distribution if ff is not drifting. Default value is 100.

A larger value will result in a considerably larger kernel, which has dimensions of s×s×klim×(n+1)s \times s \times klim \times (n + 1), which will increase the memory requirements and will slow down considerably the simulate.dsmm() method. However, this will lead to better estimations through fit_dsmm(). (dsmm_parametric, fit_dsmm, simulate.dsmm)

Details

The drifting semi-Markov kernel is given as the probability that, given at the instance tt the previous state is uu, the next state state vv will be reached with a sojourn time of ll:

qtn(u,v,l)=P(Jt=v,Xt=lJt1=u),q_{\frac{t}{n}}(u,v,l) = P(J_{t}=v,X_{t}=l|J_{t-1}=u),

where nn is the model size, defined as the length of the embedded Markov chain (Jt)t{0,,n}(J_{t})_{t\in \{0,\dots,n\}} minus the last state, JtJ_t is the visited state at the instant tt and Xt=StSt1X_{t} = S_{t}-S_{t-1} is the sojourn time of the state Jt1J_{t-1}. Specifically, it is given as the sum of a linear combination:

qtn(u,v,l)=i=0dAi(t) qid(u,v,l),q_{\frac{t}{n}}(u,v,l)= \sum_{i = 0}^{d}A_{i}(t)\ q_{\frac{i}{d}}(u,v,l),

where Ai,i=0,,dA_i, i = 0, \dots, d are d+1d + 1 polynomials with degree dd that satisfy certain conditions (see dsmmR) and qid(u,v,l),i=0,,dq_{\frac{i}{d}}(u,v,l), i = 0, \dots, d are d+1d + 1 semi-Markov kernels. Three possible model specifications are described below. We will use the exponentials (1),(2),(3)(1), (2), (3) to distinguish between the drifting semi-Markov kernel qtnq_\frac{t}{n} and the semi-Markov kernels qidq_\frac{i}{d} used in Model 1, Model 2 and Model 3.

Model 1

In this case, both pp and ff are "drifting" between d+1d + 1 fixed points of the model, hence the "drifting" in drifting semi-Markov models. Therefore, the semi-Markov kernels qid (1)q_{\frac{i}{d}}^{\ (1)} are equal to:

qid (1)(u,v,l)=pid(u,v)fid(u,v,l),q_{\frac{i}{d}}^{\ (1)}(u,v,l) = {p_{\frac{i}{d}}(u,v)}{f_{\frac{i}{d}}(u,v,l)},

where for i=0,,di = 0, \dots, d we have d+1d + 1 Markov Transition matrices pid(u,v)p_{\frac{i}{d}}(u,v), and d+1d + 1 sojourn time distributions fid(u,v,l)f_{\frac{i}{d}}(u,v,l), where dd is the polynomial degree.

Thus, the drifting semi-Markov kernel will be equal to:

qtn (1)(u,v,l)=i=0dAi(t) qid (1)(u,v,l)=i=0dAi(t) pid(u,v)fid(u,v,l)q_{\frac{t}{n}}^{\ (1)}(u,v,l) = \sum_{i = 0}^{d} A_i(t)\ q_{\frac{i}{d}}^{\ (1)}(u,v,l) = \sum_{i = 0}^{d} A_i(t)\ p_{\frac{i}{d}}(u,v)f_{\frac{i}{d}}(u,v,l)

Model 2

In this case, pp is drifting and ff is not drifting. Therefore, the semi-Markov kernels qid (2)q_{\frac{i}{d}}^{\ (2)} are equal to:

qid (2)(u,v,l)=pid(u,v)f(u,v,l).q_{\frac{i}{d}}^{\ (2)}(u,v,l)={p_{\frac{i}{d}}(u,v)}{f(u,v,l)}.

Thus, the drifting semi-Markov kernel will be equal to:

qtn (2)(u,v,l)=i=0dAi(t) qid (2)(u,v,l)=i=0dAi(t) pid(u,v)f(u,v,l)q_{\frac{t}{n}}^{\ (2)}(u,v,l) = \sum_{i = 0}^{d} A_i(t)\ q_{\frac{i}{d}}^{\ (2)}(u,v,l) = \sum_{i = 0}^{d} A_i(t)\ p_{\frac{i}{d}}(u,v)f(u,v,l)

Model 3

In this case, ff is drifting and pp is not drifting.

Therefore, the semi-Markov kernels qid (3)q_{\frac{i}{d}}^{\ (3)} are now described as:

qid (3)(u,v,l)=p(u,v)fid(u,v,l).q_{\frac{i}{d}}^{\ (3)}(u,v,l)={p(u,v)}{f_{\frac{i}{d}}(u,v,l)}.

Thus, the drifting semi-Markov kernel will be equal to:

qtn (3)(u,v,l)=i=0dAi(t) qid (3)(u,v,l)=i=0dAi(t) p(u,v)fid(u,v,l)q_{\frac{t}{n}}^{\ (3)}(u,v,l) = \sum_{i = 0}^{d} A_i(t)\ q_{\frac{i}{d}}^{\ (3)}(u,v,l) = \sum_{i = 0}^{d} A_i(t)\ p(u,v)f_{\frac{i}{d}}(u,v,l)

Value

An array with dimensions of s×s×kmax×(n+1)s \times s \times k_{max} \times (n + 1), giving the value of the drifting semi-Markov kernel qtn(u,v,l)q_{\frac{t}{n}}(u,v,l) for the corresponding (u,v,l,t)(u,v,l,t). If any of u,v,lu,v,l or tt are specified, we obtain the element of the array for their given value.

See Also

For the objects required to calculate this kernel: fit_dsmm, parametric_dsmm, nonparametric_dsmm.

For sequence simulation through this kernel: simulate.dsmm.

For the theoretical background of drifting semi-Markov models: dsmmR.

Examples

# Setup.
states <- c("Rouen", "Bucharest", "Samos", "Aigio", "Marseille")
emc <- create_sequence(states, probs = c(0.3, 0.1, 0.1, 0.3, 0.2))
obj_model_2 <- fit_dsmm(
    sequence = emc,
    states = states,
    degree = 3,
    f_is_drifting = FALSE,
    p_is_drifting = TRUE
)

# Get the kernel.
kernel_model_2 <- get_kernel(obj_model_2)
cat(paste0("If no further arguments are made, kernel has dimensions ",
           "for all u, v, l, t:\n",
           "(s, s, k_max, n + 1) = (",
           paste(dim(kernel_model_2), collapse = ", "), ")"))

# Specifying `t`.
kernel_model_2_t <- get_kernel(obj_model_2, t = 100)
# kernel_model_2_t[ , , , t = 100]
cat(paste0("If we specify t, the kernel has dimensions for ",
           "all the remaining u, v, l:\n(s, s, k_max) = (",
           paste(dim(kernel_model_2_t), collapse = ", "), ")"))

# Specifying `t` and `u`.
kernel_model_2_tu <- get_kernel(obj_model_2, t = 2, u = "Aigio")
# kernel_model_2_tu["Aigio", , , t = 2]
cat(paste0("If we specify t and u, the kernel has dimensions for ",
           "all the remaining v, l:\n(s, k_max) = (",
           paste(dim(kernel_model_2_tu), collapse = ", "), ")"))

# Specifying `t`, `u` and `v`.
kernel_model_2_tuv <- get_kernel(obj_model_2, t = 3,
                                 u = "Rouen", v = "Bucharest")
# kernel_model_2_tuv["Rouen", "Bucharest", , t = 3]
cat(paste0("If we specify t, u and v, the kernel has dimensions ",
           "for all l:\n(k_max) = (",
           paste(length(kernel_model_2_tuv), collapse = ", "), ")"))

# It is possible to ask for any valid combination of `u`, `v`, `l` and `t`.

[Package dsmmR version 1.0.5 Index]