| robpca | R Documentation |
Robust PCA by the ROBPCA algorithm of Hubert, Rousseeuw and Vanden
Branden (2005), which combines projection pursuit with the minimum
covariance determinant (MCD) estimator. It resists up to n - h outlying
spectra and works when there are more variables than observations. The
computational kernels (outlyingness, FAST-MCD) are written in C++.
robpca(
x,
ncomp = NULL,
ncomp_max = 10,
alpha = 0.75,
ndir = 250,
var_explained = 0.8,
nsamp = 500,
k = deprecated(),
kmax = deprecated()
)
x |
A numeric matrix or data frame, with one observation per row. |
ncomp |
The number of principal components. If |
ncomp_max |
The maximum number of components. Default is 10. |
alpha |
The robustness parameter: the fraction of observations the
estimates are based on, between 0.5 and 1. Default is 0.75. The subset
size is |
ndir |
The number of random directions used for the outlyingness.
Default is 250; use |
var_explained |
The fraction of variance used to choose |
nsamp |
The number of random subsets of FAST-MCD. Default is 500. |
k |
|
kmax |
The algorithm follows the published description:
The data are reduced by a singular value decomposition to the affine
subspace they span (at most n - 1 dimensions).
The Stahel-Donoho outlyingness of every observation is computed over
directions through pairs of observations, using the univariate MCD
location and scale on each direction. The h least outlying
observations form the subset H_0.
The number of components k (ncomp) is chosen (if not given) as
the smallest number that explains var_explained of the variance of
H_0, with at most ncomp_max. Observations whose orthogonal
distance to the k-dimensional PCA subspace of H_0 is below
the cut-off form H_1, and the subspace is re-estimated from
H_1. When ncomp equals the rank of the data, this subspace is the whole space and
H_1 = H_0.
All observations are projected onto this subspace, and the reweighted
FAST-MCD estimator of the scores gives the final center, loadings and
eigenvalues. When ncomp equals the rank, this is the reweighted MCD of the
data.
Each observation then has a score distance (SD), its robust Mahalanobis
distance within the PCA subspace, and an orthogonal distance (OD) to the
subspace. The cut-off for the SD is \sqrt{\chi^2_{k,0.975}}; the
cut-off for the OD uses the Wilson-Hilferty approximation, with the
univariate MCD of OD^{2/3}. When ncomp equals the rank, the ODs and
their cut-off are zero: there are no orthogonal outliers.
plot_outlier_map() plots both distances.
This is an independent implementation of the published algorithm, not a
port of the rospca or rrcov code, so its results can differ slightly from
theirs (random directions and subsets, and small-sample correction
factors, which are not applied here). Use set.seed() for reproducible
results.
An object of class specproc_robpca, a list with:
loadings: p \times k matrix of robust loadings, the largest
element of each loading vector positive.
eigenvalues: robust eigenvalues (variances of the scores).
center: robust center.
scores: n \times k matrix of scores.
sd, od: score and orthogonal distances of each observation.
cutoff_sd, cutoff_od: their cut-offs.
outlier_type: a factor classifying each observation as "regular",
"good leverage" (high SD only), "orthogonal outlier" (high OD only)
or "bad leverage" (both).
ncomp, h, alpha: the settings used.
H0, H1: logical vectors of the observations in the subsets
H_0 and H_1.
Use predict() for the scores and distances of new observations.
Christian L. Goueguel
Hubert, M., Rousseeuw, P.J., Vanden Branden, K. (2005). ROBPCA: a new approach to robust principal component analysis. Technometrics, 47(1):64-79.
Rousseeuw, P.J., Van Driessen, K. (1999). A fast algorithm for the minimum covariance determinant estimator. Technometrics, 41(3):212-223.
rospca() for sparse loadings, macropca() for data with
cellwise outliers or missing values, step_robpca() for a recipe step,
plot_outlier_map().
set.seed(1)
# the 380-430 nm window (Ca II H and K lines)
wl <- suppressWarnings(as.numeric(names(forageLIBS)))
forageLIBS[which(wl > 380 & wl < 430)] |>
center() |>
robpca() |>
print()
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.