Learn R Programming

mapfit (version 0.9.9)

ph: Phase-Type (PH) Distribution

Description

Density function, distribution function and random generation for the PH distribution, and a function to generate an object of '>ph.

Usage

ph(size, alpha, Q, xi, class = "CsparseMatrix")

dph(x, ph = ph(1), log = FALSE)

pph(q, ph = ph(1), lower.tail = TRUE, log.p = FALSE)

rph(n, ph = ph(1))

Arguments

size

A value for the number of phases.

alpha

A vector for the initial probabilities of PH distribution.

Q

An object of Matrix class for the initesmal generator of PH distribution.

xi

A vector for the exit rates of PH distribution.

class

Name of Matrix class for Q.

x

Vectors of quantiles.

ph

An object of S4 class of PH ('>ph).

log

Logical; if TRUE, the log density is returned.

q

Vectors of quantiles.

lower.tail

Logical; if TRUE, probabilities are P[X <= x], otherwise, P[X > x].

log.p

Logical; if TRUE, the log probability is returned.

n

Number of observations.

p

A vector of probabilities.

Value

ph gives an object of general PH distribution. dph gives the density function, pph gives the distribution function, and rph generates random samples.

Details

The PH distribution with parameters \(\alpha\), \(Q\) and \(\xi\): Cumulative probability function; $$F(q) = 1 - \alpha \exp( Q q ) 1$$ Probability density function; $$f(x) = \alpha \exp( Q x ) \xi$$

See Also

cf1, herlang

Examples

Run this code
# NOT RUN {
## create a PH (full matrix) with 5 phases
(param1 <- ph(5))

## create a PH (full matrix) with 5 phases
(param1 <- ph(size=5))

## create a PH with specific parameters
(param2 <- ph(alpha=c(1,0,0), 
              Q=rbind(c(-4,2,0),c(2,-5,1),c(1,0,-1)),
              xi=c(2,2,0))) 

## p.d.f. for 0, 0.1, ..., 1
(dph(x=seq(0, 1, 0.1), ph=param2))

## c.d.f. for 0, 0.1, ..., 1
(pph(q=seq(0, 1, 0.1), ph=param2))

## generate 10 samples
(rph(n=10, ph=param2))
# }

Run the code above in your browser using DataLab