ph: Phase-Type (PH) Distribution

Description Usage Arguments Details Value Note See Also Examples

View source: R/model_ph.R

Description

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

Usage

1
2
3
4
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, q

vectors of quantiles.

p

a vector of probabilities.

n

number of observations.

ph

an object of S4 class of PH (ph).

log

logical; if TRUE, the log density is returned.

lower.tail

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

log.p

logical; if TRUE, the log probability is returned.

Details

The PH distribution with parameters α, Q and ξ: Cumulative probability function;

F(q) = 1 - α \exp( Q q ) 1

Probability density function;

f(x) = α \exp( Q x ) ξ

Value

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

Note

ph requires either size or (alpha, Q, xi). rph for ph is too slow. It is recommended to use rph for cf1.

See Also

cf1, herlang

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
## 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))

mapfit documentation built on May 29, 2017, 3:44 p.m.