GPD2 | R Documentation |
Density, distribution function, quantile function and
random generation for the two-parameter Generalized Pareto
Distribution (GPD) distribution with scale
and
shape
.
dGPD2(x, scale = 1, shape = 0, log = FALSE, deriv = FALSE, hessian = FALSE)
pGPD2(
q,
scale = 1,
shape = 0,
lower.tail = TRUE,
deriv = FALSE,
hessian = FALSE
)
qGPD2(
p,
scale = 1,
shape = 0,
lower.tail = TRUE,
deriv = FALSE,
hessian = FALSE
)
rGPD2(n, scale = 1, shape = 0, array)
x, q |
Vector of quantiles. |
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 |
Let \sigma >0
and \xi
denote the scale and the shape; the
survival function S(x) := \textrm{Pr}[X > x]
is given
for x \geq 0
by
S(x) = \left[1 + \xi x/ \sigma \right]_+^{-1/\xi}
for \xi \neq 0
where v_+ := \max\{v, \, 0\}
and by
S(x) = \exp\{-x/\sigma\}
for \xi = 0
. For x < 0
we have S(x) = 1
:
the support of the distribution is (0,\,\infty(
.
The probability functions d
, p
and q
all
allow each of the two GP parameters to be a vector. Then the
recycling rule is used to get three vectors of the same length,
corresponding to the first argument and to the two GP
parameters. This behaviour is the standard one for the probability
functions of the stats. Note that the provided functions
can be used e.g. to evaluate the quantile with a given
probability for a large number of values of the parameter vector
c(shape, scale)
. This is frequently required in he Bayesian
framework with MCMC inference.
A numeric vector with length equal to the maximum of the
four lengths: that of the first argument and that of the two
parameters scale
and shape
. When deriv
is
TRUE
, the returned value has an attribute named
"gradient"
which is a matrix with n
lines and 2
columns containing the derivatives. A row contains the partial
derivatives of the corresponding element w.r.t. the two parameters
"scale"
and "shape"
in that order.
The attributes "gradient"
and "hessian"
have
dimension c(n, 2)
and c(n, 2, 2)
, even when n
equals 1
. Use the drop
method on these objects to
drop the extra dimension if wanted i.e. to get a gradient vector
and a Hessian matrix.
## Illustrate the effect of recycling rule.
pGPD2(1.0, scale = 1:4, shape = 0.0, lower.tail = FALSE) - exp(-1.0 / (1:4))
pGPD2(1:4, scale = 1:4, shape = 0.0, lower.tail = FALSE) - exp(-1.0)
## With gradient and Hessian.
pGPD2(c(1.1, 1.7), scale = 1, shape = 0, deriv = TRUE, hessian = TRUE)
## simulate 40 paths
ti <- 1:20
names(ti) <- 2000 + ti
y <- rGPD2(n = 40, scale = ti, shape = 0.05)
matplot(ti, y, type = "l", col = "gray", main = "varying scale")
lines(ti, apply(y, 1, mean))
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.