tlim: vector of (lower, upper) limits of range of threshold to plot MRL, or NULL to use default values
nt: number of thresholds for which to evaluate MRL
p.or.n: logical, should tail fraction (FALSE) or number of exceedances (TRUE) be given on upper x-axis
alpha: significance level over range (0, 1), or NULL for no CI
ylim: y-axis limits or NULL
legend.loc: location of legend (see legend) or NULL for no legend
try.thresh: vector of thresholds to consider
main: title of plot
xlab: x-axis label
ylab: y-axis label
...: further arguments to be passed to the plotting functions
Returns
mrlplot gives the mean residual life plot. It also returns a matrix containing columns of the threshold, number of exceedances, mean excess, standard devation of excesses and 100(1−α)% confidence interval if requested. The standard deviation and confidence interval are NA for less than 5 exceedances.
Details
Plots the sample mean residual life plot, which is also known as the mean excess plot.
If the generalised Pareto distribution (GPD) is an appropriate model for the excesses X−u
above u then their expected value is:
E(X−u∣X>u)=σu/(1−ξ).
For any higher threshold v>u the expected value is
E(X−v∣X>v)=[σu+ξ∗(v−u)]/(1−ξ)
which is linear in higher thresholds v with intercept given by [σu−ξ∗u]/(1−ξ)
and gradient ξ/(1−ξ). The estimated mean residual life above a threshold v is given by the sample mean excess mean(x[x > v]) - v.
Symmetric CLT based confidence intervals are provided, provided there are at least 5 exceedances. The sampling density for the MRL is shown by a greyscale image, where lighter greys indicate low density.
A pre-chosen threshold (or more than one) can be given in try.thresh. The GPD is fitted to the excesses using maximum likelihood estimation. The estimated parameters are used to plot the linear function for all higher thresholds using a solid line. The threshold should set as low as possible, so a dashed line is shown below the pre-chosen threshold. If the MRL is similar to the dashed line then a lower threshold may be chosen.
If no threshold limits are provided tlim = NULL then the lowest threshold is set to be just below the median data point and the maximum threshold is set to the 6th largest datapoint.
The range of permitted thresholds is just below the minimum datapoint and the second largest value. If there are less unique values of data within the threshold range than the number of threshold evalations requested, then instead of a sequence of thresholds the MRL will be evaluated at each unique datapoint.
The missing (NA and NaN) and non-finite values are ignored.
The lower x-axis is the threshold and an upper axis either gives the number of exceedances (p.or.n = FALSE) or proportion of excess (p.or.n = TRUE). Note that unlike the gpd related functions the missing values are ignored, so do not add to the lower tail fraction. But ignoring the missing values is consistent with all the other mixture model functions.
Note
If the user specifies the threshold range, the thresholds above the second largest are dropped. A warning message is given if any thresholds have at most 5 exceedances, in which case the confidence interval is not calculated as it is unreliable due to small sample. If there are less than 10 exceedances of the minimum threshold then the function will stop.
Error checking of the inputs (e.g. invalid probabilities) is carried out and will either stop or give warning message as appropriate.
Acknowledgments
Based on the mrlplot function in the evd package for which Stuart Coles' and Alec Stephenson's contributions are gratefully acknowledged. They are designed to have similar syntax and functionality to simplify the transition for users of these packages.
Scarrott, C.J. and MacDonald, A. (2012). A review of extreme value threshold estimation and uncertainty quantification. REVSTAT - Statistical Journal 10(1), 33-59. Available from http://www.ine.pt/revstat/pdf/rs120102.pdf
Coles S.G. (2004). An Introduction to the Statistical Modelling of Extreme Values. Springer-Verlag: London.