| GeneralizedExtremeValue | R Documentation |
Density, distribution function, quantile function and random generation for
the generalized extreme value distribution with location equal to
location, scale equal to scale and shape equal to shape.
dgev(x, location = 0, scale = 1, shape = 0, log = FALSE)
pgev(q, location = 0, scale = 1, shape = 0, lower.tail = TRUE, log.p = FALSE)
qgev(p, location = 0, scale = 1, shape = 0, lower.tail = TRUE, log.p = FALSE)
rgev(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 scales. |
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 extreme value distribution with location \mu, scale
\sigma > 0 and shape \xi has density
f(s) = \frac{1}{\sigma} (1 + \xi s)^{-(1 + 1/\xi)} \exp(-(1 + \xi s)^{-1/\xi})
for 1 + \xi s > 0 where s = \frac{(x - \mu)}{\sigma}. In the limit \xi → 0, the density
simplifies to
f(s) = \frac{1}{\sigma} \exp(-s) \exp(-\exp(-s))
dgev gives the density, pgev gives the distribution function,
qgev gives the quantile function, and rgev generates random
deviates.
The length of the result is determined by n for rgev, 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.
shapes <- expression(-1/2, 0, +1/2)
legend.text <- as.expression(lapply(shapes, function(shape) {
call("==", as.symbol("xi"), shape)
}))
shapes <- vapply(shapes, eval, 0)
cols <- c("green3", "red", "blue")
x <- seq.int(-4, 4, length.out = 1001)
# we use plapply here instead of lapply because
# plapply allows us to name the looping arguments
ys <- essentials::plapply(
list(shape = shapes),
essentials::dgev,
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, list(ys, cols), {
graphics::lines(x, y, col = col, lwd = 2)
})
graphics::legend(
x = "topleft",
legend = legend.text,
col = cols,
lwd = 2,
bty = "n"
)
graphics::title(sub = ~"All with" ~ list(mu == 0, sigma == 1), adj = 1)
ys <- essentials::plapply(
list(shape = shapes),
essentials::pgev,
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, list(ys, cols), {
graphics::lines(x, y, col = col, lwd = 2)
})
graphics::legend(
x = "topleft",
legend = legend.text,
col = cols,
lwd = 2,
bty = "n"
)
graphics::title(sub = ~"All with" ~ list(mu == 0, sigma == 1), adj = 1)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.