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 |
deriv |
Logical. If |
hessian |
Logical. If |
lower.tail |
Logical; if |
p |
Vector of probabilities. |
n |
Sample size. |
array |
Logical. If |
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))