Learn R Programming

extraDistr (version 1.8.1)

GPD: Generalized Pareto distribution

Description

Density, distribution function, quantile function and random generation for the generalized Pareto distribution.

Usage

dgpd(x, mu = 0, sigma = 1, xi = 0, log = FALSE)
pgpd(q, mu = 0, sigma = 1, xi = 0, lower.tail = TRUE, log.p = FALSE)
qgpd(p, mu = 0, sigma = 1, xi = 0, lower.tail = TRUE, log.p = FALSE)
rgpd(n, mu = 0, sigma = 1, xi = 0)

Arguments

x, q
vector of quantiles.
mu, sigma, xi
location, scale, and shape parameters. Scale must be positive.
log, log.p
logical; if TRUE, probabilities p are given as log(p).
lower.tail
logical; if TRUE (default), probabilities are $P[X \le x]$ otherwise, $P[X > x]$.
p
vector of probabilities.
n
number of observations. If length(n) > 1, the length is taken to be the number required.

Details

Probability density function $$ f(x) = \left\{\begin{array}{ll} \frac{1}{\sigma} \left(1+\xi \frac{x-\mu}{\sigma}\right)^{-(\xi+1)/\xi} & \xi \neq 0 \\ \frac{1}{\sigma} \exp\left(-\frac{x-\mu}{\sigma}\right) & \xi = 0 \end{array}\right. $$

Cumulative distribution function $$ F(x) = \left\{\begin{array}{ll} 1-\left(1+\xi \frac{x-\mu}{\sigma}\right)^{-1/\xi} & \xi \neq 0 \\ 1-\exp\left(-\frac{x-\mu}{\sigma}\right) & \xi = 0 \end{array}\right. $$

Quantile function $$ F^{-1}(x) = \left\{\begin{array}{ll} \mu + \sigma \frac{(1-p)^{-\xi}-1}{\xi} & \xi \neq 0 \\ \mu - \sigma \log(1-p) & \xi = 0 \end{array}\right. $$

References

Coles, S. (2001). An Introduction to Statistical Modeling of Extreme Values. Springer.

Examples

Run this code

x <- rgpd(1e5, 5, 2, .1)
xx <- seq(0, 1000, by = 0.1)
hist(x, 100, freq = FALSE, xlim = c(0, 50))
lines(xx, dgpd(xx, 5, 2, .1), col = "red")
hist(pgpd(x, 5, 2, .1))
plot(ecdf(x))
lines(xx, pgpd(xx, 5, 2, .1), col = "red", lwd = 2)

Run the code above in your browser using DataLab