Computes the mean difference analog (MDA or MNDIF) for a vector of frequencies of categories.
MDA(x, na.rm = TRUE)
x | a vector of frequencies |
---|---|
na.rm | if TRUE, missing values are removed. If FALSE, NA is returned if there is any NA value. |
The value of the MDA statistics, which is normalised (varies between 0 and 1).
According to Wilcox (1973, p. 328), the MDA is 'an analog of the mean difference, a measure of variation that is discussed and used much less frequently than the average deviation or the standard deviation. It is defined as "the average of the differences of all the possible pairs of variate-values, taken regardless of sign"'. The formula for the MDA is: $$1 - \frac{\sum_{i=1}^{k-1} \sum_{j=i+1}^k |f_i - f_j|}{N(K-1)}$$
Wilcox, Allen R. 'Indices of Qualitative Variation and Political Measurement.' The Western Political Quarterly 26, no. 2 (1 June 1973): 325-43. doi:10.2307/446831.
x <- rmultinom(1, 100, rep_len(0.25, 4)) x <- as.vector(t(x)) MDA(x)#> [1] 0.9066667df <- rmultinom(10, 100, rep_len(0.25, 4)) df <- as.data.frame(t(df)) apply(df, 1, MDA)#> [1] 0.8533333 0.7533333 0.8866667 0.8533333 0.8666667 0.9200000 0.9666667 #> [8] 0.8866667 0.8200000 0.8133333