dissent {posterior} | R Documentation |
Dissention, for measuring dispersion in draws from ordinal distributions.
dissent(x) ## Default S3 method: dissent(x) ## S3 method for class 'rvar' dissent(x)
x |
(multiple options) A vector to be interpreted as draws from an ordinal distribution, such as:
|
Calculates Tastle and Wierman's (2007) dissention measure:
-∑_{i = 1}^{n} p_i \log_2 ≤ft(1 - \frac{|x_i - \mathrm{E}(x)| }{\max(x) - \min(x)} \right)
This ranges from 0 (all probability in one category) through 0.5 (uniform) to 1 (bimodal: all probability split equally between the first and last category).
If x
is a factor or numeric, returns a length-1 numeric vector with a value
between 0 and 1 (inclusive) giving the dissention of x
.
If x
is an rvar, returns an array of the same shape as x
, where each
cell is the dissention of the draws in the corresponding cell of x
.
William J. Tastle, Mark J. Wierman (2007). Consensus and dissention: A measure of ordinal dispersion. International Journal of Approximate Reasoning. 45(3), 531–545. doi: 10.1016/j.ijar.2006.06.024.
set.seed(1234) levels <- c("lowest", "low", "neutral", "high", "highest") # a bimodal distribution: high dissention x <- ordered( sample(levels, 4000, replace = TRUE, prob = c(0.45, 0.04, 0.02, 0.04, 0.45)), levels = levels ) dissent(x) # a unimodal distribution: low dissention y <- ordered( sample(levels, 4000, replace = TRUE, prob = c(0.95, 0.02, 0.015, 0.01, 0.005)), levels = levels ) dissent(y) # both together, as an rvar xy <- c(rvar(x), rvar(y)) xy dissent(xy)