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 length(n) > 1, the length is taken to be the number required.

prob

vector of initial probabilities for each of the transient states of the underlying Markov chain. The initial probability of the absorbing state is 1 - sum(prob).

rates

square matrix of the rates of transition among the states of the underlying Markov chain.

log, log.p

logical; if TRUE, probabilities/densities p are returned as \log(p).

lower.tail

logical; if TRUE (default), probabilities are P[X \le x], otherwise, P[X > x].

order

order of the moment.

t

numeric vector.

Details

The phase-type distribution with parameters prob = \pi and rates = \boldsymbol{T} has density:

f(x) = \pi e^{\boldsymbol{T} x} \boldsymbol{t}

for x \ge 0 and f(0) = 1 - \pi \boldsymbol{e}, where \boldsymbol{e} is a column vector with all components equal to one, \boldsymbol{t} = -\boldsymbol{T} \boldsymbol{e} is the exit rates vector and e^{\boldsymbol{T}x} denotes the matrix exponential of \boldsymbol{T}x. The matrix exponential of a matrix \boldsymbol{M} is defined as the Taylor series

e^{\boldsymbol{M}} = \sum_{n = 0}^{\infty} \frac{\boldsymbol{M}^n}{n!}.

The parameters of the distribution must satisfy \pi \boldsymbol{e} \leq 1, \boldsymbol{T}_{ii} < 0, \boldsymbol{T}_{ij} \geq 0 and \boldsymbol{T} \boldsymbol{e} \leq 0.

The kth raw moment of the random variable X is E[X^k] and the moment generating function is E[e^{tX}].

Value

dphasetype gives the density, pphasetype gives the distribution function, rphasetype generates random deviates, mphasetype gives the kth 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)

[Package actuar version 3.3-4 Index]