Learn R Programming

evmix (version 1.0)

gpd: Generalised Pareto Distribution (GPD)

Description

Density, cumulative distribution function, quantile function and random number generation for the GPD conditional on being above a threshold u with parameters sigmau and xi. Unconditional quantities are provided when the probability phiu of being above the threshold u is given.

Usage

dgpd(x, u = 0, sigmau = 1, xi = 0, phiu = 1, log = FALSE)

  pgpd(q, u = 0, sigmau = 1, xi = 0, phiu = 1,
    lower.tail = TRUE)

  qgpd(p, u = 0, sigmau = 1, xi = 0, phiu = 1,
    lower.tail = TRUE)

  rgpd(n = 1, u = 0, sigmau = 1, xi = 0, phiu = 1)

Arguments

x
quantile
q
quantile
p
cumulative probability
n
sample size (non-negative integer)
u
threshold
sigmau
scale parameter (non-negative)
xi
shape parameter
phiu
probability of being above threshold [0,1]
log
logical, if TRUE then log density
lower.tail
logical, if FALSE then upper tail probabilities

Value

  • dgpd gives the density, pgpd gives the cumulative distribution function, qgpd gives the quantile function and rgpd gives a random sample.

Details

The GPD with parameters scale $\sigma_u$ and shape $\xi$ has conditional density given by $$f(x | X > u) = 1/\sigma_u [1 + \xi(x - u)/\sigma_u]^{-1/\xi - 1}$$ for non-zero $\xi$, $x > u$ and $\sigma_u > 0$. Further, $[1+\xi (x - u) / \sigma_u] > 0$ which for $\xi < 0$ implies $u < x \le u - \sigma_u/\xi$. In the special case of $\xi = 0$, which is treated as $|\xi|<1e-6$, it="" reduces="" to="" the="" exponential:="" $$f(x="" |="" x=""> u) = 1/\sigma_u exp(-(x - u)/\sigma_u).$$ The unconditional density is obtained by mutltiplying this by the survival probability (or tail fraction) $\phi_u = P(X > u)$ giving $f(x) = \phi_u f(x | X > u)$. The syntax of these functions are similar to those of the evd package, so most code using these functions can simply be reused. The key difference is the introduction of phiu to permit output of unconditional quantities.

References

http://en.wikipedia.org/wiki/Generalized_Pareto_distribution Based on GPD functions in the evd package.

See Also

evd and fpot Other gpd: fgpd, lgpd, nlgpd

Examples

Run this code
par(mfrow=c(2,2))
x = rgpd(1000) # simulate sample from GPD
xx = seq(-1, 10, 0.01)
hist(x, breaks = 100, freq = FALSE, xlim = c(-1, 10))
lines(xx, dgpd(xx))
# three tail behaviours
plot(xx, pgpd(xx), type = "l")
lines(xx, pgpd(xx, xi = 0.3), col = "red")
lines(xx, pgpd(xx, xi = -0.3), col = "blue")
legend("bottomright", paste("xi =",c(0, 0.3, -0.3)),
  col=c("black", "red", "blue"), lty = 1)

# GPD when xi=0 is exponential, and demonstrating phiu
x = rexp(1000)
hist(x, breaks = 100, freq = FALSE, xlim = c(-1, 10))
lines(xx, dgpd(xx, u = 0, sigmau = 1, xi = 0), lwd = 2)
lines(xx, dgpd(xx, u = 0.5, phiu = 1 - pexp(0.5)), col = "red", lwd = 2)
lines(xx, dgpd(xx, u = 1.5, phiu = 1 - pexp(1.5)), col = "blue", lwd = 2)
legend("topright", paste("u =",c(0, 0.5, 1.5)),
  col=c("black", "red", "blue"), lty = 1, lwd = 2)

# Quantile function and phiu
p = pgpd(xx)
plot(qgpd(p), p, type = "l")
lines(xx, pgpd(xx, u = 2), col = "red")
lines(xx, pgpd(xx, u = 5, phiu = 0.2), col = "blue")
legend("bottomright", c("u = 0 phiu = 1","u = 2 phiu = 1","u = 5 phiu = 0.2"),
  col=c("black", "red", "blue"), lty = 1)

Run the code above in your browser using DataLab