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 6 data values:
25, 1, 75, 80, 47, 31
Calculate the median absolute deviation of this sample.
Your Answer
You got the correct answer of 37.0645. 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 |
25 |
39 |
-14 | 14 |
1 |
39 |
-38 | 38 |
75 |
39 |
36 | 36 |
80 |
39 |
41 | 41 |
47 |
39 |
8 | 8 |
31 |
39 |
-8 | 8 |
The table shows steps 2 and 3. Step 4 is to calculate the median of the final column: 25. The final step is to divide this median by 0.6745. Doing so gives the sample median absolute deviation as MAD = 37.0645.
Hide the R Code
Copy and paste the following code into your R script window, then run it from there.
sample = c(25, 1, 75, 80, 47, 31)
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 | | | |
25 |
=MEDIAN(A:A) |
=A2-B2 |
=ABS(C2) |
|
MAD: |
=MEDIAN(D:D)/0.6745 |
1 |
=MEDIAN(A:A) |
=A3-B3 |
=ABS(C3) |
|
|
|
75 |
=MEDIAN(A:A) |
=A4-B4 |
=ABS(C4) |
|
|
|
80 |
=MEDIAN(A:A) |
=A5-B5 |
=ABS(C5) |
|
|
|
47 |
=MEDIAN(A:A) |
=A6-B6 |
=ABS(C6) |
|
|
|
31 |
=MEDIAN(A:A) |
=A7-B7 |
=ABS(C7) |
|
|
|
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.