GEV {nieve}R Documentation

Density, Distribution Function, Quantile Function and Random Generation for the Generalized Extreme Value (GEV) Distribution

Description

Density, distribution function, quantile function and random generation for the Generalized Extreme Value (GEV) distribution with parameters loc, scale and shape. The distribution function F(x) = \textrm{Pr}[X \leq x] is given by

F(x) = \exp\left\{-[1 + \xi z]^{-1/\xi}\right\}

when \xi \neq 0 and 1 + \xi z > 0, and by

F(x) = \exp\left\{-e^{-z}\right\}

for \xi =0 where z := (x - \mu) / \sigma in both cases.

Usage

dGEV(
  x,
  loc = 0,
  scale = 1,
  shape = 0,
  log = FALSE,
  deriv = FALSE,
  hessian = FALSE
)

pGEV(q, loc = 0, scale = 1, shape = 0, lower.tail = TRUE, deriv = FALSE)

qGEV(
  p,
  loc = 0,
  scale = 1,
  shape = 0,
  lower.tail = TRUE,
  deriv = FALSE,
  hessian = FALSE
)

rGEV(n, loc = 0, scale = 1, shape = 0, array)

Arguments

x, q

Vector of quantiles.

loc

Location parameter. Numeric vector with suitable length, see Details.

scale

Scale parameter. Numeric vector with suitable length, see Details.

shape

Shape parameter. Numeric vector with suitable length, see Details.

log

Logical; if TRUE, densities p are returned as log(p).

deriv

Logical. If TRUE, the gradient of each computed value w.r.t. the parameter vector is computed, and returned as a "gradient" attribute of the result. This is a numeric array with dimension c(n, 3) where n is the length of the first argument, i.e. x, p or q depending on the function.

hessian

Logical. If TRUE, the Hessian of each computed value w.r.t. the parameter vector is computed, and returned as a "hessian" attribute of the result. This is a numeric array with dimension c(n, 3, 3) where n is the length of the first argument, i.e. x, p or depending on the function.

lower.tail

Logical; if TRUE (default), probabilities are \textrm{Pr}[X \leq x], otherwise, \textrm{Pr}[X>x].

p

Vector of probabilities.

n

Sample size.

array

Logical. If TRUE, the simulated values form a numeric matrix with n columns and np rows where np is the number of GEV parameter values. This number is obtained by recycling the three GEV parameters vectors to a common length, so np is the maximum of the lengths of the parameter vectors loc, scale, shape. This option is useful to cope with so-called non-stationary models with GEV margins. See Examples. The default value is TRUE if any of the vectors loc, scale and shape has length > 1 and FALSE otherwise.

Details

Each of the probability function normally requires two formulas: one for the non-zero shape case \xi \neq 0 and one for the zero-shape case \xi = 0. However the non-zero shape formulas lead to numerical instabilities near \xi = 0, especially for the derivatives w.r.t. \xi. This can create problem in optimization tasks. To avoid this, a Taylor expansion w.r.t. \xi is used for |\xi| < \epsilon for a small positive \epsilon. The expansion has order 2 for the functions (log-density, distribution and quantile), order 1 for their first-order derivatives and order 0 for the second-order derivatives.

For the d, p and q functions, the GEV parameter arguments loc, scale and shape are recycled in the same fashion as the classical R distribution functions in the stats package, see e.g., Normal, GammaDist, ... Let n be the maximum length of the four arguments: x q or p and the GEV parameter arguments, then the four provided vectors are recycled in order to have length n. The returned vector has length n and the attributes "gradient" and "hessian", when computed, are arrays wich dimension: c(1, 3) and c(1, 3, 3).

Value

A numeric vector with length n as described in the Details section. When deriv is TRUE, the returned value has an attribute named "gradient" which is a matrix with n lines and 3 columns containing the derivatives. A row contains the partial derivatives of the corresponding element w.r.t. the three parameters loc scale and shape in that order.

Examples

ti <- 1:10; names(ti) <- 2000 + ti
mu <- 1.0 + 0.1 * ti
## simulate 40 paths
y <- rGEV(n = 40, loc = mu, scale = 1, shape = 0.05)
matplot(ti, y, type = "l", col = "gray")
lines(ti, apply(y, 1, mean))

[Package nieve version 0.1.3 Index]