adm: Mean Absolute Deviation from the Median or Mean

View source: R/adm.R

admR Documentation

Mean Absolute Deviation from the Median or Mean

Description

Compute the mean absolute deviation from the median, also known as the average deviation to the median (ADM) and (by default) adjust by a factor for asymptotically normal consistency.

Usage

adm(x, center = NULL, constant = NULL, na.rm = FALSE)

Arguments

x

numeric; A vector of values.

center

optional; The central value from which to measure the average distance. It can either be a scalar numeric value or a function on x returning a single numeric value. Defaults to the median of x.

constant

numeric; A scale factor for asymptotic normality. When NULL, it defaults to \sqrt{\frac{\pi}{2}}.

na.rm

logical; If TRUE then NA values are stripped from x before computation takes place.

Details

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.

The ADM is 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, assuming the Gaussian distribution, the mean absolute deviation from the median approaches \sqrt{\frac{2}{\pi}}, the same value as the mean absolute deviation from the mean (Pham-Gia & Hung 2001). This latter statistic may be returned by passing center = mean(x) in the function call, where x is whatever is being passed in the first position.

Given the asymptotic behavior, the default is to multiple the results by the reciprocal—\sqrt{\frac{\pi}{2}}. 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.

Value

A numeric value representing the average absolute deviation from the requested central tendency adjusted by the constant.

Author(s)

Avraham Adler Avraham.Adler@gmail.com

References

Nair, K. R. (1947) A Note on the Mean Deviation from the Median. Biometrika, 34, 3/4, 360–362. \Sexpr[results=rd]{tools:::Rd_expr_doi("10.2307/2332448")}

Pham-Gia, T. and Hung, T. L. (2001) "The mean and median absolute deviations," Mathematical and Computer Modelling, 34 (7–8), 921–936. \Sexpr[results=rd]{tools:::Rd_expr_doi("10.1016/s0895-7177(01)00109-1")}

See Also

See admn for the small-sample bias-corrected version of this function, mad in stats for the median absolute deviation from the median, and madn for the small-sample bias-corrected version of mad.

Examples

adm(c(1:9))
x <- c(1,2,3,5,7,8)
c(adm(x), adm(x, constant = 1))

revss documentation built on March 18, 2026, 9:06 a.m.