PhaseType {actuar} | R Documentation |
The Phase-type Distribution
Description
Density, distribution function, random generation, raw moments and
moment generating function for the (continuous) Phase-type
distribution with parameters prob
and rates
.
Usage
dphtype(x, prob, rates, log = FALSE)
pphtype(q, prob, rates, lower.tail = TRUE, log.p = FALSE)
rphtype(n, prob, rates)
mphtype(order, prob, rates)
mgfphtype(t, prob, rates, log = FALSE)
Arguments
x , q |
vector of quantiles. |
n |
number of observations. If |
prob |
vector of initial probabilities for each of the transient
states of the underlying Markov chain. The initial probability of
the absorbing state is |
rates |
square matrix of the rates of transition among the states of the underlying Markov chain. |
log , log.p |
logical; if |
lower.tail |
logical; if |
order |
order of the moment. |
t |
numeric vector. |
Details
The phase-type distribution with parameters prob
and
rates
has density:
for and
, where
is a column vector with all components equal to one,
is the exit rates vector and
denotes the matrix exponential of
. The
matrix exponential of a matrix
is defined as
the Taylor series
The parameters of the distribution must satisfy
,
,
and
.
The th raw moment of the random variable
is
and the moment generating function is
.
Value
dphasetype
gives the density,
pphasetype
gives the distribution function,
rphasetype
generates random deviates,
mphasetype
gives the th raw moment, and
mgfphasetype
gives the moment generating function in x
.
Invalid arguments will result in return value NaN
, with a warning.
Note
The "distributions"
package vignette provides the
interrelations between the continuous size distributions in
actuar and the complete formulas underlying the above functions.
Author(s)
Vincent Goulet vincent.goulet@act.ulaval.ca and Christophe Dutang
References
https://en.wikipedia.org/wiki/Phase-type_distribution
Neuts, M. F. (1981), Generating random variates from a distribution of phase type, WSC '81: Proceedings of the 13th conference on Winter simulation, IEEE Press.
Examples
## Erlang(3, 2) distribution
T <- cbind(c(-2, 0, 0), c(2, -2, 0), c(0, 2, -2))
pi <- c(1,0,0)
x <- 0:10
dphtype(x, pi, T) # density
dgamma(x, 3, 2) # same
pphtype(x, pi, T) # cdf
pgamma(x, 3, 2) # same
rphtype(10, pi, T) # random values
mphtype(1, pi, T) # expected value
curve(mgfphtype(x, pi, T), from = -10, to = 1)