Search code examples
rmediancomputation

Median Absolute Deviation Computation in R


A quite confusing thing is what I got:

The Median Absolute Deviation output of the following vector is

vec = c( -5.665488 ,3.963051, 14.14956, 0, -5.665488)

> mad(vec)
[1] 8.399653

However, if I compute that I got the following value:

Median absolute deviation = 5.665488

which is equal to the value of the computation I have found online as well: http://www.miniwebtool.com/median-absolute-deviation-calculator/

How can the difference between the calculated value of mine and the website and the value of R be explained?


Solution

  • It has to do with the mad function automatically setting the scaling constant as 1.482. If you do

    mad(vec, constant=1)
    

    You get the same output as your other methods