# Masking problem in outlier detection

What is outlier masking as defined by Barnett and Lewis classic "Outliers in Statistical Data"?

Are there any simple or good real-world examples of outlier masking to help elucidate it?

Further, what outlier detection methods are resistant versus susceptible to outlier masking? As an example of this, does Grubb’s test compensate against outlier masking by its iterative approach?

Edit: from the article linked by @Saurabh-Gupta is the following definition of the masking effect (originally from Acuna and Rodriguez (2004)).

Masking effect. It is said that one outlier masks a second outlier, if the second outlier can be considered as an outlier only by itself, but not in the presence of the first outlier. Thus, after the deletion of the first outlier the second instance is emerged as an outlier. Masking occurs when a cluster of outlying observations skews the mean and the covariance estimates toward it, and the resulting distance of the outlying point from the mean is small.

This shows the rationale for the Grubb’s test being iterative, and indeed an example of the value of iterative methods. The value of @Dave’s answer is more subtle. It is not strictly a masking effect by the above definition, but it shows that the standard deviation’s standard error can be large in some situations and this could (for some samples) produce the same effect of masking.

From the same paper (and again originally from Acuna and Rodriguez (2004)), an example of where outliers are “created” from other outliers:

Swamping effect. It is said that one outlier swamps a second observation, if the latter can be considered as an outlier only under the presence of the first one. In other words, after the deletion of the first outlier the second observation becomes a non-outlying observation. Swamping occurs when a group of outlying instances skews the mean and the covariance estimates toward it and away from other non-outlying instances, and the resulting distance from these instances to the mean is large, making them look like outliers

My read of the "masking" comment is that, if you let your measure of scale (e.g. standard deviation) be highly influenced by the outlier(s), it will be harder to detect the outlier(s). Let's look at some R simulations.

set.seed(2020)
B <- 10
dfs <- seq(2.1, 8.1, 0.1)
my_df <- data.frame(dfs=rep(NA, B*length(dfs)), s=rep(NA, B*length(dfs)), iqr=rep(NA, B*length(dfs)))
counter <- 1
for (i in 1:B){
for (j in 1:length(dfs)){

x <- rt(50, dfs[j])
s <- sd(x)
my_iqr = IQR(x)
my_df[counter, ] <- c(dfs[j], s, my_iqr)
counter <- counter + 1
}
}
plot(my_df$$dfs, my_df$$s, main="Standard Deviation")
lines(dfs, sqrt(dfs/(dfs-2)), col='red')

plot(my_df$$dfs, my_df$$iqr, main="Interquartile Range")
lines(dfs, qt(0.75, dfs)-qt(0.25, dfs), col='red')


The points are the empirical standard deviation, given a particular number of degrees of freedom; lower degrees of freedom means a heavy tail. The red line is the population standard deviation for that many degrees of freedom.

When the degrees of freedom are low, look how much higher the empirical standard deviation can be than the population standard deviation, much higher than when the degrees of freedom increase.

This makes it harder to catch an outlier, as the standard deviation can be quite inflated. Compare this to the interquartile range.

The interquartile range is much less erratic.

• There is some good work here. Could I get clarification on why 2.1 was the start of the dfs? The Caucy distribution would be df of one here, so you could have started with anything strictly greater than one? Also, for the first red line (sd) could you explain the $y$ formula? I have also edited the question as am particularly interested in how Barnett and Lewis define masking in "Outliers in Statistical Data". Sep 3, 2020 at 18:49
• @SingleMalt Which $y$ has you confused? // I picked $2.1$ because the $t_2$ distribution has infinite variance (or maybe undefined), so I bumped up the degrees of freedom a tad to get a finite variance.
– Dave
Sep 3, 2020 at 18:58
• Thanks for such a quick reply. I just looked up the t-distribution, I mistakenly thought that the t-distribution had an infinite variance only for $v=1$ that is the Caucy distribution. But now I know that it is infinite for $1 \lt v \le 2$. I also learnt that for $v \gt 2$ the variance is given by $v \div (v - 2)$ which explains the red line formula that I was confused about. Sep 3, 2020 at 19:09

I am assuming that masking is defined as summarised on Page 8 of this book by Irad Ben-Gal available on https://www.researchgate.net/publication/226362876_Outlier_Detection

This is a synthetic example from a grocery transactions data set with 2 variables - sales revenue (in dollars) and sales quantity (units). Each record is a sales transaction. Given the large variety of products in a large format grocery store, a lot of products would cost less than 5 dollars per unit while an outlier could cost more than 100 dollars per unit. The number of units could vary from 1 to 30 in most transactions. Both variables are positively skewed with a long tail of extreme values >> 0 i.e. some transactions could be of more than 5000 dollars while some may have sales quantity of 100+ .

On such a data set, if k-means clustering is applied without centering and scaling, outliers in sales revenue variable can mask sales quantity variable because the Mahalanobis distances will be skewed more by sales revenue than sales quantity. E.g. the following records:

Transaction, Revenue, Qty

1,100,1

2,200,20

3,10,2

4,5,1

5,50,10

6,70,8

7,30,4

8,500,2

• Your example is the classic one (estmated Mahalanobis distance parameters being influenced by outliers) and fits the definition in the paper you referenced (+1). Sep 9, 2020 at 5:32