# tailPlot: Tail Plot Functions In DistributionUtils: Distribution Utilities

## Description

Create a left or right tail plot of a data set using tailPlot. Add a line for any distribution with parameters given by an argument named param, using tailPlotLine. Add normal, t, or gamma distribution lines to the plot using normTailPlotLine, tTailPlotLine, or gammaTailPlotLine

## Usage

 1 2 3 4 5 6 7 tailPlot(x, log = "y", side = c("right", "left"), main = NULL, xlab = NULL, ylab = NULL, ...) tailPlotLine(x, distrFn, param = NULL, side = c("right", "left"), ...) normTailPlotLine(x, mean = 0, sd = 1, side = c("right", "left"), ...) tTailPlotLine(x, df = Inf, side = c("right", "left"), ...) gammaTailPlotLine(x, shape = 1, rate = 1, scale = 1/rate, side = c("right", "left"), ...)

## Arguments

 x A vector of values for which the tail plot is to be drawn. log A character string which contains "x" if the x-axis is to be logarithmic, "y" if the y-axis is to be logarithmic and "xy" or "yx" if both axes are to be logarithmic. side Character. "right" (the default) for a tail plot of the right-hand tail, "left" for a tail plot of the left-hand tail. main A main title for the plot. xlab A label for the x axis, defaults to NULL. ylab A label for the y axis, defaults to NULL. distrFn Character. The name of the distribution function to be to be added to the tail plot. param Vector specifying the parameters of the distribution, defaults to NULL. mean The mean of the normal distribution. sd The standard deviation of the normal distribution. Must be positive. df The degrees of freedom of the t-distribution, (> 0, may be non-integer). Defaults to Inf, corresponding to the standard normal distribution. shape The shape parameter of the gamma distribution. Must be positive. scale The scale parameter of the gamma distribution. Must be strictly positive, scale strictly. rate The rate parameter of the gamma distribution. An alternative way to specify the scale. ... Other graphical parameters (see par.

## Details

tailPlot draws either a left-hand or right-hand tail plot of the data x. See for example Resnick (2007), p.105. The left-hand tail plot plots the empirical distribution of the data against the order statistics, for order statistic values below the median. The right-hand tail plot plots one minus the empirical distribution of the data against the order statistics, for order statistic values above the median. The default is for the y-axis to be plotted on a log scale.

tailPlotLine adds a line for the specified distribution to an already drawn tail plot. The distribution can be any distribution which has default parameters, but if parameters need to be supplied the distribution must have an argument param which specifies the parameters. This is the case for all distributions in the form recommended in Scott et al (2009) and includes distributions from the packages GeneralizedHyperbolic, SkewHyperbolic, VarianceGamma and NormalLaplace (which is on R-Forge).

normTailPlotLine,tTailPlotLine and gammaTailPlotLine add the corresponding line derived respectively from the given normal, t, or gamma distribution to an already drawn tail plot.

## Value

Returns NULL invisibly.

## Author(s)

David Scott [email protected]

## References

Aas, Kjersti and Hob<e6>k Haff, Ingrid (2006) The generalised hyperbolic skew Student's t-distribution. Journal of Financial Econometrics, 4, 275–309.

Resnick, S. (2007) Heavy-Tail Phenomena, New York: Springer.

Scott, David J. and W<fc>rtz, Diethelm and Dong, Christine (2009) Software for Distributions in R. UseR: The R User Conference 2009 http://www.agrocampus-ouest.fr/math/useR-2009/slides/Scott+Wuertz+Dong.pdf

## Examples

 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 ### Draw tail plot of some data x <- rnorm(100, 1, 2) tailPlot(x) ### Add normal distribution line normTailPlotLine(x, mean = 1, sd = 2) ### Add t distribution line tTailPlotLine(x, df = 5, lty = 2) ### Use fitted values normTailPlotLine(x, mean = mean(x), sd = sd(x), lty = 3) ### Gamma distribution x <- rgamma(100, shape = 1, scale = 1) tailPlot(x) ### Add gamma distribution line gammaTailPlotLine(x, shape = 1, scale = 1) ### Left tail example tailPlot(x, side = "l") ### Add gamma distribution line gammaTailPlotLine(x, shape = 1, scale = 1, side = "l") ### Log scale on both axes tailPlot(x, side = "l", log = "xy") ### Add gamma distribution line gammaTailPlotLine(x, shape = 1, scale = 1, side = "l") ### Add line from a standard distribution with default parameters x <- rlnorm(100) tailPlot(x) tailPlotLine(x, distrFn = "lnorm") ### Add line from a distribution with 'param' argument require(VarianceGamma) param <- c(0,0.5,0,0.5) x <- rvg(100, param = param) tailPlot(x) tailPlotLine(x, distrFn = "vg", param = param)

DistributionUtils documentation built on May 31, 2017, 4:18 a.m.