View source: R/smmparametric.R
smmparametric | R Documentation |
Creates a parametric model specification for a semi-Markov model.
smmparametric(
states,
init,
ptrans,
type.sojourn = c("fij", "fi", "fj", "f"),
distr,
param,
cens.beg = FALSE,
cens.end = FALSE
)
states |
Vector of state space of length |
init |
Vector of initial distribution of length |
ptrans |
Matrix of transition probabilities of the embedded Markov
chain |
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 has
only one parameter that is |
cens.beg |
Optional. A logical value indicating whether or not sequences are censored at the beginning. |
cens.end |
Optional. A logical value indicating whether or not sequences are censored at the end. |
This function creates a semi-Markov model object in the parametric case, taking into account the type of sojourn time and the censoring described in references. For the parametric specification, several discrete distributions are considered (see below).
The difference between the Markov model and the semi-Markov model concerns the modeling of the sojourn time. With a Markov chain, the sojourn time distribution 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/n
for a \le x \le b
, with n = b-a+1
;
Geometric: f(x) = \theta (1-\theta)^x
for x = 0, 1, 2,\ldots,n
, 0 < \theta < 1
, with n > 0
and \theta
is the probability of success;
Poisson: f(x) = (\lambda^x exp(-\lambda))/x!
for x = 0, 1, 2,\ldots,n
, with n > 0
and \lambda > 0
;
Discrete Weibull of type 1: f(x)=q^{(x-1)^{\beta}}-q^{x^{\beta}}, x=1,2,3,\ldots,n
, with n > 0
, q
is the first parameter and \beta
is the second parameter;
Negative binomial: f(x)=\frac{\Gamma(x+\alpha)}{\Gamma(\alpha) x!} p^{\alpha} (1 - p)^x
,
for x = 0, 1, 2,\ldots,n
, \Gamma
is the Gamma function,
\alpha
is the parameter of overdispersion and p
is the
probability 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 states
of the embedded Markov chain J = (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 argument param
in 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
).
If type.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 from
the first state to the second state following a Poisson distribution).
If type.sojourn = "fi"
or "fj"
, distr
must be a vector (e.g., if the
first element of vector is "geom"
, that is to say we go from the first
state to any state according to a Geometric distribution).
If type.sojourn = "f"
, distr
must be one of "unif"
, "geom"
, "pois"
,
"dweibull"
, "nbinom"
(e.g., if distr
is equal to "nbinom"
, that is
to say that the sojourn times when going from any state to any state follows
a Negative Binomial distribution).
For the non-parametric case, distr
is equal to "nonparametric"
whatever
type of sojourn time given.
If the sequence is censored at the beginning and/or at the end, cens.beg
must be equal to TRUE
and/or cens.end
must be equal to TRUE
.
All the sequences must be censored in the same way.
Returns an object of class smmparametric.
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.
simulate, fitsmm, smmnonparametric
states <- c("a", "c", "g", "t")
s <- length(states)
# Creation of the initial distribution
vect.init <- c(1 / 4, 1 / 4, 1 / 4, 1 / 4)
# Creation of the transition matrix
pij <- 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 matrix
distr.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 parameters
param1.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 model
semimarkov <- smmparametric(states = states, init = vect.init, ptrans = pij,
type.sojourn = "fij", distr = distr.matrix,
param = param.array)
semimarkov
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.