What is the median absolute deviation? It's the median deviation from the median for a vector of Xs, multiplied by a constant of (usually) 1.4826. What does it look like in research? Well, imagine that you're interested in extraversion in schools. It's the median difference between the extraversion score of each member of the class and the median extraversion across the class, multiplied by the magic number 1.4826.
Working it out is straight forward. You can do it in four steps. First, find the median of a vector of Xs (median classroom extraversion score). Second, subtract this median from each X (each child's extraversion score). Third, find the median of these differences. Fourth, multiply by 1.4826.
It's good to know what the MAD is because it is the foundation of a method of outlier detection that was recently touted as a successor to, and improvement over, the standard deviation method common in psychological research (Leys, Klein, Bernard, & Licata, 2013). All you need to do after you have median standard deviation is to multiply it by 2, 2.5, or 3. Depending on how conservative you're feeling. Then add and subtract the resulting value from the median. Any Xs falling outside of this window are outliers.
In a flash report published in JESP, Leys and colleagues argue that the MAD method should be preferred to the standard deviation method. This is because the detection of outliers in the standard deviation method is heavily influenced by the presence of outliers. So using it is a bit like installing a fire alarm in your kitchen whose ability to detect a fire decreases substantially as the number of separate fires in the room increases. Which doesn't sound like a good idea.
My analogy not theirs. And I'm not even sure it's a good one, but I'll go with it for lack of any better ideas.
My analogy not theirs. And I'm not even sure it's a good one, but I'll go with it for lack of any better ideas.
Here's the paper.
Leys, C., Klein,
O., Bernard, P., & Licata, L. (2013). Detectingoutliers: Do not use standard deviation around the mean, use absolute deviationaround the median. Journal ofExperimental Social Psychology, 49, 764-766. http://dx.doi.org/10.1016/j.jesp.2013.03.013
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#apply median absolute deviation method of outlier detection | |
#for computational example provided in Ley et al. (2013) | |
#Ley, C., Klein, O., Bernard, P., & Licata, L. (2013). Detecting outliers: Do not use standard deviation around the mean, use absolute deviation around the median. | |
#Journal of Experimental Social Psychology, 49, 764-766. http://dx.doi.org/10.1016/j.jesp.2013.03.013 | |
#get targetted vector (a) | |
a <- c(1, 3, 3, 6, 8, 10, 10, 1000) #change this to another vector, or a column of a data frame, to apply to your own data | |
#find median | |
med <- median(a) | |
#subtract median from Xs | |
medsub <- (a-med) | |
#make positive | |
medsubpos <- abs(medsub) | |
#find median deviation | |
meddev <- median(medsubpos) | |
#multiply by 1.4826 | |
meddev1 <- meddev*1.4826 | |
#multiply this by 2, 2.5, or 3 to find decision criterion | |
#--- CHOOSE ONE ---- | |
#3 in example | |
cutoff <- meddev1*2 | |
cutoff <- meddev1*2.5 | |
cutoff <- meddev1*3 #this one in example | |
#locutoff | |
LC <- med - cutoff | |
#hicutoff | |
HC <- med + cutoff | |
#find distance from decision criterion (p.3) #191.36 for 1000 | |
distance <- (a-med)/meddev1 | |
#put above information in to a data frame | |
dfoutlier <- data.frame(a = a, medsub = medsub, meddev = meddev, LC = LC, HC = HC, distance = distance) | |
round(dfoutlier,3) | |
#take outlier out and put in to new data frame (change value in accordance with chosen decision criterion) | |
df1 <- subset.data.frame(dfoutlier, distance > 3) | |
#take out the outliers from data set and create new data frame | |
df2 <- subset.data.frame (dfoutlier, distance < 3) | |