Plots the Hill plot and some its variants.
hillplot(data, orderlim = NULL, tlim = NULL, hill.type = "Hill",
r = 2, x.theta = FALSE, y.alpha = FALSE, alpha = 0.05,
ylim = NULL, legend.loc = "topright",
try.thresh = quantile(data[data > 0], 0.9, na.rm = TRUE),
main = paste(ifelse(x.theta, "Alt", ""), hill.type, " Plot", sep = ""),
xlab = ifelse(x.theta, "theta", "order"),
ylab = paste(ifelse(x.theta, "Alt", ""), hill.type, ifelse(y.alpha,
" alpha", " xi"), ">0", sep = ""), ...)
vector of sample data
vector of (lower, upper) limits of order statistics
to plot estimator, or NULL
to use default values
vector of (lower, upper) limits of range of threshold
to plot estimator, or NULL
to use default values
"Hill" or "SmooHill"
smoothing factor for "SmooHill" (integer > 1)
logical, should order (FALSE
) or theta (TRUE
) be given on x-axis
logical, should shape xi (FALSE
) or tail index alpha (TRUE
) be given on y-axis
significance level over range (0, 1), or NULL
for no CI
y-axis limits or NULL
location of legend (see legend
) or NULL
for no legend
vector of thresholds to consider
title of plot
x-axis label
y-axis label
further arguments to be passed to the plotting functions
hillplot
gives the Hill plot. It also
returns a dataframe containing columns of the order statistics, order, Hill
estimator, it's standard devation and
Thanks to Younes Mouatasim, Risk Dynamics, Brussels for reporting various bugs in these functions.
Produces the Hill, AltHill, SmooHill and AltSmooHill plots, including confidence intervals.
For an ordered iid sequence hill.type="Hill"
.
Once a sufficiently low order statistic is reached the Hill estimator will
be constant, upto sample uncertainty, for regularly varying tails. The Hill
plot is a plot of
These so called Hill's horror plots can be difficult to interpret. A smooth
form of the Hill estimator was suggested by Resnick and Starica (1997):
hill.type="SmooHill"
. The smoothing
factor is r=2
by default.
It has also been suggested to plot the order on a log scale, by plotting
the points x.theta=TRUE
.
The Hill estimator is for the GPD shape y.alpha=FALSE
and the tail index is plotted when y.alpha=TRUE
.
A pre-chosen threshold (or more than one) can be given in
try.thresh
. The estimated parameter (
If no order statistic (or threshold) limits are provided orderlim =
tlim = NULL
then the lowest order statistic is set to
The missing (NA
and NaN
) and non-finite values are ignored.
Non-positive data are ignored.
The lower x-axis is the order x.theta=FALSE
and x.theta=TRUE
respectively. The upper axis
is for the corresponding threshold.
Hill, B.M. (1975). A simple general approach to inference about the tail of a distribution. Annals of Statistics 13, 331-341.
Resnick, S. and Starica, C. (1997). Smoothing the Hill estimator. Advances in Applied Probability 29, 271-293.
Resnick, S. (1997). Discussion of the Danish Data of Large Fire Insurance Losses. Astin Bulletin 27, 139-151.
# NOT RUN {
# Reproduce graphs from Figure 2.4 of Resnick (1997)
data(danish, package="evir")
par(mfrow = c(2, 2))
# Hill plot
hillplot(danish, y.alpha=TRUE, ylim=c(1.1, 2))
# AltHill plot
hillplot(danish, y.alpha=TRUE, x.theta=TRUE, ylim=c(1.1, 2))
# AltSmooHill plot
hillplot(danish, hill.type="SmooHill", r=3, y.alpha=TRUE, x.theta=TRUE, ylim=c(1.35, 1.85))
# AltHill and AltSmooHill plot (no CI's or legend)
hillout = hillplot(danish, hill.type="SmooHill", r=3, y.alpha=TRUE,
x.theta=TRUE, try.thresh = c(), alpha=NULL, ylim=c(1.1, 2), legend.loc=NULL, lty=2)
n = length(danish)
with(hillout[3:n,], lines(log(ks)/log(n), 1/H, type="s"))
# }
Run the code above in your browser using DataLab