Skip to contents

This function computes the *average absolute deviation*, i.e. the mean of the absolute deviations from a central point (median by default).

Usage

AAD(x, i = NULL, na.rm = TRUE, center = NULL)

Arguments

x

(named) numerical vector

i

(optional) numerical vector giving the position in x or character vector matching the names in x. If missing or i = NULL, the entire x is considered for the computation of the score

na.rm

logical, whether to remove NA values from x before computation

center

numerical value, the central point

Value

A numerical value representing the computed measure. A default NA value is returned if the score can't be computed.

References

https://en.wikipedia.org/wiki/Average_absolute_deviation

Author

Alessandro Barberis

Examples

x = c(2,2,3,4,14)
AAD(x = x, center = median(x))#2.8
#> [1] 2.8
AAD(x = x, center = mean(x))#3.6
#> [1] 3.6
AAD(x = x, center = modalValue(x))#3.0
#> [1] 3