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
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.
Aas, Kjersti and Hob<c3><a6>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.
### 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)
Results
R version 3.3.1 (2016-06-21) -- "Bug in Your Hair"
Copyright (C) 2016 The R Foundation for Statistical Computing
Platform: x86_64-pc-linux-gnu (64-bit)
R is free software and comes with ABSOLUTELY NO WARRANTY.
You are welcome to redistribute it under certain conditions.
Type 'license()' or 'licence()' for distribution details.
R is a collaborative project with many contributors.
Type 'contributors()' for more information and
'citation()' on how to cite R or R packages in publications.
Type 'demo()' for some demos, 'help()' for on-line help, or
'help.start()' for an HTML browser interface to help.
Type 'q()' to quit R.
> library(DistributionUtils)
Loading required package: RUnit
> png(filename="/home/ddbj/snapshot/RGM3/R_CC/result/DistributionUtils/tailPlot.Rd_%03d_medium.png", width=480, height=480)
> ### Name: tailPlot
> ### Title: Tail Plot Functions
> ### Aliases: tailPlot tailPlotLine normTailPlotLine tTailPlotLine
> ### gammaTailPlotLine
> ### Keywords: distribution univar
>
> ### ** Examples
>
> ### 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)
Loading required package: VarianceGamma
Loading required package: GeneralizedHyperbolic
> param <- c(0,0.5,0,0.5)
> x <- rvg(100, param = param)
> tailPlot(x)
> tailPlotLine(x, distrFn = "vg", param = param)
>
>
>
>
>
>
> dev.off()
null device
1
>