Density, distribution, quantile functions and other utilities for the Coxian phase-type distribution with two phases.

1 2 3 4 5 |

`x,q` |
vector of quantiles. |

`p` |
vector of probabilities. |

`n` |
number of observations. If |

`l1` |
Intensity for transition between phase 1 and phase 2. |

`mu1` |
Intensity for transition from phase 1 to exit. |

`mu2` |
Intensity for transition from phase 2 to exit. |

`log` |
logical; if TRUE, return log density or log hazard. |

`log.p` |
logical; if TRUE, probabilities p are given as log(p). |

`lower.tail` |
logical; if TRUE (default), probabilities are P[X <= x], otherwise, P[X > x]. |

This is the distribution of the time to reach state 3 in a
continuous-time Markov model with three states and transitions permitted
from state 1 to state 2 (with intensity
*lambda1*) state 1 to state 3 (intensity
*mu1*) and state 2 to state 3 (intensity *mu2*).
States 1 and 2 are the two "phases" and state 3 is the "exit" state.

The density is

*f(t | l1, mu1) = exp(-(l1+mu1)*t)*(mu1 + (l1+mu1)*l1*t)*

if *l1 + mu1 = mu2*, and

*f(t | l1, mu1, mu2) = ((l1+mu1)*exp(-(l1+mu1)*t)*(mu2-mu1) + mu2*l1*exp(-mu2*t))/(l1+mu1-mu2)*

otherwise. The distribution function is

*F(t | l1, mu1) = 1 - exp(-(l1+mu1)*t)*(1 + l1*t)*

if *l1 + mu1 = mu2*, and

*F(t | l1, mu1, mu2) = 1 -
(exp(-(l1+mu1)*t)*(-mu1+mu2) + l1*exp(-mu2*t))/(l1+mu1-mu2)*

otherwise. Quantiles are calculated by numerically inverting the distribution function.

The mean is *(1 + l1/mu2) / (l1 + mu1)*.

The variance is *(2 + 2*l1*(l1+mu1+ mu2)/mu2^2 - (1 + l1/mu2)^2)/(l1+mu1)^2*.

If *mu1=mu2* it reduces to an exponential
distribution with rate *mu1*, and the parameter
*l1* is redundant. Or also if *l1=0*.

The hazard at *x=0* is *μ_1*, and smoothly increasing if
*mu1<mu2*. If *l1 + mu1 >= mu2*
it increases to an asymptote of *mu2*, and if
*l1 + mu1 <= mu2* it increases to an
asymptote of *l1 + mu1*.
The hazard is decreasing if *mu1>mu2*, to an
asymptote of *mu2*.

`d2phase`

gives the density, `p2phase`

gives the distribution
function, `q2phase`

gives the quantile function, `r2phase`

generates random deviates, and `h2phase`

gives the hazard.

An individual following this distribution can be seen as coming from a mixture of two populations:

1) "short stayers" whose mean sojourn time is *M1 = 1/(l1+mu1)* and sojourn distribution is
exponential with rate *l1+mu1*.

2) "long stayers" whose mean sojourn time *1/(l1+mu1) + 1/mu2* and sojourn
distribution is the sum of two exponentials with rate *l1+mu1*
and *mu2*
respectively. The individual is a "long stayer" with probability
*p=λ_1/(λ_1 + μ_1)*.

Thus a two-phase distribution can be more intuitively parameterised by
the short and long stay means *M_1 < M_2* and the long stay
probability *p*. Given these parameters, the transition
intensities are *l1=p/M1*,
*mu1=(1-p)/M1*, and *mu2 =
1/(M2 - M1)*. This can be useful for choosing intuitively reasonable
initial values for procedures to fit these models to data.

The hazard is increasing at least if *M2 < 2M1*,
and also only if *(M2 - 2M1)/(M2 -
M1) < p*.

For increasing hazards with *l1 +
mu1 <= mu2*, the maximum hazard
ratio between any time *t* and time 0 is *1/(1-p)*.

For increasing hazards with *l1 +
mu1 >= mu2*, the maximum hazard ratio is *M1/((1-p)(M2 - M1))*. This is the minimum hazard ratio for
decreasing hazards.

This is a special case of the n-phase Coxian phase-type distribution, which in turn is a special case of the (general) phase-type distribution. The actuar R package implements a general n-phase distribution defined by the time to absorption of a general continuous-time Markov chain with a single absorbing state, where the process starts in one of the transient states with a given probability.

C. H. Jackson chris.jackson@mrc-bsu.cam.ac.uk

C. Dutang, V. Goulet and M. Pigeon (2008). actuar: An R Package for Actuarial Science. Journal of Statistical Software, vol. 25, no. 7, 1-37. URL http://www.jstatsoft.org/v25/i07

Questions? Problems? Suggestions? Tweet to @rdrrHQ or email at ian@mutexlabs.com.

Please suggest features or report bugs with the GitHub issue tracker.

All documentation is copyright its authors; we didn't write any of that.

Embedding an R snippet on your website

Add the following code to your website.

For more information on customizing the embed code, read Embedding Snippets.