GeneralizedPareto | R Documentation |
Density, distribution function, quantile function and random generation for
the generalized pareto distribution with location equal to location
,
scale equal to scale
and shape equal to shape
.
dgpd(x, location = 0, scale = 1, shape = 0, log = FALSE)
pgpd(q, location = 0, scale = 1, shape = 0, lower.tail = TRUE, log.p = FALSE)
qgpd(p, location = 0, scale = 1, shape = 0, lower.tail = TRUE, log.p = FALSE)
rgpd(n, location = 0, scale = 1, shape = 0)
x , q |
vector of quantiles. |
p |
vector of probabilities. |
n |
number of observations. If |
location |
vector of locations. |
scale |
vector of scale. |
shape |
vector of shapes. |
log , log.p |
logical; if TRUE, probabilities p are given as log(p). |
lower.tail |
logical; if TRUE (default), probabilities are
|
If location
, scale
or shape
are not specified they
assume the default values of 0
, 1
and 0
, respectively.
The generalized pareto distribution with location \mu
, scale
\sigma > 0
and shape \xi
has density
f(s) = \frac{1}{\sigma} (1 + \xi s)^{-(1 + 1/\xi)}
for s \ge 0
when \xi \ge 0
, and for
0 \le s \le -1/\xi
when \xi < 0
, where
s = \frac{(x - \mu)}{\sigma}
. In the limit
\xi → 0
, the density simplifies to
f(s) = \frac{1}{\sigma} \exp(-s)
dgpd
gives the density, pgpd
gives the distribution function,
qgpd
gives the quantile function, and rgpd
generates random
deviates.
The length of the result is determined by n
for rgpd
, and is
the maximum of the lengths of the numerical arguments for the other
functions.
The numerical arguments other than n
are recycled to the length of the
result. Only the first elements of the logical arguments are used.
For scale = 0
this gives the limit as \sigma
decreases to 0, a
point mass at \mu
. scale < 0
is an error and returns NaN
.
scales <- c( 1, 1, 1, 2, 2, 2)
shapes <- c( 1, 5, 20, 1, 5, 20)
legend.text <- as.expression(essentials::plapply(list(scales, shapes),
function(scale, shape) {
call("list",
call("==", as.symbol("sigma"), scale),
call("==", as.symbol("xi"), shape))
}))
cols <- c("red", "green3", "blue", "red", "green3", "blue")
ltys <- c("solid", "solid", "solid", "dashed", "dashed", "dashed")
x <- seq.int(0, 5, length.out = 1001)
# we use plapply here instead of lapply because
# plapply allows us to name the looping arguments
ys <- essentials::plapply(
list(scale = scales, shape = shapes),
essentials::dgpd,
x = x
)
graphics::par(mar = c(4.9, 4.5, 2.1, 0.4))
graphics::plot(
xlim = range(x), ylim = range(ys),
panel.first = graphics::grid(col = "gray69"),
x = NA_real_, y = NA_real_,
xlab = "x", ylab = ~f(list(x, mu, sigma, xi)),
main = "Probability density function",
bty = "L"
)
essentials::mfor(y, col, lty, list(ys, cols, ltys), {
graphics::lines(x, y, col = col, lty = lty, lwd = 2)
})
graphics::legend(
x = "topright",
legend = legend.text,
col = cols,
lwd = 2,
lty = ltys,
bty = "n"
)
graphics::title(sub = ~"All with" ~ mu == 0, adj = 1)
ys <- essentials::plapply(
list(scale = scales, shape = shapes),
essentials::pgpd,
q = x
)
graphics::plot(
xlim = range(x), ylim = c(0, 1),
panel.first = graphics::grid(col = "gray69"),
x = NA_real_, y = NA_real_,
xlab = "x", ylab = ~F(list(x, mu, sigma, xi)),
main = "Cumulative probability function",
bty = "L"
)
essentials::mfor(y, col, lty, list(ys, cols, ltys), {
graphics::lines(x, y, col = col, lty = lty, lwd = 2)
})
graphics::legend(
x = "topleft",
legend = legend.text,
col = cols,
lwd = 2,
lty = ltys,
bty = "n"
)
graphics::title(sub = ~"All with" ~ mu == 0, adj = 1)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.