outlierplot | R Documentation |
This function creates a visual representation of multivariate outliers using a univariate plot.It uses robust covariance estimation methods to identify outliers and provides options for displaying the results through various plotting styles.
outlierplot(
x,
quan = 1/2,
alpha = 0.025,
show.outlier = TRUE,
show.mahal = FALSE
)
x |
A matrix or data frame. |
quan |
A numeric value, between 0.5 and 1, that specifies the amount of observations which are used for MCD estimations. Default is 0.5. |
alpha |
A numeric value specifying the amount of observations used for calculating the adjusted quantile. Default is 0.025. |
show.outlier |
A logical value, if |
show.mahal |
A logical value, if |
The function uses the Minimum Covariance Determinant (MCD) method to compute robust estimates
of location and scatter. It then applies an adaptive reweighting step to further improve
the outlier detection. The results are visualized using ggplot2
, with options to highlight
outliers and/or color-code points based on their Mahalanobis distances.
Depending on the combination of show.outlier
and show.mahal
:
A ggplot
object with outliers highlighted (if show.outlier = TRUE
)
A ggplot
object with Mahalanobis distances color-coded (if show.mahal = TRUE
)
A ggplot
object combining both outlier highlighting and Mahalanobis distance color-coding
(if both show.outlier
and show.mahal
are TRUE
)
A tibble containing standardized scores, outlier flags, and robust multivariate Mahalanobis distances
(if both show.outlier
and show.mahal
are FALSE
)
Christian L. Goueguel
# Load the glass dataset from the chemometrics package
data(glass, package = "chemometrics")
# Basic usage with default parameters
outlierplot(glass)
# Adjust the proportion of observations used for MCD estimation
outlierplot(glass, quan = 0.75)
# Show Mahalanobis distances instead of outlier highlighting
outlierplot(glass, show.outlier = FALSE, show.mahal = TRUE)
# Combine outlier highlighting and Mahalanobis distance color-coding
outlierplot(glass, show.outlier = TRUE, show.mahal = TRUE)
# Return data frame instead of plot
result_df <- outlierplot(glass, show.outlier = FALSE, show.mahal = FALSE)
head(result_df)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.