In order to illustrate the package SMM we introduce a practical example taken from Barbu and Limnios (2008), where a semi-Markov modeling is appropriate. Let ℱ be a textile factory. To avoid river pollution, the factory waste is treated in the unit 𝒰 before being thrown in the river ℛ. In order for the factory not to be stopped if a failure occurs in the treatment unit 𝒰, the waste is stocked in a tank 𝒯. If 𝒰 is repaired before 𝒯 is full, then the factory starts to work again normally and we suppose that the tank is emptied instantaneously (before another failure of 𝒰). Otherwise, the whole factory has to stop and a certain time is necessary to restart it. The figure below describes the waste treatment system of the textile factory.
As the output of the factory is variable, the filling time of the tank is a random variable. Moreover, if we suppose that the filling time is deterministic, we can still make the assumption that we have a random time that has a Dirac distribution.
We propose a semi-Markov modelization for the evolution of the
described system. Let E = {"
1"
, "
2"
, "
3"
}
be the set of possible states of the system, where we set:
The possible transitions between states are given in the following figure:
The system is defined by:
The initial distribution α = (α1, α2, α3);
The transition matrix p of the embedded Markov chain (Jn)n ∈ ℕ $\boldsymbol{p} = \begin{pmatrix} 0 & 1 & 0 \\ a & 0 & b \\ 1 & 0 & 0 \end{pmatrix}$,
The conditional sojourn time distributions $\boldsymbol{f(k)} = \begin{pmatrix} 0 & f_{12}(k) & 0 \\ f_{21}(k) & 0 & f_{23}(k) \\ f_{31}(k) & 0 & 0 \end{pmatrix}, \ k \in \mathbb{N}$,
where,
f12 is the distribution of the failure time of the treatment unit 𝒰;
f21 is the distribution of the repairing time of 𝒰;
f23 is the distribution of the filling time of the tank 𝒯;
f31 is the distribution of time needed to restart the entire factory ℱ, after it has been shut down.
This is an irreducible discrete-time semi-Markov system, or, equivalently, a Markov renewal system. We chose the following sojourn time distributions:
f12 is the geometric distribution on ℕ* of parameter p, 0 < p < 1, i.e., f12(k) = p(1 − p)k − 1, k ∈ ℕ*.
f21 = Wq1, b1, f23 = Wq2, b2, f31 = Wq3, b3 are discrete-time first-type Weibull distributions (Nakagawa and Osaki (1975)), defined by: Wq, b(0) = 0, Wq, b(k) = q(k − 1)b − qkb, k ∈ ℕ*
The choice of discrete-time Weibull distribution is motivated by its use in reliability theory, due to its flexibility in modeling failure rates. In fact, our main purpose in this document is to compute and estimate the main reliability indicators of this system.
Let us continue the example of the textile factory presented above. We take the initial distribution α = (1, 0, 0), the transition matrix of the embedded Markov chain (Jn)n ∈ ℕ, $$ \boldsymbol{p} = \begin{pmatrix} 0 & 1 & 0 \\ 0.95 & 0 & 0.05 \\ 1 & 0 & 0 \end{pmatrix} $$ and the following conditional sojourn time distributions:
f12 is the geometric distribution on ℕ* with parameter p = 0.8;
f21 = Wq1, b1, f23 = Wq2, b2, f31 = Wq3, b3 are discrete-time Weibull distributions with parameters: q1 = 0.3, b1 = 0.5, q2 = 0.5, b2 = 0.7, q3 = 0.6, b3 = 0.9.
First, let us create a smmparametric object to represent the semi-Markov chain associated to the system:
states <- c("1", "2", "3") # State space
alpha <- c(1, 0, 0) # Initial distribution
p <- matrix(data = c(0, 1, 0,
0.95, 0, 0.05,
1, 0, 0), nrow = 3, byrow = TRUE) # Transition matrix
distr <- matrix(c(NA, "geom", NA,
"dweibull", NA, "dweibull",
"dweibull", NA, NA),
nrow = 3, ncol = 3, byrow = TRUE) # Distribution matrix
param1 <- matrix(c(NA, 0.8, NA,
0.3, NA, 0.5,
0.6, NA, NA),
nrow = 3, ncol = 3, byrow = TRUE)
param2 <- matrix(c(NA, NA, NA,
0.5, NA, 0.7,
0.9, NA, NA),
nrow = 3, ncol = 3, byrow = TRUE)
parameters <- array(c(param1, param2), c(3, 3, 2))
factory <- smmparametric(states = states, init = alpha, ptrans = p,
type.sojourn = "fij", distr = distr, param = parameters)
After that, we are able to simulate a sequence of sample sizes M = 10, 000:
Thanks to the SMM package, we can estimate any semi-Markov model with one or several discrete sequences. In our case, we are going to introduce a non-parametric estimation:
estimate <- fitsmm(sequences = seq, states = states, type.sojourn = "fij")
## Some transitions from state i to state j are not observed: (i = "3" to j = "2"), (i = "1" to j = "3")
## The probabilities of the initial state(s) "2", "3" are 0.
The estimate p̂ of the transition matrix p is:
print(x = estimate$ptrans, digits = 2)
## 1 2 3
## 1 0.00 1 0.000
## 2 0.95 0 0.048
## 3 1.00 0 0.000
We can also plot the estimated sojourn time densities. For example, let us plot the sojourn time distribution f̂23:
plot(x = estimate, i = "2", j = "3", type = "l", col = "blue")
lines(x = 1:estimate$kmax, y = ddweibull(x = 1:estimate$kmax, q = 0.5, beta = 0.7),
col = "red", pch = "x")
legend(x = "topright",
legend = c("True value", "Estimate"),
col = c("red", "blue"), lty = c(1, 1))
In the following sections, based on the model specification
factory
and the estimate of the latter
estimate
, we can compute true and estimated values of some
indicators such as reliability, availability, maintainability as well as
their asymptotic confidence intervals.
Consider a system System starting to function at time k = 0. The reliability of System at time k ∈ ℕ is the probability that the system has functioned without failure in the period [0, k]. Let’s take k = 300.
trueReliab <- reliability(x = factory, k = k, upstates = upstates)
estReliab <- reliability(x = estimate, k = k, upstates = upstates)
plot(x = 0:k, y = trueReliab[, 1], type = "l", cex = 2.5, ylim = c(0, 1),
col = "red", main = "Reliability", xlab = "k", ylab = "R(k)")
lines(x = estReliab[, 1], col = "blue")
lines(x = estReliab[, 3], lty = 4, col = "blue")
lines(x = estReliab[, 4], lty = 4, col = "blue")
legend(x = "topright",
legend = c("True value", "Estimated value", "95% confidence interval"),
col = c("red", "blue", "blue"), lty = c(1, 1, 4))
The pointwise (or instantaneous) availability of a system System at time k ∈ ℕ is the probability that the system is operational at time k (independently of the fact that the system has failed or not in [0, k)).
trueAvail <- availability(x = factory, k = k, upstates = upstates)
estAvail <- availability(x = estimate, k = k, upstates = upstates)
plot(x = 0:k, y = trueAvail[, 1], type = "l", cex = 2.5, ylim = c(0.95, 1),
col = "red", main = "Availability", xlab = "k", ylab = "A(k)")
lines(x = estAvail[, 1], col = "blue")
lines(x = estAvail[, 3], lty = 4, col = "blue")
lines(x = estAvail[, 4], lty = 4, col = "blue")
legend(x = "topright",
legend = c("True value", "Estimated value", "95% confidence interval"),
col = c("red", "blue", "blue"), lty = c(1, 1, 4))
Following the lines of Barbu and Limnios (2008), we consider two different definitions of the failure rate function. The first one is the usual failure rate, introduced by Barlow, Marshall and Prochan (Barlow, Marshall, and Proschan (1963)), that we will call BMP-failure rate. The second one is a failure rate adapted for the work in discrete time, proposed by Roy and Gupta (Roy and Gupta (1992)), that we will call RG-failure rate.
Consider a system System starting to work at time k = 0. The BMP-failure rate at time k ∈ ℕ, denoted by λ(k), is the conditional probability that the failure of the system occurs at time k, given that the system has worked until time k − 1.
trueBMP <- failureRate(x = factory, k = k, upstates = upstates)
estBMP <- failureRate(x = estimate, k = k, upstates = upstates)
plot(x = 0:k, y = trueBMP[, 1], type = "l", cex = 2.5, ylim = c(0, 0.025),
col = "red", main = "BMP-failure rate", xlab = "k", ylab = bquote(lambda(k)))
lines(x = estBMP[, 1], col = "blue")
lines(x = estBMP[, 3], lty = 4, col = "blue")
lines(x = estBMP[, 4], lty = 4, col = "blue")
legend(x = "topright",
legend = c("True value", "Estimated value", "95% confidence interval"),
col = c("red", "blue", "blue"), lty = c(1, 1, 4))
The RG-failure rate will be denoted by r(k), k ∈ ℕ.
trueRG <- failureRate(x = factory, k = k, upstates = upstates, failure.rate = "RG")
estRG <- failureRate(x = estimate, k = k, upstates = upstates, failure.rate = "RG")
plot(x = 0:k, y = trueRG[, 1], type = "l", cex = 2.5, ylim = c(0, 0.03),
col = "red", main = "RG-failure rate", xlab = "k", ylab = "r(k)")
lines(x = estRG[, 1], col = "blue")
lines(x = estRG[, 3], lty = 4, col = "blue")
lines(x = estRG[, 4], lty = 4, col = "blue")
legend(x = "topright",
legend = c("True value", "Estimated value", "95% confidence interval"),
col = c("red", "blue", "blue"), lty = c(1, 1, 4))