Computes the variance analog (VA) for a vector of frequencies of categories.

VA(x, na.rm = TRUE)

Arguments

x

a vector of frequencies

na.rm

if TRUE, missing values are removed. If FALSE, NA is returned if there is any NA value.

Value

The value of the VA statistics, which is normalised (varies between 0 and 1).

Details

According to Wilcox (1973, p. 329), the VA is 'based on the variance, which is defined as the arithmetic mean of the squared differences of each value from the mean'. The formula for the VA is: $$1 - \frac{\sum_{i=1}^k \left(f_i - \frac{N}{K}\right)^2}{\frac{N^2(K-1)}{K}}$$

References

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.

Examples

x <- rmultinom(1, 100, rep_len(0.25, 4)) x <- as.vector(t(x)) VA(x)
#> [1] 0.996
df <- rmultinom(10, 100, rep_len(0.25, 4)) df <- as.data.frame(t(df)) apply(df, 1, VA)
#> [1] 0.9938667 0.9674667 0.9973333 0.9976000 0.9832000 0.9898667 0.9952000 #> [8] 0.9901333 0.9874667 0.9917333