dissent: Dissention

View source: R/discrete-summaries.R

dissentR Documentation

Dissention

Description

Dissention, for measuring dispersion in draws from ordinal distributions.

Usage

dissent(x)

## Default S3 method:
dissent(x)

## S3 method for class 'rvar'
dissent(x)

Arguments

x

(multiple options) A vector to be interpreted as draws from an ordinal distribution, such as:

  • A factor

  • A numeric (should be integer or integer-like)

  • An rvar, rvar_factor, or rvar_ordered

Details

Calculates Tastle and Wierman's (2007) dissention measure:

-\sum_{i = 1}^{n} p_i \log_2 \left(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).

Value

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.

References

William J. Tastle, Mark J. Wierman (2007). Consensus and dissention: A measure of ordinal dispersion. International Journal of Approximate Reasoning. 45(3), 531–545. \Sexpr[results=rd]{tools:::Rd_expr_doi("10.1016/j.ijar.2006.06.024")}.

Examples

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)

posterior documentation built on Nov. 2, 2023, 5:56 p.m.