bagplot2: bagplot

View source: R/archive/bagplot0.R

bagplot2R Documentation

bagplot

Description

A non-ggplot2 bagplot based on mrfDepth::bagplot.

Usage

bagplot2(
  x,
  y = NULL,
  colorbag = NULL,
  colorloop = NULL,
  colorchull = NULL,
  databag = TRUE,
  dataloop = TRUE,
  plot.fence = FALSE,
  type = "hdepth",
  sizesubset = 500,
  extra.directions = FALSE,
  options = NULL,
  ...
)

Arguments

x, y

the x and y arguments provide the x and y coordinates for the bagplot. Any reasonable way of defining the coordinates is acceptable. See the function xy.coords for details. If supplied separately, they must be of the same length.

colorbag

The color of the bag (which contains the 50% observations with largest depth).

colorloop

The color of the loop (which contains the regular observations).

colorchull

When the bagplot is based on halfspace depth, the depth region with maximal depth is plotted. This argument controls its color.

databag

Logical indicating whether data points inside the bag need to be plotted.
Defaults to TRUE.

dataloop

Logical indicating whether data points inside the fence need to be plotted.
Defaults to TRUE.

plot.fence

Logical indicating whether the fence should be plotted.
Defaults to FALSE.

type

Determines the depth function used to construct the bagplot: "hdepth" for halfspace depth, "projdepth" for projection depth and "sprojdepth" for skewness-adjusted projection depth.
Defaults to "hdepth".

sizesubset

When computing the bagplot based on halfspace depth, the size of the subset used to perform the main computations. See Details for more information.
Defaults to 500.

extra.directions

Logical indicating whether additional directions should be considered in the computation of the fence for the bagplot based on projection depth or skewness-adjusted projection depth. If set to TRUE an additional 250 equispaced directions are added to the directions defined by the points in x themselves and the center. If FALSE only directions determined by the points in x are considered.
Defaults to FALSE.

options

A list of options to pass to the projdepth or sprojdepth function. In addition the following option may be specified:

  • max.iter
    The maximum number of iterations in the bisection algorithm used to compute the depth contour corresponding to the cutoff. See depthContour for more information.
    Defaults to 100.

...

further parameters given to plot

Details

The bagplot has been proposed by Rousseeuw et al. (1999) as a generalisation of the boxplot to bivariate data. It is constructed based on halfspace depth and as such is invariant under affine transformations. Similar graphical representations can be obtained by means of other depth functions, as illustrated in Hubert and Van der Veeken (2008) and in Hubert et al. (2015). See mrfDepth::compBagplot for more details.

The deepest point is indicated with a "*" sign, the outlying observations with red points.

Value

Invisibly the result of the call to mrfDepth::compBagplot

References

Rousseeuw P.J., Ruts I., Tukey, J.W. (1999). The bagplot: a bivariate boxplot. The American Statistician, 53, 382–387.

Hubert M., Van der Veeken S. (2008). Outlier detection for skewed data. Journal of Chemometrics, 22, 235–246.

Hubert M., Rousseeuw P.J., Segaert, P. (2015). Rejoinder to 'Multivariate functional outlier detection'. Statistical Methods & Applications, 24, 269–277.

See Also

mrfDepth::compBagplot and mrfDepth::bagplot

Examples

bagplot2(iris$Sepal.Length, iris$Sepal.Width)
bagplot2(iris[,1:2])
bagplot2(iris[,3:4], title="Bagplot with Tukey depth", xlab="Petal.Length", ylab="Petal.Width") 
#
library("mrfDepth")
data("bloodfat")
result <- compBagplot(bloodfat)
bagplot(result, colorbag = rgb(0.2,0.2,0.2), colorloop = "green")

sigbertklinke/smvgraph documentation built on Dec. 10, 2022, 9:13 a.m.