| Type: | Package |
| Title: | Simulation, Estimation and Reliability of Semi-Markov Models |
| Version: | 1.0.5 |
| Date: | 2025-10-20 |
| Description: | Performs parametric and non-parametric estimation and simulation for multi-state discrete-time semi-Markov processes. For the parametric estimation, several discrete distributions are considered for the sojourn times: Uniform, Geometric, Poisson, Discrete Weibull and Negative Binomial. The non-parametric estimation concerns the sojourn time distributions, where no assumptions are done on the shape of distributions. Moreover, the estimation can be done on the basis of one or several sample paths, with or without censoring at the beginning or/and at the end of the sample paths. Reliability indicators such as reliability, maintainability, availability, BMP-failure rate, RG-failure rate, mean time to failure and mean time to repair are available as well. The implemented methods are described in Barbu, V.S., Limnios, N. (2008) <doi:10.1007/978-0-387-73173-5>, Barbu, V.S., Limnios, N. (2008) <doi:10.1080/10485250701261913> and Trevezas, S., Limnios, N. (2011) <doi:10.1080/10485252.2011.555543>. Estimation and simulation of discrete-time k-th order Markov chains are also considered. |
| URL: | https://plmlab.math.cnrs.fr/lmrs/statistique/smmR,https://lmrs.pages.math.cnrs.fr/statistique/smmR |
| BugReports: | https://github.com/corentin-dev/smmR/issues |
| License: | GPL-3 |
| Imports: | DiscreteWeibull, Rcpp, seqinr |
| Suggests: | utils, knitr, rmarkdown, testthat (≥ 3.0.0), roxytest |
| LinkingTo: | Rcpp, RcppArmadillo |
| VignetteBuilder: | knitr |
| Encoding: | UTF-8 |
| RoxygenNote: | 7.3.3 |
| Config/testthat/edition: | 3 |
| NeedsCompilation: | yes |
| Packaged: | 2025-11-07 07:55:43 UTC; corentin |
| Author: | Vlad Stefan Barbu |
| Maintainer: | Nicolas Vergne <nicolas.vergne@univ-rouen.fr> |
| Repository: | CRAN |
| Date/Publication: | 2025-11-07 11:40:02 UTC |
smmR : Semi-Markov Models, Markov Models and Reliability
Description
This package performs parametric and non-parametric estimationand simulation for multi-state discrete-time semi-Markov processes. For theparametric estimation, several discrete distributions are considered for thesojourn times: Uniform, Geometric, Poisson, Discrete Weibull and NegativeBinomial. The non-parametric estimation concerns the sojourn timedistributions, where no assumptions are done on the shape of distributions.Moreover, the estimation can be done on the basis of one or several samplepaths, with or without censoring at the beginning or/and at the end of thesample paths. Estimation and simulation of discrete-time k-th order Markovchains are also considered.
Semi-Markov models are specified by using the functionssmmparametric()andsmmnonparametric() for parametric and non-parametric specificationsrespectively. These functions return objects of S3 class (smm,smmparametric) and (smm,smmnonparametric) respectively (smm classinherits from S3 classessmmparametric orsmmnonparametric). Thus,smmis like a wrapper class for semi-Markov model specifications.
Based on a model specification (an object of classsmm), it is possible to:
simulate one or several sequences with the method
simulate.smm();plot conditional sojourn time distributions (method
plot.smm());computelog-likelihood,AIC andBIC criteria (methods
logLik(),AIC(),BIC());computereliability,maintainability,availability,failure rates (methods
reliability(),maintainability(),availability(),failureRate()).
Estimations of parametric and non-parametric semi-Markov models can be doneby using the functionfitsmm(). This function returns anobject of S3 classsmmfit. The classsmmfit inherits from classes(smm,smmparametric) or (smm,smmnonparametric).
Based on a fitted/estimated semi-Markov model (an object of classsmmfit),it is possible to:
simulate one or several sequences with the method
simulate.smmfit();plot estimated conditional sojourn time distributions(method
plot.smmfit());computelog-likelihood,AIC andBIC criteria (methods
logLik(),AIC(),BIC());compute estimatedreliability,maintainability,availability,failure rates and theirconfidence intervals(methods
reliability(),maintainability(),availability(),failureRate()).
Author(s)
Maintainer: Nicolas Vergnenicolas.vergne@univ-rouen.fr
Authors:
References
V. S. Barbu, N. Limnios. (2008). Semi-Markov Chains and Hidden Semi-MarkovModels Toward Applications - Their Use in Reliability and DNA Analysis.New York: Lecture Notes in Statistics, vol. 191, Springer.
R.E. Barlow, A.W. Marshall, and F. Prochan. (1963). Properties of probabilitydistributions with monotone hazard rate. Ann. Math. Statist., 34, 375-389.
T. Nakagawa and S. Osaki. (1975). The discrete Weibull distribution.IEEE Trans. Reliabil., R-24, 300-301.
D. Roy and R. Gupta. (1992). Classification of discrete lives.Microelectron. Reliabil., 32 (10), 1459-1473.
I. Votsi & A. Brouste (2019) Confidence interval for the mean time tofailure in semi-Markov models: an application to wind energy production,Journal of Applied Statistics, 46:10, 1756-1773.
See Also
Useful links:
Report bugs athttps://github.com/corentin-dev/smmR/issues
BMP-Failure Rate Function
Description
Consider a systemS_{ystem} starting to work at timek = 0. The BMP-failure rate at timek \in N is the conditionalprobability that the failure of the system occurs at timek, giventhat the system has worked until timek - 1.
Usage
.failureRateBMP( x, k, upstates = x$states, level = 0.95, epsilon = 0.001, klim = 10000)Arguments
x | An object of S3 class |
k | A positive integer giving the period |
upstates | Vector giving the subset of operational states |
level | Confidence level of the asymptotic confidence interval. Helpfulfor an object |
epsilon | Value of the reliability above which the latter is supposedto be 0 because of computation errors (see Details). |
klim | Optional. The time horizon used to approximate the series in thecomputation of the mean sojourn times vector |
Details
Consider a system (or a component)S_{ystem} whose possiblestates during its evolution in time areE = \{1,\dots,s\}.Denote byU = \{1,\dots,s_1\} the subset of operational states ofthe system (the up states) and byD = \{s_1 + 1,\dots,s\} thesubset of failure states (the down states), with0 < s_1 < s(obviously,E = U \cup D andU \cap D = \emptyset,U \neq \emptyset,\ D \neq \emptyset). One can think of the statesofU as different operating modes or performance levels of thesystem, whereas the states ofD can be seen as failures of thesystems with different modes.
We are interested in investigating the failure rate of a discrete-timesemi-Markov systemS_{ystem}. Consequently, we suppose that theevolution in time of the system is governed by an E-state spacesemi-Markov chain(Z_k)_{k \in N}. The system starts to work atinstant0 and the state of the system is given at each instantk \in N byZ_k: the event\{Z_k = i\}, for a certaini \in U, means that the systemS_{ystem} is in operating modei at timek, whereas\{Z_k = j\}, for a certainj \in D, means that the system is not operational at timekdue to the mode of failurej or that the system is under therepairing modej.
The BMP-failure rate at timek \in N is the conditional probabilitythat the failure of the system occurs at timek, given that thesystem has worked until timek - 1.
LetT_D denote the first passage time in subsetD, calledthe lifetime of the system, i.e.,
T_D := \textrm{inf}\{ n \in N;\ Z_n \in D\}\ \textrm{and}\ \textrm{inf}\ \emptyset := \infty.
For a discrete-time semi-Markov system, the failure rate at timek \geq 1 has the expression:
\lambda(k) := P(T_{D} = k | T_{D} \geq k)
We can rewrite it as follows :
\lambda(k) = 1 - \frac{R(k)}{R(k - 1)},\ \textrm{if } R(k - 1) \neq 0;\ \lambda(k) = 0, \textrm{otherwise}
The failure rate at timek = 0 is defined by\lambda(0) := 1 - R(0),withR being the reliability function (seereliability function).
The calculation of the reliabilityR involves the computation ofmany convolutions. It implies that the computation error, may be higher(in value) than the "true" reliability itself for reliability close to 0.In order to avoid inconsistent values of the BMP-failure rate, we use thefollowing formula:
\lambda(k) = 1 - \frac{R(k)}{R(k - 1)},\ \textrm{if } R(k - 1) \geq \epsilon;\ \lambda(k) = 0, \textrm{otherwise}
with\epsilon, the threshold, the parameterepsilon in thefunctionfailureRateBMP.
Value
A matrix withk + 1 rows, and with columns giving values ofthe BMP-failure rate, variances, lower and upper asymptotic confidencelimits (ifx is an object of classsmmfit).
Availability Function
Description
The pointwise (or instantaneous) availability of a systemS_{ystem} at timek \in N is the probability that the systemis operational at timek (independently of the fact that the systemhas failed or not in[0, k)).
Usage
availability(x, k, upstates = x$states, level = 0.95, klim = 10000)Arguments
x | An object of S3 class |
k | A positive integer giving the time at which the availabilityshould be computed. |
upstates | Vector giving the subset of operational states |
level | Confidence level of the asymptotic confidence interval. Helpfulfor an object |
klim | Optional. The time horizon used to approximate the series in thecomputation of the mean sojourn times vector |
Details
Consider a system (or a component)S_{ystem} whose possiblestates during its evolution in time areE = \{1,\dots,s\}.Denote byU = \{1,\dots,s_1\} the subset of operational states ofthe system (the up states) and byD = \{s_1 + 1,\dots,s\} thesubset of failure states (the down states), with0 < s_1 < s(obviously,E = U \cup D andU \cap D = \emptyset,U \neq \emptyset,\ D \neq \emptyset). One can think of the statesofU as different operating modes or performance levels of thesystem, whereas the states ofD can be seen as failures of thesystems with different modes.
We are interested in investigating the availability of a discrete-timesemi-Markov systemS_{ystem}. Consequently, we suppose that theevolution in time of the system is governed by an E-state spacesemi-Markov chain(Z_k)_{k \in N}. The state of the system is givenat each instantk \in N byZ_k: the event\{Z_k = i\},for a certaini \in U, means that the systemS_{ystem} is inoperating modei at timek, whereas\{Z_k = j\}, for acertainj \in D, means that the system is not operational at timek due to the mode of failurej or that the system is under therepairing modej.
The pointwise (or instantaneous) availability of a systemS_{ystem}at timek \in N is the probability that the system is operationalat timek (independently of the fact that the system has failed ornot in[0, k)).
Thus, the pointwise availability of a semi-Markov system at timek \in N is
A(k) = P(Z_k \in U) = \sum_{i \in E} \alpha_i A_i(k),
where we have denoted byA_i(k) the conditional availability of thesystem at timek \in N, given that it starts in statei \in E,
A_i(k) = P(Z_k \in U | Z_0 = i).
Value
A matrix withk + 1 rows, and with columns giving values ofthe availability, variances, lower and upper asymptotic confidence limits(ifx is an object of classsmmfit).
References
V. S. Barbu, N. Limnios. (2008). Semi-Markov Chains and Hidden Semi-MarkovModels Toward Applications - Their Use in Reliability and DNA Analysis.New York: Lecture Notes in Statistics, vol. 191, Springer.
Discrete-time convolution product off andg(See definition 2.2 p. 20)
Description
Discrete-time convolution product off andg(See definition 2.2 p. 20)
Usage
convolution(f, g)Arguments
f | A vector giving the values of the function |
g | A vector giving the values of the function |
Value
A vector giving the values of the discrete-time convolution off andg for eachk \in N.
Failure Rate Function
Description
Function to compute the BMP-failure rate or the RG-failure rate.
Consider a systemS_{ystem} starting to work at timek = 0. The BMP-failure rate at timek \in N is the conditionalprobability that the failure of the system occurs at timek, giventhat the system has worked until timek - 1.
The RG-failure rate is a discrete-time adapted failure rate, proposed byD. Roy and R. Gupta. Classification of discrete lives. MicroelectronicsReliability, 32(10):1459–1473, 1992. We call it the RG-failure rate anddenote it byr(k),\ k \in N.
Usage
failureRate( x, k, upstates = x$states, failure.rate = c("BMP", "RG"), level = 0.95, epsilon = 0.001, klim = 10000)Arguments
x | An object of S3 class |
k | A positive integer giving the period |
upstates | Vector giving the subset of operational states |
failure.rate | Type of failure rate to compute. If |
level | Confidence level of the asymptotic confidence interval. Helpfulfor an object |
epsilon | Value of the reliability above which the latter is supposedto be 0 because of computation errors (see Details). |
klim | Optional. The time horizon used to approximate the series in thecomputation of the mean sojourn times vector |
Details
Consider a system (or a component)S_{ystem} whose possiblestates during its evolution in time areE = \{1,\dots,s\}.Denote byU = \{1,\dots,s_1\} the subset of operational states ofthe system (the up states) and byD = \{s_1 + 1,\dots,s\} thesubset of failure states (the down states), with0 < s_1 < s(obviously,E = U \cup D andU \cap D = \emptyset,U \neq \emptyset,\ D \neq \emptyset). One can think of the statesofU as different operating modes or performance levels of thesystem, whereas the states ofD can be seen as failures of thesystems with different modes.
We are interested in investigating the failure rate of a discrete-timesemi-Markov systemS_{ystem}. Consequently, we suppose that theevolution in time of the system is governed by an E-state spacesemi-Markov chain(Z_k)_{k \in N}. The system starts to work atinstant0 and the state of the system is given at each instantk \in N byZ_k: the event\{Z_k = i\}, for a certaini \in U, means that the systemS_{ystem} is in operating modei at timek, whereas\{Z_k = j\}, for a certainj \in D, means that the system is not operational at timekdue to the mode of failurej or that the system is under therepairing modej.
The BMP-failure rate at timek \in N is the conditional probabilitythat the failure of the system occurs at timek, given that thesystem has worked until timek - 1.
LetT_D denote the first passage time in subsetD, calledthe lifetime of the system, i.e.,
T_D := \textrm{inf}\{ n \in N;\ Z_n \in D\}\ \textrm{and}\ \textrm{inf}\ \emptyset := \infty.
For a discrete-time semi-Markov system, the failure rate at timek \geq 1 has the expression:
\lambda(k) := P(T_{D} = k | T_{D} \geq k)
We can rewrite it as follows :
\lambda(k) = 1 - \frac{R(k)}{R(k - 1)},\ \textrm{if } R(k - 1) \neq 0;\ \lambda(k) = 0, \textrm{otherwise}
The failure rate at timek = 0 is defined by\lambda(0) := 1 - R(0),withR being the reliability function (seereliability function).
The calculation of the reliabilityR involves the computation ofmany convolutions. It implies that the computation error, may be higher(in value) than the "true" reliability itself for reliability close to 0.In order to avoid inconsistent values of the BMP-failure rate, we use thefollowing formula:
\lambda(k) = 1 - \frac{R(k)}{R(k - 1)},\ \textrm{if } R(k - 1) \geq \epsilon;\ \lambda(k) = 0, \textrm{otherwise}
with\epsilon, the threshold, the parameterepsilon in thefunctionfailureRate.
Expressing the RG-failure rater(k) in terms of the reliabilityR we obtain that the RG-failure rate function for a discrete-timesystem is given by:
r(k) = - \ln \frac{R(k)}{R(k - 1)},\ \textrm{if } k \geq 1;\ r(k) = - \ln R(0),\ \textrm{if } k = 0
forR(k) \neq 0. IfR(k) = 0, we setr(k) := 0.
Note that the RG-failure rate is related to the BMP-failure rate by:
r(k) = - \ln (1 - \lambda(k)),\ k \in N
Value
A matrix withk + 1 rows, and with columns giving values ofthe BMP-failure rate or RG-failure rate, variances, lower and upperasymptotic confidence limits (ifx is an object of classsmmfit).
References
V. S. Barbu, N. Limnios. (2008). Semi-Markov Chains and Hidden Semi-MarkovModels Toward Applications - Their Use in Reliability and DNA Analysis.New York: Lecture Notes in Statistics, vol. 191, Springer.
R.E. Barlow, A.W. Marshall, and F. Prochan. (1963). Properties of probabilitydistributions with monotone hazard rate. Ann. Math. Statist., 34, 375-389.
D. Roy and R. Gupta. (1992). Classification of discrete lives.Microelectron. Reliabil., 32 (10), 1459-1473.
Maximum Likelihood Estimation (MLE) of a k-th order Markov chain
Description
Maximum Likelihood Estimation of the transition matrix andinitial distribution of a k-th order Markov chain starting from one orseveral sequences.
Usage
fitmm(sequences, states, k = 1, init.estim = "mle")Arguments
sequences | A list of vectors representing the sequences. |
states | Vector of state space (of length s). |
k | Order of the Markov chain. |
init.estim | Optional.
|
Details
LetX_1, X_2, ..., X_n be a trajectory of lengthn ofthe Markov chainX = (X_m)_{m \in N} of orderk = 1 withtransition matrixp_{trans}(i,j) = P(X_{m+1} = j | X_m = i). Themaximum likelihood estimation of the transition matrix is\widehat{p_{trans}}(i,j) = \frac{N_{ij}}{N_{i.}}, whereN_{ij}is the number of transitions from statei to statej andN_{i.} is the number of transition from statei to any state.Fork > 1 we have similar expressions.
The initial distribution of a k-th order Markov chain is defined as\mu_i = P(X_1 = i). Five methods are proposed for the estimationof the latter :
- Maximum Likelihood Estimator:
The Maximum Likelihood Estimatorfor the initial distribution. The formula is:
\widehat{\mu_i} = \frac{Nstart_i}{L}, whereNstart_iisthe number of occurences of the wordi(of lengthk) atthe beginning of each sequence andLis the number of sequences.This estimator is reliable when the number of sequencesLis high.- Stationary distribution:
The stationary distribution is used asa surrogate of the initial distribution. If the order of the Markovchain is more than one, the transition matrix is converted into asquare block matrix in order to estimate the stationary distribution.This method may take time if the order of the Markov chain is high(more than three (3)).
- Frequencies of each word:
The initial distribution is estimatedby taking the frequencies of the words of length
kfor all sequences.The formula is\widehat{\mu_i} = \frac{N_i}{N}, whereN_iis the number of occurences of the wordi(of lengthk) inthe sequences andNis the sum of the lengths of the sequences.- Product of the frequencies of each state:
The initial distributionis estimated by using the product of the frequencies of each state(for all the sequences) in the word of length
k.- Uniform distribution:
The initial probability of each state isequal to
1 / s, withs, the number of states.
Value
An object of class S3mmfit (inheriting from the S3 classmm).The S3 classmmfit contains:
All the attributes of the S3 classmm;
An attribute
Mwhich is an integer giving the total length ofthe set of sequencessequences(sum of all the lengths of the listsequences);An attribute
logLikwhich is a numeric value giving the valueof the log-likelihood of the specified Markov model based on thesequences;An attribute
sequenceswhich is equal to the parametersequencesof the functionfitmm(i.e. a list of sequences used toestimate the Markov model).
See Also
Examples
states <- c("a", "c", "g", "t")s <- length(states)k <- 2init <- rep.int(1 / s ^ k, s ^ k)p <- matrix(0.25, nrow = s ^ k, ncol = s)# Specify a Markov model of order 2markov <- mm(states = states, init = init, ptrans = p, k = k)seqs <- simulate(object = markov, nsim = c(1000, 10000, 2000), seed = 150)est <- fitmm(sequences = seqs, states = states, k = 2)Maximum Likelihood Estimation (MLE) of a semi-Markov chain
Description
Maximum Likelihood Estimation of a semi-Markov chain startingfrom one or several sequences. This estimation can be parametric ornon-parametric, non-censored, censored at the beginning and/or at the endof the sequence, with one or several trajectories. Several parametricdistributions are considered (Uniform, Geometric, Poisson, DiscreteWeibull and Negative Binomial).
Usage
fitsmm( sequences, states, type.sojourn = c("fij", "fi", "fj", "f"), distr = "nonparametric", init.estim = "mle", cens.beg = FALSE, cens.end = FALSE)Arguments
sequences | A list of vectors representing the sequences. |
states | Vector of state space (of length s). |
type.sojourn | Type of sojourn time (for more explanations, see Details). |
distr | By default If the parametric estimation case is desired,
The distributions to be used in |
init.estim | Optional.
|
cens.beg | Optional. A logical value indicating whether or notsequences are censored at the beginning. |
cens.end | Optional. A logical value indicating whether or notsequences are censored at the end. |
Details
This function estimates a semi-Markov model in parametric ornon-parametric case, taking into account the type of sojourn time and thecensoring described in references. The non-parametric estimation concernssojourn time distributions defined by the user. For the parametricestimation, several discrete distributions are considered (see below).
The difference between the Markov model and the semi-Markov model concernsthe modeling of the sojourn time. With a Markov chain, the sojourn timedistribution is modeled by a Geometric distribution (in discrete time).With a semi-Markov chain, the sojourn time can be any arbitrary distribution.In this package, the available distribution for a semi-Markov model are :
Uniform:
f(x) = \frac{1}{n}for1 \le x \le n.nis the parameter;Geometric:
f(x) = \theta (1-\theta)^{x - 1}forx = 1, 2,\ldots,n,0 < \theta < 1,\thetais the probability of success.\thetais the parameter;Poisson:
f(x) = \frac{\lambda^x exp(-\lambda)}{x!}forx = 0, 1, 2,\ldots,n, with\lambda > 0.\lambdais the parameter;Discrete Weibull of type 1:
f(x)=q^{(x-1)^{\beta}}-q^{x^{\beta}},x = 1, 2,\ldots,n,with0 < q < 1, the first parameter and\beta > 0the second parameter.(q, \beta)are the parameters;Negative binomial:
f(x)=\frac{\Gamma(x+\alpha)}{\Gamma(\alpha) x!} p^{\alpha} (1 - p)^x,forx = 0, 1, 2,\ldots,n,\Gammais the Gamma function,\alphais the parameter of overdispersion andpis theprobability of success,0 < p < 1.(\alpha, p)are the parameters;Non-parametric.
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 statesof theembedded Markov chainJ = (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 ),fis specified by the argumentparamin the parametric caseand bydistrin the non-parametric case.
The maximum likelihood estimation of the transition matrix of the embeddedMarkov chain is\widehat{p_{trans}}(i,j) = \frac{N_{ij}}{N_{i.}}.
Five methods are proposed for the estimation of the initial distribution :
- Maximum Likelihood Estimator:
The Maximum Likelihood Estimatorfor the initial distribution. The formula is:
\widehat{\mu_i} = \frac{Nstart_i}{L}, whereNstart_iisthe number of occurences of the wordi(of lengthk) atthe beginning of each sequence andLis the number of sequences.This estimator is reliable when the number of sequencesLis high.- Limit (stationary) distribution:
The limit (stationary)distribution of the semi-Markov chain is used as a surrogate of theinitial distribution.
- Frequencies of each state:
The initial distribution is replacedby taking the frequencies of each state in the sequences.
- Uniform distribution:
The initial probability of each state isequal to
1 / s, withs, the number of states.
Note thatq_{ij}(k) = p_{trans}(i,j) \ f_{ij}(k) in the general case(depending on the present state and on the next state). For particular cases,we replacef_{ij}(k) byf_{i.}(k) (depending on the presentstatei),f_{.j}(k) (depending on the next statej) andf_{..}(k) (depending neither on the present state nor on the nextstate).
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 (
fij);depending only on the present state (
fi);depending only on the next state (
fj);depending neither on the current, nor on the next state (
f).
Iftype.sojourn = "fij",distr is a matrix of dimension(s, s)(e.g., if the 1st element of the 2nd column is"pois", that is to say wego from the first state to the second state following a Poisson distribution).Iftype.sojourn = "fi" or"fj",distr must be a vector (e.g., if thefirst element of vector is"geom", that is to say we go from (or to) thefirst state to (or from) any state according to a Geometric distribution).Iftype.sojourn = "f",distr must be one of"unif","geom","pois","dweibull","nbinom" (e.g., ifdistr is equal to"nbinom", that isto say that the sojourn time when going from one state to another statefollows a Negative Binomial distribution).For the non-parametric case,distr is equal to"nonparametric" whatevertype of sojourn time given.
If the sequence is censored at the beginning and/or at the end,cens.begmust be equal toTRUE and/orcens.end must be equal toTRUE.All the sequences must be censored in the same way.
Value
Returns an object of S3 classsmmfit (inheriting from the S3classsmm andsmmnonparametric class ifdistr = "nonparametric"orsmmparametric otherwise). The S3 classsmmfit contains:
All the attributes of the S3 classsmmnonparametric orsmmparametric depending on the type of estimation;
An attribute
Mwhich is an integer giving the total length ofthe set of sequencessequences(sum of all the lengths of the listsequences);An attribute
logLikwhich is a numeric value giving the valueof the log-likelihood of the specified semi-Markov model based on thesequences;An attribute
sequenceswhich is equal to the parametersequencesof the functionfitsmm(i.e. a list of sequences used toestimate the Markov model).
References
V. S. Barbu, N. Limnios. (2008). Semi-Markov Chains and Hidden Semi-MarkovModels Toward Applications - Their Use in Reliability and DNA Analysis.New York: Lecture Notes in Statistics, vol. 191, Springer.
See Also
smmnonparametric,smmparametric,simulate.smm,simulate.smmfit,plot.smm,plot.smmfit
Examples
states <- c("a", "c", "g", "t")s <- length(states)# Creation of the initial distributionvect.init <- c(1 / 4, 1 / 4, 1 / 4, 1 / 4)# Creation of the transition matrixpij <- 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 the distribution matrixdistr.matrix <- matrix(c(NA, "pois", "geom", "nbinom", "geom", NA, "pois", "dweibull", "pois", "pois", NA, "geom", "pois", "geom", "geom", NA), nrow = s, ncol = s, byrow = TRUE)# Creation of an array containing the parametersparam1.matrix <- matrix(c(NA, 2, 0.4, 4, 0.7, NA, 5, 0.6, 2, 3, NA, 0.6, 4, 0.3, 0.4, NA), nrow = s, ncol = s, byrow = TRUE)param2.matrix <- matrix(c(NA, NA, NA, 0.6, NA, NA, NA, 0.8, NA, NA, NA, NA, NA, NA, NA, NA), nrow = s, ncol = s, byrow = TRUE)param.array <- array(c(param1.matrix, param2.matrix), c(s, s, 2))# Specify the semi-Markov modelsemimarkov <- smmparametric(states = states, init = vect.init, ptrans = pij, type.sojourn = "fij", distr = distr.matrix, param = param.array)seqs <- simulate(object = semimarkov, nsim = c(1000, 10000, 2000), seed = 100)# Estimation of simulated sequencesest <- fitsmm(sequences = seqs, states = states, type.sojourn = "fij", distr = distr.matrix)Function to compute the value of the sojourn time cumulative distributionH
Description
Function to compute the value ofH (See equation (3.4) p.46).
Usage
get.H(q)Arguments
q | An array giving the values of the kernel for a giving time horizon |
Value
An array giving the value ofH(k) at each time between 0andk.
Method to get the number of parameters of a Markov or semi-Markov chain
Description
Method to get the number of parameters of a Markov orsuch as AIC and BIC.
Usage
get.Kpar(x)Arguments
x | An object for which the number of parameters can be returned (Anobject of class |
Value
A positive integer giving the number of parameters.
Function giving the value of the counting process Niuj used in theestimation of the kernel and the transition matrix of censored andnon-parametric semi-markov chains (cf. article Exact MLE and asymptoticproperties for nonparametric semi-Markov models)
Description
Function giving the value of the counting process Niuj used in theestimation of the kernel and the transition matrix of censored andnon-parametric semi-markov chains (cf. article Exact MLE and asymptoticproperties for nonparametric semi-Markov models)
Usage
get.Niuj(sequences)Arguments
sequences | A list of sequences of states. |
Value
An array giving the values of the counting processN_{iuj}.
Method to compute the value ofP
Description
Method to compute the value ofP(See equation (3.33) p.59).
Usage
get.P(x, k, states = x$states, var = FALSE, klim = 10000)Arguments
x | An object of S3 class |
k | A positive integer giving the time horizon. |
states | Vector giving the states for which the mean sojourn timeshould be computed. |
var | Logical. If |
klim | Optional. The time horizon used to approximate the series in thecomputation of the mean sojourn times vector |
Value
An array giving the value ofP_{i,j}(k) at each time between 0andk ifvar = FALSE. Ifvar = TRUE, a list containing thefollowing components:
- x:
an array giving the value of
P_{ij}(k)at each timebetween 0 andk;- sigma2:
an array giving the asymptotic variance of the estimator
\sigma_{P}^{2}(i, j, k).
Method to compute the value ofP_{Y}
Description
Method to compute the value ofP_{Y}(See Proposition 5.1 p.105-106).
Usage
get.Py(x, k, upstates = x$states)Arguments
x | An object of S3 class |
k | A positive integer giving the time horizon. |
upstates | Vector giving the subset of operational states |
Value
An array giving the value ofP_{Y}(k) at each time between 0andk.
Method to get the conditional sojourn time distribution f
Description
Computes the conditional sojourn time distributionf(k),f_{i}(k),f_{j}(k) orf_{ij}(k).
Usage
get.f(x, k)Arguments
x | An object of S3 class |
k | A strictly positive integer giving the time horizon (k must bedifferent from 0 since we assume that there are not instantaneoustransitions). |
Value
A vector, matrix or array giving the value off at each timebetween 1 andk.
Method to get the limit (stationary) distribution
Description
Method to get the limit (stationary) distribution of asemi-Markov chain.
Usage
get.limitDistribution(x, klim = 10000)Arguments
x | An object of S3 class |
klim | Optional. The time horizon used to approximate the series in thecomputation of the mean sojourn times vector |
Value
A vector of length\textrm{card}(E) giving the values of thelimit distribution.
Function to compute the value of the matrix-valued function\psi
Description
Function to compute the value of\psi, the matrix-valuedfunction (See equation (3.16) p.53).
Usage
get.psi(q)Arguments
q | An array giving the values of the kernel for a giving time horizon |
Value
An array giving the value of\psi(k) at each time between 0andk.
Method to get the semi-Markov kernelq_{Y}
Description
Computes the semi-Markov kernelq_{Y}(k)(See proposition 5.1 p.106).
Usage
get.qy(x, k, upstates = x$states)Arguments
x | An object of S3 class |
k | A positive integer giving the time horizon. |
upstates | Vector giving the subset of operational states |
Value
An array giving the value ofq_{Y}(k) at each time between 0andk.
Method to get the stationary distribution
Description
Method to get the stationary distribution of a Markov chain.If the order of the Markov chain is higher than one, a block matrix iscomputed to get the stationary distribution.
Usage
get.stationaryDistribution(x)Arguments
x | An object of S3 class |
Value
A vector of length\textrm{card}(E) giving the values of thestationary distribution.
Method to get the semi-Markov kernelq
Description
Computes the semi-Markov kernelq_{ij}(k).
Usage
getKernel(x, k, var = FALSE, klim = 10000)Arguments
x | An object of S3 class |
k | A positive integer giving the time horizon. |
var | Logical. If |
klim | Optional. The time horizon used to approximate the series in thecomputation of the mean sojourn times vector |
Value
An array giving the value ofq_{ij}(k) at each time between 0andk ifvar = FALSE. Ifvar = TRUE, a list containing thefollowing components:
- x:
an array giving the value of
q_{ij}(k)at each timebetween 0 andk;- sigma2:
an array giving the asymptotic variance of the estimator
\sigma_{q}^{2}(i, j, k).
Function to compute processes based on a list of sequences
Description
Function to compute processes based on a list of sequences
Usage
getProcesses(sequences)Arguments
sequences | A list of sequences of states. |
Value
A list giving:
- s:
Cardinal of the states space;
- states:
Vector of state space of length
s;- M:
The total length (sum of the length of each sequence);
- L:
The number of sequences;
- kmax :
Maximum length of the sojourn times;
- Ym:
List of semi-Markov chains;
- Jm:
List of successively visited states for each sequence;
- Tm:
List of successive time points when state changes for each sequence;
- Lm:
List of sojourn time for each sequence;
- Um:
List of backward recurrence time for each sequence;
- counting:
List giving the counting processes such as
N_{ij}(k),N_{i}(k),N_{j}(k)...
Function to check if an object is of classmm
Description
is.mm returnsTRUE ifx is an object ofclassmm.
Usage
is.mm(x)Arguments
x | An arbitrary R object. |
Value
is.mm returnsTRUE orFALSE depending on whetherx is anobject of classmm or not.
Function to check if an object is of classmmfit
Description
is.mmfit returnsTRUE ifx is an object ofclassmmfit.
Usage
is.mmfit(x)Arguments
x | An arbitrary R object. |
Value
is.mmfit returnsTRUE orFALSE depending on whetherx is anobject of classmmfit or not.
Function to check if an object is of classsmm
Description
is.smm returnsTRUE ifx is an object of classsmm.
Usage
is.smm(x)Arguments
x | An arbitrary R object. |
Value
is.smm returnsTRUE orFALSE depending on whetherx is anobject of classsmm or not.
Function to check if an object is of classsmmfit
Description
is.smmfit returnsTRUE ifx is an object of classsmmfit.
Usage
is.smmfit(x)Arguments
x | An arbitrary R object. |
Value
is.smmfit returnsTRUE orFALSE depending on whetherx is anobject of classsmmfit or not.
Function to check if an object is of classsmmnonparametric
Description
is.smmnonparametric returnsTRUE ifx is an object ofclasssmmnonparametric.
Usage
is.smmnonparametric(x)Arguments
x | An arbitrary R object. |
Value
is.smmnonparametric returnsTRUE orFALSE depending on whetherx is an object of classsmmnonparametric or not.
Function to check if an object is of classsmmparametric
Description
is.smmparametric returnsTRUE ifx is an object ofclasssmmparametric.
Usage
is.smmparametric(x)Arguments
x | An arbitrary R object. |
Value
is.smmparametric returnsTRUE orFALSE depending on whetherx is an object of classsmmparametric or not.
Maintainability Function
Description
For a reparable systemS_{ystem} for which the failureoccurs at timek = 0, its maintainability at timek \in N isthe probability that the system is repaired up to timek, given thatit has failed at timek = 0.
Usage
maintainability(x, k, upstates = x$states, level = 0.95, klim = 10000)Arguments
x | An object of S3 class |
k | A positive integer giving the period |
upstates | Vector giving the subset of operational states |
level | Confidence level of the asymptotic confidence interval. Helpfulfor an object |
klim | Optional. The time horizon used to approximate the series in thecomputation of the mean sojourn times vector |
Details
Consider a system (or a component)S_{ystem} whose possiblestates during its evolution in time areE = \{1,\dots,s\}.Denote byU = \{1,\dots,s_1\} the subset of operational states ofthe system (the up states) and byD = \{s_1 + 1,\dots, s\} thesubset of failure states (the down states), with0 < s_1 < s(obviously,E = U \cup D andU \cap D = \emptyset,U \neq \emptyset,\ D \neq \emptyset). One can think of the statesofU as different operating modes or performance levels of thesystem, whereas the states ofD can be seen as failures of thesystems with different modes.
We are interested in investigating the maintainability of a discrete-timesemi-Markov systemS_{ystem}. Consequently, we suppose that theevolution in time of the system is governed by an E-state spacesemi-Markov chain(Z_k)_{k \in N}. The system starts to fail atinstant0 and the state of the system is given at each instantk \in N byZ_k: the event\{Z_k = i\}, for a certaini \in U, means that the systemS_{ystem} is in operating modei at timek, whereas\{Z_k = j\}, for a certainj \in D, means that the system is not operational at timekdue to the mode of failurej or that the system is under therepairing modej.
Thus, we take(\alpha_{i} := P(Z_{0} = i))_{i \in U} = 0 and wedenote byT_U the first hitting time of subsetU, called theduration of repair or repair time, that is,
T_U := \textrm{inf}\{ n \in N;\ Z_n \in U\}\ \textrm{and}\ \textrm{inf}\ \emptyset := \infty.
The maintainability at timek \in N of a discrete-time semi-Markovsystem is
M(k) = P(T_U \leq k) = 1 - P(T_{U} > k) = 1 - P(Z_{n} \in D,\ n = 0,\dots,k).
Value
A matrix withk + 1 rows, and with columns giving values ofthe maintainability, variances, lower and upper asymptotic confidence limits(ifx is an object of classsmmfit).
References
V. S. Barbu, N. Limnios. (2008). Semi-Markov Chains and Hidden Semi-MarkovModels Toward Applications - Their Use in Reliability and DNA Analysis.New York: Lecture Notes in Statistics, vol. 191, Springer.
Discrete-time matrix convolution product(See definition 3.5 p. 48)
Description
Discrete-time matrix convolution product(See definition 3.5 p. 48)
Usage
matrixConvolution(a, b)Arguments
a | An array of dimension |
b | An array of dimension |
Value
An array of dimension(S, S, k + 1) giving the discrete-timematrix convolution product for eachk \in N.
Method to get the mean recurrence times\mu
Description
Method to get the mean recurrence times\mu.
Usage
meanRecurrenceTimes(x, klim = 10000)Arguments
x | An object of S3 class |
klim | Optional. The time horizon used to approximate the series in thecomputation of the mean sojourn times vector |
Details
Consider a system (or a component)S_{ystem} whose possiblestates during its evolution in time areE = \{1,\dots,s\}.
We are interested in investigating the mean recurrence times of adiscrete-time semi-Markov systemS_{ystem}. Consequently, we supposethat the evolution in time of the system is governed by an E-state spacesemi-Markov chain(Z_k)_{k \in N}. The state of the system is givenat each instantk \in N byZ_k: the event\{Z_k = i\}.
LetT = (T_{n})_{n \in N} denote the successive time points whenstate changes in(Z_{n})_{n \in N} occur and let alsoJ = (J_{n})_{n \in N} denote the successively visited states atthese time points.
The mean recurrence of an arbitrary statej \in E is given by:
\mu_{jj} = \frac{\sum_{i \in E} \nu(i) m_{i}}{\nu(j)}
where(\nu(1),\dots,\nu(s)) is the stationary distribution of theembedded Markov chain(J_{n})_{n \in N} andm_{i} is the meansojourn time in statei \in E (seemeanSojournTimes function forthe computation).
Value
A vector giving the mean recurrence time(\mu_{i})_{i \in [1,\dots,s]}.
Mean Sojourn Times Function
Description
The mean sojourn time is the mean time spent in each state.
Usage
meanSojournTimes(x, states = x$states, klim = 10000)Arguments
x | An object of S3 class |
states | Vector giving the states for which the mean sojourn timeshould be computed. |
klim | Optional. The time horizon used to approximate the series in thecomputation of the mean sojourn times vector |
Details
Consider a system (or a component)S_{ystem} whose possiblestates during its evolution in time areE = \{1,\dots,s\}.
We are interested in investigating the mean sojourn times of adiscrete-time semi-Markov systemS_{ystem}. Consequently, we supposethat the evolution in time of the system is governed by an E-state spacesemi-Markov chain(Z_k)_{k \in N}. The state of the system is givenat each instantk \in N byZ_k: the event\{Z_k = i\}.
LetT = (T_{n})_{n \in N} denote the successive time points whenstate changes in(Z_{n})_{n \in N} occur and let alsoJ = (J_{n})_{n \in N} denote the successively visited states atthese time points.
The mean sojourn times vector is defined as follows:
m_{i} = E[T_{1} | Z_{0} = j] = \sum_{k \geq 0} (1 - P(T_{n + 1} - T_{n} \leq k | J_{n} = j)) = \sum_{k \geq 0} (1 - H_{j}(k)),\ i \in E
Value
A vector of length\textrm{card}(E) giving the values of themean sojourn times for each statei \in E.
Markov model specification
Description
Creates a model specification of a Markov model.
Usage
mm(states, init, ptrans, k = 1)Arguments
states | Vector of state space of length s. |
init | Vector of initial distribution of length s ^ k. |
ptrans | Matrix of transition probabilities of dimension |
k | Order of the Markov chain. |
Value
An object of classmm.
See Also
Examples
states <- c("a", "c", "g", "t")s <- length(states)k <- 1init <- rep.int(1 / s, s)p <- matrix(c(0, 0, 0.3, 0.4, 0, 0, 0.5, 0.2, 0.7, 0.5, 0, 0.4, 0.3, 0.5, 0.2, 0), ncol = s)# Specify a Markov model of order 1markov <- mm(states = states, init = init, ptrans = p, k = k)Mean Time To Failure (MTTF) Function
Description
Consider a systemS_{ystem} starting to work at timek = 0. The mean time to failure (MTTF) is defined as the meanlifetime.
Usage
mttf(x, upstates = x$states, level = 0.95, klim = 10000)Arguments
x | An object of S3 class |
upstates | Vector giving the subset of operational states |
level | Confidence level of the asymptotic confidence interval. Helpfulfor an object |
klim | Optional. The time horizon used to approximate the series in thecomputation of the mean sojourn times vector |
Details
Consider a system (or a component)S_{ystem} whose possiblestates during its evolution in time areE = \{1,\dots,s\}.Denote byU = \{1,\dots,s_1\} the subset of operational states ofthe system (the up states) and byD = \{s_1 + 1,\dots,s\} thesubset of failure states (the down states), with0 < s_1 < s(obviously,E = U \cup D andU \cap D = \emptyset,U \neq \emptyset,\ D \neq \emptyset). One can think of the statesofU as different operating modes or performance levels of thesystem, whereas the states ofD can be seen as failures of thesystems with different modes.
We are interested in investigating the mean time to failure of adiscrete-time semi-Markov systemS_{ystem}. Consequently, we supposethat the evolution in time of the system is governed by an E-state spacesemi-Markov chain(Z_k)_{k \in N}. The system starts to work atinstant0 and the state of the system is given at each instantk \in N byZ_k: the event\{Z_k = i\}, for a certaini \in U, means that the systemS_{ystem} is in operating modei at timek, whereas\{Z_k = j\}, for a certainj \in D, means that the system is not operational at timekdue to the mode of failurej or that the system is under therepairing modej.
LetT_D denote the first passage time in subsetD, calledthe lifetime of the system, i.e.,
T_D := \textrm{inf}\{ n \in N;\ Z_n \in D\}\ \textrm{and}\ \textrm{inf}\ \emptyset := \infty.
The mean time to failure (MTTF) is defined as the mean lifetime, i.e., theexpectation of the hitting time to down setD,
MTTF = E[T_{D}]
Value
A matrix with\textrm{card}(U) = s_{1} rows, and with columnsgiving values of the mean time to failure for each statei \in U,variances, lower and upper asymptotic confidence limits (ifx is anobject of classsmmfit).
References
V. S. Barbu, N. Limnios. (2008). Semi-Markov Chains and Hidden Semi-MarkovModels Toward Applications - Their Use in Reliability and DNA Analysis.New York: Lecture Notes in Statistics, vol. 191, Springer.
I. Votsi & A. Brouste (2019) Confidence interval for the mean time tofailure in semi-Markov models: an application to wind energy production,Journal of Applied Statistics, 46:10, 1756-1773
Mean Time To Repair (MTTR) Function
Description
Consider a systemS_{ystem} that has just failed at timek = 0. The mean time to repair (MTTR) is defined as the mean of therepair duration.
Usage
mttr(x, upstates = x$states, level = 0.95, klim = 10000)Arguments
x | An object of S3 class |
upstates | Vector giving the subset of operational states |
level | Confidence level of the asymptotic confidence interval. Helpfulfor an object |
klim | Optional. The time horizon used to approximate the series in thecomputation of the mean sojourn times vector |
Details
Consider a system (or a component)S_{ystem} whose possiblestates during its evolution in time areE = \{1,\dots,s\}.Denote byU = \{1,\dots,s_1\} the subset of operational states ofthe system (the up states) and byD = \{s_1 + 1,\dots,s\} thesubset of failure states (the down states), with0 < s_1 < s(obviously,E = U \cup D andU \cap D = \emptyset,U \neq \emptyset,\ D \neq \emptyset). One can think of the statesofU as different operating modes or performance levels of thesystem, whereas the states ofD can be seen as failures of thesystems with different modes.
We are interested in investigating the mean time to repair of adiscrete-time semi-Markov systemS_{ystem}. Consequently, we supposethat the evolution in time of the system is governed by an E-state spacesemi-Markov chain(Z_k)_{k \in N}. The system has just failed atinstant 0 and the state of the system is given at each instantk \in N byZ_k: the event\{Z_k = i\}, for a certaini \in U, means that the systemS_{ystem} is in operating modei at timek, whereas\{Z_k = j\}, for a certainj \in D, means that the system is not operational at timekdue to the mode of failurej or that the system is under therepairing modej.
LetT_U denote the first passage time in subsetU, called theduration of repair or repair time, i.e.,
T_U := \textrm{inf}\{ n \in N;\ Z_n \in U\}\ \textrm{and}\ \textrm{inf}\ \emptyset := \infty.
The mean time to repair (MTTR) is defined as the mean of the repairduration, i.e., the expectation of the hitting time to up setU,
MTTR = E[T_{U}]
Value
A matrix with\textrm{card}(U) = s_{1} rows, and with columnsgiving values of the mean time to repair for each statei \in U,variances, lower and upper asymptotic confidence limits (ifx is anobject of classsmmfit).
References
V. S. Barbu, N. Limnios. (2008). Semi-Markov Chains and Hidden Semi-MarkovModels Toward Applications - Their Use in Reliability and DNA Analysis.New York: Lecture Notes in Statistics, vol. 191, Springer.
I. Votsi & A. Brouste (2019) Confidence interval for the mean time tofailure in semi-Markov models: an application to wind energy production,Journal of Applied Statistics, 46:10, 1756-1773
Plot function for an object of class smm
Description
Displays the densities for the conditional sojourn timedistributions depending on the current statei and on the next statej.
Usage
## S3 method for class 'smm'plot(x, i, j, klim = NULL, ...)Arguments
x | An object of S3 class |
i | An element of the state space vector |
j | An element of the state space vector |
klim | An integer giving the limit value for which the density will beplotted. If |
... | Arguments passed to plot. |
Value
None.
Plot function for an object of class smmfit
Description
Displays the densities for the conditional sojourn timedistributions depending on the current statei and on the next statej.
Usage
## S3 method for class 'smmfit'plot(x, i, j, klim = NULL, ...)Arguments
x | An object of class |
i | An element of the state space vector |
j | An element of the state space vector |
klim | An integer giving the limit value for which the density will beplotted. If |
... | Arguments passed to plot. |
Value
None.
References
V. S. Barbu, N. Limnios. (2008). Semi-Markov Chains and Hidden Semi-MarkovModels Toward Applications - Their Use in Reliability and DNA Analysis.New York: Lecture Notes in Statistics, vol. 191, Springer.
Examples
states <- c("a", "c", "g", "t")s <- length(states)# Creation of the initial distributionvect.init <- c(1 / 4, 1 / 4, 1 / 4, 1 / 4)# Creation of the transition matrixpij <- matrix(c(0, 0.2, 0.3, 0.4, 0.2, 0, 0.5, 0.2, 0.5, 0.3, 0, 0.4, 0.3, 0.5, 0.2, 0), ncol = s)# Creation of the distribution matrixdistr.vec <- c("pois", "geom", "geom", "geom")parameters <- matrix(c(2, 0.6, 0.8, 0.8, NA, NA, NA, NA), ncol = 2, byrow = FALSE)# Specify the semi-Markov modelsmm <- smmparametric(states = states, init = vect.init, ptrans = pij, type.sojourn = "fi", distr = distr.vec, param = parameters)seqs <- simulate(object = smm, nsim = rep(5000, 100), seed = 10)est <- fitsmm(sequences = seqs, states = states, type.sojourn = "fi", distr = distr.vec)class(est)plot(x = est, i = "a", col = "blue", pch = "+")Reliability Function
Description
Consider a systemS_{ystem} starting to function at timek = 0. The reliability or the survival function ofS_{ystem}at timek \in N is the probability that the system has functionedwithout failure in the period[0, k].
Usage
reliability(x, k, upstates = x$states, level = 0.95, klim = 10000)Arguments
x | An object of S3 class |
k | A positive integer giving the period |
upstates | Vector giving the subset of operational states |
level | Confidence level of the asymptotic confidence interval. Helpfulfor an object |
klim | Optional. The time horizon used to approximate the series in thecomputation of the mean sojourn times vector |
Details
Consider a system (or a component)S_{ystem} whose possiblestates during its evolution in time areE = \{1,\dots,s\}.Denote byU = \{1,\dots,s_1\} the subset of operational states ofthe system (the up states) and byD = \{s_1 + 1,\dots, s\} thesubset of failure states (the down states), with0 < s_1 < s(obviously,E = U \cup D andU \cap D = \emptyset,U \neq \emptyset,\ D \neq \emptyset). One can think of the statesofU as different operating modes or performance levels of thesystem, whereas the states ofD can be seen as failures of thesystems with different modes.
We are interested in investigating the reliability of a discrete-timesemi-Markov systemS_{ystem}. Consequently, we suppose that theevolution in time of the system is governed by an E-state spacesemi-Markov chain(Z_k)_{k \in N}. The system starts to work atinstant0 and the state of the system is given at each instantk \in N byZ_k: the event\{Z_k = i\}, for a certaini \in U, means that the systemS_{ystem} is in operating modei at timek, whereas\{Z_k = j\}, for a certainj \in D, means that the system is not operational at timekdue to the mode of failurej or that the system is under therepairing modej.
LetT_D denote the first passage time in subsetD, calledthe lifetime of the system, i.e.,
T_D := \textrm{inf}\{ n \in N;\ Z_n \in D\}\ \textrm{and}\ \textrm{inf}\ \emptyset := \infty.
The reliability or the survival function at timek \in N of adiscrete-time semi-Markov system is:
R(k) := P(T_D > k) = P(Zn \in U,n = 0,\dots,k)
which can be rewritten as follows:
R(k) = \sum_{i \in U} P(Z_0 = i) P(T_D > k | Z_0 = i) = \sum_{i \in U} \alpha_i P(T_D > k | Z_0 = i)
Value
A matrix withk + 1 rows, and with columns giving values ofthe reliability, variances, lower and upper asymptotic confidence limits(ifx is an object of classsmmfit).
References
V. S. Barbu, N. Limnios. (2008). Semi-Markov Chains and Hidden Semi-MarkovModels Toward Applications - Their Use in Reliability and DNA Analysis.New York: Lecture Notes in Statistics, vol. 191, Springer.
Set the RNG Seed from within Rcpp
Description
Set the RNG Seed from within Rcpp
Usage
setSeed(seed)Arguments
seed | An |
Value
A set RNG scope.
Examples
set.seed(10)x <- rnorm(5, 0, 1)setSeed(10)y <- rnorm(5, 0, 1)all.equal(x, y, check.attributes = FALSE)Simulates k-th order Markov chains
Description
Simulates k-th order Markov chains.
Usage
## S3 method for class 'mm'simulate(object, nsim = 1, seed = NULL, ...)Arguments
object | An object of classmm. |
nsim | An integer or vector of integers (for multiple sequences)specifying the length of the sequence(s). |
seed | Optional. |
... | further arguments passed to or from other methods. |
Details
Ifnsim is a single integer then a chain of that length isproduced. Ifnsim is a vector of integers, thenlength(nsim)sequences are generated with respective lengths.
Value
A list of vectors representing the sequences.
See Also
Examples
states <- c("a", "c", "g", "t")s <- length(states)k <- 2init <- rep.int(1 / s ^ k, s ^ k)p <- matrix(0.25, nrow = s ^ k, ncol = s)# Specify a Markov model of order 1markov <- mm(states = states, init = init, ptrans = p, k = k)seqs <- simulate(object = markov, nsim = c(1000, 10000, 2000), seed = 150)Simulates Markov chains
Description
Simulates sequences from a fitted Markov model.
Usage
## S3 method for class 'mmfit'simulate(object, nsim = 1, seed = NULL, ...)Arguments
object | An object of class |
nsim | An integer or vector of integers (for multiple sequences)specifying the length of the sequence(s). |
seed | Optional. |
... | further arguments passed to or from other methods. |
Details
Ifnsim is a single integer then a chain of that length isproduced. Ifnsim is a vector of integers, thenlength(nsim)sequences are generated with respective lengths.
Value
A list of vectors representing the sequences.
See Also
Simulates semi-Markov chains
Description
Simulates sequences from a semi-Markov model.
Usage
## S3 method for class 'smm'simulate(object, nsim = 1, seed = NULL, ...)Arguments
object | An object of S3 class |
nsim | An integer or vector of integers (for multiple sequences)specifying the length of the sequence(s). |
seed | Optional. |
... | further arguments passed to or from other methods. |
Details
Ifnsim is a single integer then a chain of that length isproduced. Ifnsim is a vector of integers, thenlength(nsim)sequences are generated with respective lengths.
Value
A list of vectors representing the sequences.
References
V. S. Barbu, N. Limnios. (2008). Semi-Markov Chains and Hidden Semi-MarkovModels Toward Applications - Their Use in Reliability and DNA Analysis.New York: Lecture Notes in Statistics, vol. 191, Springer.
See Also
smmparametric,smmnonparametric,fitsmm
Simulates semi-Markov chains
Description
Simulates sequences from a fitted semi-Markov model.
Usage
## S3 method for class 'smmfit'simulate(object, nsim = 1, seed = NULL, ...)Arguments
object | An object of class |
nsim | An integer or vector of integers (for multiple sequences)specifying the length of the sequence(s). |
seed |
|
... | further arguments passed to or from other methods. |
Details
Ifnsim is a single integer then a chain of that length isproduced. Ifnsim is a vector of integers, thenlength(nsim)sequences are generated with respective lengths.
Value
A list of vectors representing the sequences.
References
V. S. Barbu, N. Limnios. (2008). Semi-Markov Chains and Hidden Semi-MarkovModels Toward Applications - Their Use in Reliability and DNA Analysis.New York: Lecture Notes in Statistics, vol. 191, Springer.
See Also
smmnonparametric,smmparametric,fitsmm
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 |
init | Vector of initial distribution of length |
ptrans | Matrix of transition probabilities of the embedded Markovchain |
type.sojourn | Type of sojourn time (for more explanations, see Details). |
distr |
|
cens.beg | Optional. A logical value indicating whether or notsequences are censored at the beginning. |
cens.end | Optional. A logical value indicating whether or notsequences are censored at the end. |
Details
This function creates a semi-Markov model object in thenon-parametric case, taking into account the type of sojourn time and thecensoring described in references. The non-parametric specification concernssojourn time distributions defined by the user.
The difference between the Markov model and the semi-Markov model concernsthe modeling of the sojourn time. With a Markov chain, the sojourn timedistribution 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 statesof the embedded Markov chainJ = (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 argumentdistrin 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 definekmax the maximum length of the sojourn times.Iftype.sojourn = "fij",distr is an array of dimension(s, s, kmax).Iftype.sojourn = "fi" or"fj",distr must be a matrix of dimension(s, kmax).Iftype.sojourn = "f",distr must be a vector of lengthkmax.
If the sequence is censored at the beginning and/or at the end,cens.begmust be equal toTRUE and/orcens.end must be equal toTRUE.All the sequences must be censored in the same way.
Value
Returns an object of classsmm,smmnonparametric.
References
V. S. Barbu, N. Limnios. (2008). Semi-Markov Chains and Hidden Semi-MarkovModels Toward Applications - Their Use in Reliability and DNA Analysis.New York: Lecture Notes in Statistics, vol. 191, Springer.
See Also
Examples
states <- c("a", "c", "g", "t")s <- length(states)# Creation of the initial distributionvect.init <- c(1 / 4, 1 / 4, 1 / 4, 1 / 4)# Creation of the transition matrixpij <- 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 distributionskmax <- 6nparam.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)semimarkovParametric semi-Markov model specification
Description
Creates a parametric model specification for a semi-Markov model.
Usage
smmparametric( states, init, ptrans, type.sojourn = c("fij", "fi", "fj", "f"), distr, param, cens.beg = FALSE, cens.end = FALSE)Arguments
states | Vector of state space of length |
init | Vector of initial distribution of length |
ptrans | Matrix of transition probabilities of the embedded Markovchain |
type.sojourn | Type of sojourn time (for more explanations, see Details). |
distr |
where the distributions to be used can be one of |
param | Parameters of sojourn time distributions:
When parameters/values are not necessary (e.g. the Poisson distribution hasonly one parameter that is |
cens.beg | Optional. A logical value indicating whether or notsequences are censored at the beginning. |
cens.end | Optional. A logical value indicating whether or notsequences are censored at the end. |
Details
This function creates a semi-Markov model object in the parametriccase, taking into account the type of sojourn time and the censoringdescribed in references. For the parametric specification, several discretedistributions are considered (see below).
The difference between the Markov model and the semi-Markov model concernsthe modeling of the sojourn time. With a Markov chain, the sojourn timedistribution is modeled by a Geometric distribution (in discrete time).With a semi-Markov chain, the sojourn time can be any arbitrary distribution.In this package, the available distribution for a semi-Markov model are :
Uniform:
f(x) = 1/nfora \le x \le b, withn = b-a+1;Geometric:
f(x) = \theta (1-\theta)^xforx = 0, 1, 2,\ldots,n,0 < \theta < 1, withn > 0and\thetais the probability of success;Poisson:
f(x) = (\lambda^x exp(-\lambda))/x!forx = 0, 1, 2,\ldots,n, withn > 0and\lambda > 0;Discrete Weibull of type 1:
f(x)=q^{(x-1)^{\beta}}-q^{x^{\beta}}, x=1,2,3,\ldots,n, withn > 0,qis the first parameter and\betais the second parameter;Negative binomial:
f(x)=\frac{\Gamma(x+\alpha)}{\Gamma(\alpha) x!} p^{\alpha} (1 - p)^x,forx = 0, 1, 2,\ldots,n,\Gammais the Gamma function,\alphais the parameter of overdispersion andpis theprobability of success,0 < p < 1;Non-parametric.
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 statesof the embedded Markov chainJ = (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 ),fis specified by the argumentparamin the 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).
Iftype.sojourn = "fij",distr is a matrix of dimension(s, s)(e.g., if the row 1 of the 2nd column is"pois", that is to say we go fromthe first state to the second state following a Poisson distribution).Iftype.sojourn = "fi" or"fj",distr must be a vector (e.g., if thefirst element of vector is"geom", that is to say we go from the firststate to any state according to a Geometric distribution).Iftype.sojourn = "f",distr must be one of"unif","geom","pois","dweibull","nbinom" (e.g., ifdistr is equal to"nbinom", that isto say that the sojourn times when going from any state to any state followsa Negative Binomial distribution).For the non-parametric case,distr is equal to"nonparametric" whatevertype of sojourn time given.
If the sequence is censored at the beginning and/or at the end,cens.begmust be equal toTRUE and/orcens.end must be equal toTRUE.All the sequences must be censored in the same way.
Value
Returns an object of classsmmparametric.
References
V. S. Barbu, N. Limnios. (2008). Semi-Markov Chains and Hidden Semi-MarkovModels Toward Applications - Their Use in Reliability and DNA Analysis.New York: Lecture Notes in Statistics, vol. 191, Springer.
See Also
simulate,fitsmm,smmnonparametric
Examples
states <- c("a", "c", "g", "t")s <- length(states)# Creation of the initial distributionvect.init <- c(1 / 4, 1 / 4, 1 / 4, 1 / 4)# Creation of the transition matrixpij <- 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 the distribution matrixdistr.matrix <- matrix(c(NA, "pois", "geom", "nbinom", "geom", NA, "pois", "dweibull", "pois", "pois", NA, "geom", "pois", "geom", "geom", NA), nrow = s, ncol = s, byrow = TRUE)# Creation of an array containing the parametersparam1.matrix <- matrix(c(NA, 2, 0.4, 4, 0.7, NA, 5, 0.6, 2, 3, NA, 0.6, 4, 0.3, 0.4, NA), nrow = s, ncol = s, byrow = TRUE)param2.matrix <- matrix(c(NA, NA, NA, 0.6, NA, NA, NA, 0.8, NA, NA, NA, NA, NA, NA, NA, NA), nrow = s, ncol = s, byrow = TRUE)param.array <- array(c(param1.matrix, param2.matrix), c(s, s, 2))# Specify the semi-Markov modelsemimarkov <- smmparametric(states = states, init = vect.init, ptrans = pij, type.sojourn = "fij", distr = distr.matrix, param = param.array)semimarkov