The Problem
The median absolute deviation (MAD) is another measure of variability. As it uses the median, it tends to be more resistent to outliers than measures of spread using the mean (like the variance). To illustrate calculating the median absolute deviation, assume that you collected the following 5 data values:
17, 37, 0, 39, 9
Calculate the median absolute deviation of this sample.
Your Answer
You got the correct answer of 25.2039. Congratulations!
Unfortunately, your answer was not correct. Either try again or click on “Show Solution” below to see how to obtain the correct answer.
Assistance
Hide Solution
The sample median absolute deviation is the median absolute deviation from the sample median.
 Calculate the sample median of the data
 Calculate the difference between each data value and the sample median
 Take the absolute value of those differences
 Calculate the median of those absolute values
 Finally, divide that median by 0.6745
The table below shows the schema:
Datum  Median  Deviation  Absolute Deviation 
17 
17 
0  0 
37 
17 
20  20 
0 
17 
17  17 
39 
17 
22  22 
9 
17 
8  8 
The table shows steps 2 and 3. Step 4 is to calculate the median of the final column: 17. The final step is to divide this median by 0.6745. Doing so gives the sample median absolute deviation as MAD = 25.2039.
Hide the R Code
Copy and paste the following code into your R script window, then run it from there.
sample = c(17, 37, 0, 39, 9)
mad(sample)
In the R output, the sample median absolute deviation is the number output by the script.
Hide the Excel Code
Copy and paste the following code into your Excel spreadsheet window, making sure your cursor is in A1
when you paste.
Copy and paste the following code into your Excel spreadsheet window, making sure the value sample1
ends up in A1
after pasting.
How to calculate the expected value in Excel.
sample  median  deviation  absolute deviation    
17 
=MEDIAN(A:A) 
=A2B2 
=ABS(C2) 

MAD: 
=MEDIAN(D:D)/0.6745 
37 
=MEDIAN(A:A) 
=A3B3 
=ABS(C3) 



0 
=MEDIAN(A:A) 
=A4B4 
=ABS(C4) 



39 
=MEDIAN(A:A) 
=A5B5 
=ABS(C5) 



9 
=MEDIAN(A:A) 
=A6B6 
=ABS(C6) 



Note that there is no MAD
function in Excel. The only way to calculate the median absolute deviation is to perform the calculations described in the formula.