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 7 data values:
43, 50, 11, 74, 52, 83, 72
Calculate the median absolute deviation of this sample.
Your Answer
You got the correct answer of 29.6516. 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 |
43 |
52 |
-9 | 9 |
50 |
52 |
-2 | 2 |
11 |
52 |
-41 | 41 |
74 |
52 |
22 | 22 |
52 |
52 |
0 | 0 |
83 |
52 |
31 | 31 |
72 |
52 |
20 | 20 |
The table shows steps 2 and 3. Step 4 is to calculate the median of the final column: 20. The final step is to divide this median by 0.6745. Doing so gives the sample median absolute deviation as MAD = 29.6516.
Hide the R Code
Copy and paste the following code into your R script window, then run it from there.
sample = c(43, 50, 11, 74, 52, 83, 72)
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 | | | |
43 |
=MEDIAN(A:A) |
=A2-B2 |
=ABS(C2) |
|
MAD: |
=MEDIAN(D:D)/0.6745 |
50 |
=MEDIAN(A:A) |
=A3-B3 |
=ABS(C3) |
|
|
|
11 |
=MEDIAN(A:A) |
=A4-B4 |
=ABS(C4) |
|
|
|
74 |
=MEDIAN(A:A) |
=A5-B5 |
=ABS(C5) |
|
|
|
52 |
=MEDIAN(A:A) |
=A6-B6 |
=ABS(C6) |
|
|
|
83 |
=MEDIAN(A:A) |
=A7-B7 |
=ABS(C7) |
|
|
|
72 |
=MEDIAN(A:A) |
=A8-B8 |
=ABS(C8) |
|
|
|
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.