robustcov
statistics: sig = robustcov (X)
statistics: [sig, mu] = robustcov (X)
statistics: [sig, mu, mah] = robustcov (X)
statistics: [sig, mu, mah, outliers] = robustcov (X)
statistics: [sig, mu, mah, outliers, s] = robustcov (X)
statistics: […] = robustcov (…, name, value)
Robust multivariate covariance and mean estimate.
sig = robustcov (X) returns a robust estimate sig of
the covariance matrix of the data matrix X, computed so that
it is not distorted by outlying observations. Rows of X are
observations and columns are variables. Rows containing NaN values
are removed.
[sig, mu, mah, outliers, s] = robustcov
(…) also returns the robust mean mu (), the robust
Mahalanobis distances mah () of each observation from the
estimated distribution, a logical vector outliers () flagging
observations whose distance exceeds sqrt (chi2inv (0.975, P)),
and a structure s holding the estimate metadata.
Additional parameters can be specified by Name-Value pair arguments.
| Name | Value |
|---|---|
'Method' | the estimator, either 'fmcd' (default,
the Fast Minimum Covariance Determinant algorithm) or 'ogk' (the
Orthogonalized Gnanadesikan-Kettenring estimator). 'olivehawkins' is
not implemented. |
'OutlierFraction' | the maximum fraction of outliers, a
scalar in (default 0.5), used to set the size of the
elemental subsets in 'fmcd'. |
'NumTrials' | the number of random elemental subsets drawn
by 'fmcd', a positive integer (default 500). |
'BiasCorrection' | a logical scalar (default true)
that applies the small-sample bias correction to the 'fmcd' estimate. |
'NumOGKIterations' | the number of orthogonalization
iterations for 'ogk', a positive integer (default 2). |
'UnivariateEstimator' | the robust univariate
location/scale estimator used by 'ogk', either 'tauscale'
(default) or 'qn'. |
Source Code: robustcov
Note on reproducibility. 'fmcd' draws random subsets, so its
exact estimate depends on the random number generator and is not identical to
MATLAB’s on data where the optimal subset is ambiguous; on well-separated
data both converge to the same estimate. For 'fmcd' with
'BiasCorrection' enabled, the small-sample factor uses the published
Pison-Van Aelst-Willems asymptotic formula, which differs from MATLAB’s
tabulated simulation values by up to about 1.6% for very small samples.
See also: mahal, cov, mad, dbscan
Source Code: robustcov
Robust covariance is unaffected by a cluster of outliers.
X = [randn(80,2); 8 + randn(10,2)]; [sig, mu, mah, outliers] = robustcov (X);
gscatter (X(:,1), X(:,2), outliers);
error: Invalid call to legend. Correct usage is:
-- legend ()
-- legend COMMAND
-- legend (STR1, STR2, ...)
-- legend (CHARMAT)
-- legend ({CELLSTR})
-- legend (..., PROPERTY, VALUE, ...)
-- legend (HOBJS, ...)
-- legend ("COMMAND")
-- legend (HAX, ...)
-- legend (HLEG, ...)
-- HLEG = legend (...)
title ("robustcov: inliers vs. flagged outliers");