Learn R Programming

cellWise (version 2.5.3)

plot_cellMCD: Draw plots based on the cellwise minimum covariance determinant estimator cellMCD

Description

Function for making plots based on the output of cellMCD.

Usage

plot_cellMCD(cellout, type = "Zres/X", whichvar = NULL,
             horizvar = NULL, vertivar = NULL,  
             hband = NULL, vband = NULL, drawellipse = T,
             opacity = 0.5, identify = FALSE, 
             ids = NULL, labelpoints = T, vlines = FALSE,
             clines = TRUE, main = NULL,
             xlab = NULL, ylab = NULL, xlim = NULL,
             ylim = NULL, cex = 1, cex.main = 1.2, 
             cex.txt = 0.8, cex.lab = 1, line = 2.0)

Value

NULL, unless identify = TRUE. Then a list with components:

  • ids
    the case number(s) that were identified

  • coords
    coordinates of all points in the plot.

Arguments

cellout

output of function cellMCD

type

type of diagnostic plot. Should be one of "index", "Zres/X", "Zres/pred", "X/pred", or "bivariate".

whichvar

number or name of the variable to be plotted. Not applicable when type = "bivariate".

horizvar

number or name of the variable to be plotted on the horizontal axis. Only when type = "bivariate".

vertivar

number or name of the variable to be plotted on the vertical axis. Only when type = "bivariate".

hband

whether to draw a horizontal tolerance band. TRUE or FALSE. NULL yields TRUE when type is "index", "Zres/X", or "Zres/pred".

vband

whether to draw a vertical tolerance band. TRUE or FALSE. NULL yields TRUE when type is "Zres/X" or "Zres/pred".

drawellipse

whether to draw a \(99\)% tolerance ellipse. Only for type = "bivariate".

opacity

opacity of the plotted points: 1 is fully opaque, less is more transparent.

identify

if TRUE, identify cases by mouseclick, then Esc.

ids

vector of case numbers to be emphasized (colored red) in the plot. If NULL or of length zero, none are emphasized.

labelpoints

if TRUE, labels the points in ids by their row name in X.

vlines

for the points in ids, draw dashed vertical lines from their standardized residual to 0 when type is "index", "Zres/X", or "Zres/pred". Draws dashed vertical lines to the diagonal when type = "X/pred". Can be TRUE or FALSE, default is FALSE.

clines

only for type == "bivariate". If TRUE, draws a red connecting line from each point in ids to its imputed point, shown in blue.

main

main title of the plot. If NULL, it is constructed automatically from the arguments.

xlab

overriding label for x-axis, unless NULL.

ylab

overriding label for y-axis, unless NULL.

xlim

overriding limits of horizontal axis.

ylim

overriding limits of vertical axis.

cex

size of plotted points.

cex.main

size of the main title.

cex.lab

size of the axis labels.

cex.txt

size of the point labels.

line

distance of axis labels to their axis.

Author

J. Raymaekers and P.J. Rousseeuw

References

J. Raymaekers and P.J. Rousseeuw (2022). The cellwise MCD estimator, Journal of the American Statistical Association, to appear. tools:::Rd_expr_doi("10.1080/01621459.2023.2267777")(link to open access pdf)

See Also

cellMCD

Examples

Run this code
mu <- rep(0, 3)
Sigma <- diag(3) * 0.5 + 0.5
set.seed(123)
X <- MASS::mvrnorm(1000, mu, Sigma)
X[1:5, 1] <- X[1:5, 1] + 5
X[6:10, 2] <- X[6:10, 2] - 10
X[12, 1:2] <- c(-4,8)
cellMCD.out <- cellMCD(X)
plot_cellMCD(cellMCD.out, type="bivariate", 
             horizvar=1, vertivar=2, ids=c(1:10,12))

# For more examples, we refer to the vignette:
if (FALSE) {
vignette("cellMCD_examples")
}

Run the code above in your browser using DataLab