# Exponential distribution with piecewise-constant rate

### Description

Density, distribution function, quantile function and random generation for a generalisation of the exponential distribution, in which the rate changes at a series of times.

### Usage

1 2 3 4 |

### Arguments

`x,q` |
vector of quantiles. |

`p` |
vector of probabilities. |

`n` |
number of observations. If |

`rate` |
vector of rates. |

`t` |
vector of the same length as |

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

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

### Details

Consider the exponential distribution with rates *r1,…, rn* changing at times *t1,
…, tn*, with *t1 = 0*. Suppose *tk* is the
maximum *ti* such that
*ti < x*.
The density of this distribution at *x > 0* is *f(x)* for *k = 1*,
and

*∏{i=1 … k} (1 - F(ti - t{i-1}, r{i-1})) f(x - tk, rk)*

for k > 1.

where *F()* and *f()* are the distribution and density
functions of the standard exponential distribution.

If `rate`

is of length 1, this is just the standard exponential
distribution. Therefore, for example, `dpexp(x)`

, with no other
arguments, is simply equivalent to `dexp(x)`

.

Only `rpexp`

is used in the `msm`

package, to simulate
from Markov processes with piecewise-constant intensities depending on
time-dependent covariates. These functions are merely provided for
completion, and are not optimized for numerical stability or speed.

### Value

`dpexp`

gives the density, `ppexp`

gives the distribution
function, `qpexp`

gives the quantile function, and `rpexp`

generates random deviates.

### Author(s)

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

### See Also

`dexp`

, `sim.msm`

.

### Examples

1 2 3 4 5 6 7 8 9 10 11 | ```
x <- seq(0.1, 50, by=0.1)
rate <- c(0.1, 0.2, 0.05, 0.3)
t <- c(0, 10, 20, 30)
## standard exponential distribution
plot(x, dexp(x, 0.1), type="l")
## distribution with piecewise constant rate
lines(x, dpexp(x, rate, t), type="l", lty=2)
## standard exponential distribution
plot(x, pexp(x, 0.1), type="l")
## distribution with piecewise constant rate
lines(x, ppexp(x, rate, t), type="l", lty=2)
``` |