Distance-Distance plot for interval-valued data.
Usage
plot_dist_dist(
class_dist,
class_cutoff = NULL,
class_cutoff_label = NULL,
rob_dist,
rob_cutoff = NULL,
rob_cutoff_label = NULL,
obs_names = NULL,
ggplotly = TRUE,
color_class = NULL,
color_label = NULL,
palette = NULL,
shape_class = NULL,
shape_label = NULL,
label_obs = NULL
)Arguments
- class_dist
A numeric vector containing the classical distances for each observation.
- class_cutoff
Numeric. The cutoff value for the classical distances.
- class_cutoff_label
Character. Label for the classical cutoff. If NULL (default), no legend for the classical cutoff is shown.
- rob_dist
A numeric vector containing the robust distances for each observation.
- rob_cutoff
Numeric. The cutoff value for the robust distances.
- rob_cutoff_label
Character. Label for the robust cutoff. If NULL (default), no legend for the robust cutoff is shown.
- obs_names
A character vector containing the names of the observations. If NULL (default), the names are taken from the names of class_dist.
- ggplotly
Logical. If
TRUE(default), the plot is converted to an interactive plotly::plotly object.- color_class
A vector indicating the color class of each observation. If NULL (default), all points have the same color.
- color_label
Character. Label for the color class. If NULL (default), no legend for the color class is shown.
- palette
A vector with colors for each color class. If NULL (default), default ggplot2::ggplot2 colors are used.
- shape_class
A vector indicating the shape class of each observation. If NULL (default), all points have the same shape.
- shape_label
Character. Label for the shape class. If NULL (default), no legend for the shape class is shown.
- label_obs
A vector with the names of the observations to be labeled in the plot when
ggplotly = FALSE. Default is NULL.
Value
Returns a Distance-Distance plot that displays the classical distances against the robust distances for each observation, highlighting outliers.
Examples
#Create intData object
data(creditcard)
credit_card_int <- creditcard$intData
#Estimate the mean and covariance matrix
credit_card_IMCD<-IMCD(credit_card_int, floor(nrow(credit_card_int)*0.75), "farness", 0.9)
credit_card_outliers <- int_outliers(credit_card_IMCD$robust_dist,
p=credit_card_int@NIVar, cutoff_lvl = 0.9)
#Plot Distance-Distance plot
class_dist <- IMah_dist(credit_card_int, z=rep(1,credit_card_int@NObs))
class_outliers <- int_outliers(class_dist,cutoff = "adjbox",p=p,cutoff_lvl = 1.5)
credit_card_is_outliers <- as.character(credit_card_outliers$is_outlier)
credit_card_is_outliers[credit_card_outliers$is_outlier] <- "Outlier"
credit_card_is_outliers[!credit_card_outliers$is_outlier] <- "Inlier"
plot_dist_dist(class_dist, class_outliers$cutoff_value[2], "1.5 adjusted boxplot",
credit_card_IMCD$robust_dist, credit_card_outliers$cutoff_value, "0.9 farness",
color_class = credit_card_is_outliers, palette = c("grey50", "red"))