Skip to contents

Minimum covariance determinant by C-steps from random starts, then Mahalanobis distances against the robust location and scatter, compared with a chi-squared cutoff.

Usage

morie_mcd_outlier(
  X,
  support_fraction = NULL,
  n_trials = 50,
  alpha = 0.025,
  seed = 0
)

Arguments

X

numeric matrix, one row per observation.

support_fraction

fraction of points in the support h, in (0.5, 1]. Default 0.75.

n_trials

number of random starts.

alpha

tail probability for the chi-squared cutoff.

seed

integer seed. R's generator is not numpy's, so the subsets differ; the fitted location and scatter agree to within sampling noise, and the outlier flags agree.

Value

list with distance, classical_distance, outlier, location, covariance, cutoff.

Details

This exists because of MASKING. The classical covariance is inflated by the very outliers one is hunting, so their classical Mahalanobis distances come out small and they hide themselves. Fitting the covariance on a clean majority subset removes that feedback loop – the returned classical_distance is there to make the difference visible.

References

Rousseeuw, P. J. and Van Driessen, K. (1999). A fast algorithm for the minimum covariance determinant estimator. Technometrics, 41(3), 212-223.

Examples

set.seed(1)
X <- rbind(matrix(rnorm(200), ncol = 2), cbind(rnorm(5, 6), rnorm(5, 6)))
sum(morie_mcd_outlier(X, seed = 1)$outlier)
#> [1] 20