Package 'WBI'

Title: Wasserstein Bipolarization Index
Description: Computation of the Wasserstein Bipolarization Index as described in Lee and Sobel (Forthcoming) <doi:10.48550/arXiv.2408.03331>. Provides both asymptotic (Sommerfeld, 2017 <https://ediss.uni-goettingen.de/bitstream/handle/11858/00-1735-0000-0023-3FA1-C/DissertationSommerfeldRev.pdf?sequence=1>) and bootstrap methods (Efron and Narasimhan, 2020 <doi:10.1080/10618600.2020.1714633>) for calculating confidence intervals.
Authors: Hane Lee [aut, cre]
Maintainer: Hane Lee <[email protected]>
License: MIT + file LICENSE
Version: 0.1.0
Built: 2026-05-11 09:09:31 UTC
Source: https://github.com/hanelee/wbi

Help Index


Wasserstein Bipolarization Index

Description

This function takes a vector of observed responses and computes the Wasserstein Bipolarization Index and its asymptotic confidence interval with the maximum polarization distribution (with 0.5 masses each on min and max) as the maximally separated measure.

Usage

WBI(obs, wp, min, max, alpha, wt = rep(c(1/length(obs)), length(obs)))

Arguments

obs

A vector of observed responses.

wp

The order (p) of the p-Wasserstein distance. Use p=1 to only account for spread, p>1 to account for spread and bi-clustering.

min

The minimum of the response scale.

max

The maximum of the response scale.

alpha

Significance level of the confidence interval.

wt

Weight of each observation, with default set to uniform.

Value

A vector of length three containing the CI lower bound, point estimate, and CI upper bound.

Examples

# We want to measure WBI of an opinion item measured on [0,100].
# We choose W2 distance and 95% asymptotic confidence intervals.
data <- c(20, 100, 50, 50, 0,
          90, 85, 10, 25, 10,
          30, 90, 80, 0, 100,
          20, 30, 0, 65, 95)
results <- WBI(data, 2, 0, 100, 0.05)

Wasserstein Bipolarization Index with Bootstrap Confidence Intervals

Description

This function takes a vector of observed responses and computes the Wasserstein Bipolarization Index and its bootstrap confidence interval with the maximum polarization distribution (with 0.5 masses each on min and max) as the maximally separated measure. We use the package bcaboot for bootstrap.

Usage

WBI_boot(obs, wp, min, max, alpha, r = 5000)

Arguments

obs

A vector of observed responses.

wp

The order (p) of the p-Wasserstein distance. Use p=1 to only account for spread, p>1 to account for spread and bi-clustering.

min

The minimum of the response scale.

max

The maximum of the response scale.

alpha

Significance level of the confidence interval.

r

Number of Bootstrap replications

Value

A vector of length three containing the CI lower bound, point estimate, and CI upper bound.

Examples

# We want to measure WBI of an opinion item measured on [0,100].
# We choose W2 distance and 95% bootstrap confidence intervals.
# r=1 for automatic testing (runs quickly)
data <- c(20, 100, 50, 50, 0,
          90, 85, 10, 25, 10,
          30, 90, 80, 0, 100,
          20, 30, 0, 65, 95)
results <- WBI_boot(data, 2, 0, 100, 0.05, r=1)