Compute the mean absolute deviation from the median, and (by default) adjust by a factor for asymptotically normal consistency.
adm(x, center = median(x), constant = sqrt(pi / 2), na.rm = FALSE)
$$ADM = C\frac{1}{n}\sum_{i=1}^n{|x_i - \textrm{center}(x)|}$$
where \(C\) is the consistency constant and center
defaults to
median
.
A numeric vector.
The central value from which to measure the average distance. Defaults to the median.
A scale factor for asymptotic normality defaulting to \(\sqrt{\frac{\pi}{2}}\).
If TRUE
then NA
values are stripped from x
before computation takes place.
Avraham Adler Avraham.Adler@gmail.com
Computes the average distance, as an absolute value, between each observation and the central observation---usually the median. In statistical literature this is also called the mean absolute deviation around the median. Unfortunately, this shares the same acronym as the median absolute deviation (MAD), which is the median equivalent of this function.
General practice is to adjust the factor for asymptotically normal consistency. In large samples this approaches \(\sqrt{\frac{2}{\pi}}\). The default is to multiple the results by the reciprocal. However, it is important to note that this asymptotic behavior may not hold with the smaller sample sizes for which this package is intended.
If na.rm
is TRUE
then NA
values are stripped from x
before computation takes place. If this is not done then an NA
value in
x
will cause mad
to return NA
.
Nair, K. R. (1947) A Note on the Mean Deviation from the Median. Biometrika, 34, 3/4, 360--362. tools:::Rd_expr_doi("10.2307/2332448")
adm(c(1:9))
x <- c(1,2,3,5,7,8)
c(adm(x), adm(x, constant = 1))
Run the code above in your browser using DataLab