GPDtail {qrmtools}R Documentation

GPD-Based Tail Distribution (POT method)

Description

Density, distribution function, quantile function and random variate generation for the GPD-based tail distribution in the POT method.

Usage

dGPDtail(x, threshold, p.exceed, shape, scale, log = FALSE)
pGPDtail(q, threshold, p.exceed, shape, scale, lower.tail = TRUE, log.p = FALSE)
qGPDtail(p, threshold, p.exceed, shape, scale, lower.tail = TRUE, log.p = FALSE)
rGPDtail(n, threshold, p.exceed, shape, scale)

Arguments

x, q

vector of quantiles.

p

vector of probabilities.

n

number of observations.

threshold

threshold u in the POT method.

p.exceed

probability of exceeding the threshold u; for the Smith estimator, this is mean(x > threshold) for x being the data.

shape

GPD shape parameter xi (a real number).

scale

GPD scale parameter beta (a positive number).

lower.tail

logical; if TRUE (default) probabilities are P(X <= x) otherwise, P(X > x).

log, log.p

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

Details

Let u denote the threshold (threshold), p_u the exceedance probability (p.exceed) and F_{GPD} the GPD distribution function. Then the distribution function of the GPD-based tail distribution is given by

F(q) = 1-p_u(1-F_{GPD}(q - u))

. The quantile function is

F^{-1}(p) = u + F_GPD^{-1}(1-(1-p)/p_u)

and the density is

f(x) = p_u f_{GPD}(x - u)

, where f_{GPD} denotes the GPD density.

Note that the distribution function has a jumpt of height P(X <=u) (1-p.exceed) at u.

Value

dGPDtail() computes the density, pGPDtail() the distribution function, qGPDtail() the quantile function and rGPDtail() random variates of the GPD-based tail distribution in the POT method.

Author(s)

Marius Hofert

References

McNeil, A. J., Frey, R., and Embrechts, P. (2015). Quantitative Risk Management: Concepts, Techniques, Tools. Princeton University Press.

Examples

## Data we work with
data(fire) # load the Danish fire insurance data
X <- fire

## Determine thresholds for POT method
mean_excess_plot(X[X > 0])
abline(v = 10)
u <- 10 # threshold

## Fit GPD to the excesses (per margin)
fit <- fit_GPD_MLE(X[X > u] - u)
fit$par

## Estimate threshold exceedance probabilities
p.exceed <- mean(X > u)

## Define corresponding densities, distribution function and RNG
dF <- function(x) dGPDtail(x, threshold = u, p.exceed = p.exceed,
                           shape = fit$par["shape"], scale = fit$par["scale"])
pF <- function(q) pGPDtail(q, threshold = u, p.exceed = p.exceed,
                           shape = fit$par["shape"], scale = fit$par["scale"])
rF <- function(n) rGPDtail(n, threshold = u, p.exceed = p.exceed,
                           shape = fit$par["shape"], scale = fit$par["scale"])

## Basic check of dF()
curve(dF, from = 8, to = 20)
abline(v = u, lty = 2) # threshold

## Basic check of pF()
curve(pF, from = u, to = 20, ylim = 0:1) # quite flat here
abline(v = u, h = 1-p.exceed, lty = 2) # mass at u is 1-p.exceed (see 'Details')

## Basic check of rF()
set.seed(271)
X. <- rF(1000)
plot(X.)
stopifnot(all.equal(mean(X. == u), 1-p.exceed, tol = 5e-3)) # confirms the above
## Pick out 'continuous part'
X.. <- X.[X. > u]
plot(pF(X..)) # should be U[1-p.exceed, 1]

[Package qrmtools version 0.0-10 Index]