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 pp are returned as log(p)\log(p).

lower.tail

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

order

order of the moment.

t

numeric vector.

Details

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

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

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

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

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

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

Value

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