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 |
t |
Optional, but recommended. Positive integer specifying
the instance |
u |
Optional. Can be either of the two options below:
|
v |
Optional. Can be either of the two options below:
|
l |
Optional. Positive integer specifying the sojourn time |
klim |
Optional. Positive integer. Used only when A larger value will result in a considerably larger
kernel, which has dimensions of |
Details
The drifting semi-Markov kernel is given as the probability that,
given at the instance t
the previous state
is u
, the next state state v
will be reached
with a sojourn time of l
:
q_{\frac{t}{n}}(u,v,l) = P(J_{t}=v,X_{t}=l|J_{t-1}=u),
where n
is the model size, defined as the length of the embedded
Markov chain (J_{t})_{t\in \{0,\dots,n\}}
minus the last state,
J_t
is the visited state at the instant t
and
X_{t} = S_{t}-S_{t-1}
is the sojourn time of the state J_{t-1}
.
Specifically, it is given as the sum of a linear combination:
q_{\frac{t}{n}}(u,v,l)=
\sum_{i = 0}^{d}A_{i}(t)\ q_{\frac{i}{d}}(u,v,l),
where A_i, i = 0, \dots, d
are d + 1
polynomials with degree
d
that satisfy certain conditions (see dsmmR) and
q_{\frac{i}{d}}(u,v,l), i = 0, \dots, d
are d + 1
semi-Markov kernels.
Three possible model specifications are described below.
We will use the exponentials (1), (2), (3)
to distinguish between
the drifting semi-Markov kernel q_\frac{t}{n}
and the
semi-Markov kernels q_\frac{i}{d}
used in
Model 1, Model 2 and Model 3.
Model 1
In this case, both p
and f
are "drifting" between d + 1
fixed points of the model, hence the "drifting" in drifting semi-Markov
models. Therefore, the semi-Markov kernels q_{\frac{i}{d}}^{\ (1)}
are
equal to:
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, \dots, d
we have d + 1
Markov Transition
matrices p_{\frac{i}{d}}(u,v)
, and d + 1
sojourn time
distributions f_{\frac{i}{d}}(u,v,l)
, where d
is the
polynomial degree.
Thus, the drifting semi-Markov kernel will be equal to:
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, p
is drifting and f
is not drifting.
Therefore, the semi-Markov kernels q_{\frac{i}{d}}^{\ (2)}
are
equal to:
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:
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, f
is drifting and p
is not drifting.
Therefore, the semi-Markov kernels q_{\frac{i}{d}}^{\ (3)}
are now described as:
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:
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 \times s \times k_{max} \times (n + 1)
, giving the
value of the drifting semi-Markov kernel q_{\frac{t}{n}}(u,v,l)
for
the corresponding (u,v,l,t)
. If any of u,v,l
or t
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`.