View source: R/plot_robust_pca.R
| plot_outlier_map | R Documentation |
Plots the orthogonal distance of each observation against its score
distance, for a robust PCA fitted by robpca(), rospca(),
macropca() or cellpca() (Hubert, Rousseeuw and Vanden Branden, 2005).
For cellpca(), the vertical axis is the norm of the standardized
residuals, as in the enhanced outlier map of Centofanti, Hubert and
Rousseeuw. For a robust calibration model fitted by rsimpls() or
rpcr(), it is by default
the regression outlier map of Hubert and Vanden Branden (2003): the
residual distance (with one response, the absolute standardized residual)
against the score distance. With map = "score", it is the score outlier
map of the predictors: the orthogonal distance of each spectrum to the
model against its score distance, as for a robust PCA.
plot_outlier_map(
object,
newdata = NULL,
labels = 3,
relative = FALSE,
shade = FALSE,
log = FALSE,
title = NULL,
map = c("regression", "score"),
...,
color_by = c("type", "distance"),
xlab = NULL,
ylab = NULL,
base_size = 11,
point_size = 2.2,
point_alpha = 0.85,
colour_by = deprecated()
)
object |
An object returned by |
newdata |
Optional new observations to add to the map (a numeric
matrix or data frame with the calibration variables). Not available for
the regression outlier map of |
labels |
The number of most outlying observations to label (by their row names, or row numbers). Default is 3; use 0 for no labels. |
relative |
If |
shade |
If |
log |
If |
title |
The plot title. |
map |
For |
... |
Further arguments passed to |
color_by |
The colors of the points: |
xlab, ylab |
The axis titles. Default are the names of the distances. |
base_size |
The size of the text, in points. Default is 11. |
point_size |
The size of the points (default 2.2), or a numeric
vector with one value per sample (the calibration samples, then those
of |
point_alpha |
The opacity of the points, between 0 and 1 (default 0.85). |
colour_by |
The dashed lines are the cut-offs of the two distances. They divide the map into four types of observations:
regular observations (bottom left);
good leverage points (bottom right): far from the center, but close to the PCA subspace, so they follow the structure of the data;
orthogonal outliers (top left): close to the center once projected, but far from the PCA subspace;
bad leverage points (top right): far on both counts, the most harmful outliers.
In the regression outlier map of rsimpls() or rpcr(), the top left
region holds
the vertical outliers: observations with a typical spectrum but a
large residual, such as a wrong reference value. Bad leverage points have
both an outlying spectrum and a large residual; good leverage points have
an outlying spectrum that the model still fits.
New observations (newdata) are projected onto the model with
predict() (or
predict() for the score outlier map of an
rsimpls() or rpcr() fit) and shown with the calibration cut-offs,
which is how new spectra are screened before prediction.
With relative = TRUE, each distance is divided by its cut-off (the
reduced score and orthogonal distances), so both cut-offs are at 1
whatever the model. This puts maps of different models
(for example, with different numbers of components) on the same scale.
A relative distance tells where an observation falls with respect to the
cut-off, not how unlikely it is: twice the cut-off is not equally rare
in every model.
A ggplot object.
Christian L. Goueguel
robpca(), rospca(), macropca(), rsimpls(), rpcr(),
plot_cell_map()
spectra_id <- forageLIBS |> dplyr::select(1:2) |> names()
minerals <- forageLIBS |> dplyr::select(3:14) |> names()
set.seed(1)
fit <- forageLIBS |>
dplyr::select(-dplyr::all_of(c(spectra_id, minerals))) |>
center() |>
robpca()
plot_outlier_map(fit, relative = TRUE, shade = TRUE, log = TRUE)
plot_outlier_map(fit, relative = TRUE, shade = TRUE, log = TRUE,
labels = 10, color_by = "distance", point_alpha = 0.6)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.