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.02918066 0.01815451 0.9855156
#> 2 3.19929082 1.27596435 0.2019681
#> 3 3.48132317 1.35504156 0.1754043
#> 4 1.44504876 0.69744387 0.4855251