Skip to contents

Detect multivariante outliers using Mahalanobis distance using mean and covariance estimated either with standard or robust methods.

Usage

outlier(data, robust = FALSE, ...)

Arguments

data

matrix of data

robust

use robust covariance method, defaults to FALSE

...

arguments passed to MASS::cov.rob()

Value

data.frame storing chisq and z-score for each entry indicating deviation from the mean. The z-score is computed by evaluating the p-value of chisq statistic and converting it into a z-score

Details

The distance follow a chisq distrubtion under the null with standard method for mean and covariance. It is approximate if the robust method is used. So use qchisq(p = 0.999 , df = k) to get cutoff to keep 99.9% of samples under the null for data with k=2 columns.

Examples

data <- matrix(rnorm(200), 100, 2)

res <- outlier(data)

res[1:4,]
#>       chisq          z     pValue
#> 1 0.5763730 0.31913811 0.74962179
#> 2 0.1061898 0.06485432 0.94828999
#> 3 5.9415468 1.94926616 0.05126365
#> 4 2.9502180 1.20357523 0.22875380