Package 'TheOrdinals'

Title: Aggregation and Consensus Methods for Preference-Approvals
Description: Tools for aggregating ordinal preference data into a group consensus. The package implements DIVA (Divide and Conquer for Preference-Approvals), a distance-based aggregation method for preference-approvals, that is, preference data in which voters express both a (weak) ranking and an approval of the alternatives. The consensus is the preference-approval minimising the average distance to the set of voters, measured through the family of distances of Erdamar, Garcia-Lapresta, Perez-Roman and Sanver (2014) <doi:10.1016/j.mathsocsci.2013.10.005>. Methods and applications are described in Albano and Romano (2026) <doi:10.1007/s11634-025-00663-4>. The package is designed to be extended with further methods for ordinal preference data.
Authors: Maurizio Romano [aut, cre], Alessandro Albano [aut]
Maintainer: Maurizio Romano <[email protected]>
License: GPL-3
Version: 0.1.0
Built: 2026-07-11 10:51:36 UTC
Source: https://github.com/cran/TheOrdinals

Help Index


DIVA consensus for preference-approvals

Description

Computes the DIVA (Divide and Conquer for Preference-Approvals) consensus of a set of preference-approvals. The consensus is the preference-approval that minimises the average distance pref_dist to the set of voters, and it is guaranteed to be admissible (its ranking and approval components are consistent).

Usage

diva(x, search = FALSE, algorithm = "quick", lambda = 0.5, verbose = FALSE)

Arguments

x

A numeric matrix of preference-approvals with 2n2n columns: the first nn columns are the ranking component and the last nn columns the approval component (see TheOrdinals-package).

search

Logical; if TRUE, when the average approval of some alternatives is exactly tied (0.5) all admissible approval completions are explored instead of breaking the tie deterministically. Defaults to FALSE.

algorithm

Branch-and-bound or heuristic algorithm used by consrank to find the consensus ranking. Defaults to "quick"; "decor" is exact for small nn, and "fast" or any other algorithm accepted by consrank may also be used.

lambda

Weight in [0,1][0, 1] given to the ranking component of the distance; the approval component receives weight 1 - lambda. Defaults to 0.5.

verbose

Logical; if TRUE progress messages report which branch produced the solution. Defaults to FALSE.

Details

The algorithm first looks for a direct solution in which the consensus ranking and the consensus approval are already compatible. If none exists, it explores two branches: from the consensus ranking it derives admissible approvals (find_approval), and from the consensus approval it derives admissible rankings by solving the consensus separately within approved and unapproved alternatives. The branch yielding the smaller average distance is returned.

Value

An object of class "diva": a list with components

consensus

Data frame with the consensus preference-approval(s); a ranking component followed by an approval component. More than one row is returned when several solutions are tied.

d_lambda

The minimised average distance.

elapsed

A difftime with the computing time.

lambda, algorithm, search

The arguments used.

References

Albano, A. and Romano, M. (2026). A distance-based aggregation method for finding consensus in preference-approvals. Advances in Data Analysis and Classification. doi:10.1007/s11634-025-00663-4

See Also

diva_sensitivity, pref_dist

Examples

x <- rbind(
  c(1, 2, 3, 4, 1, 1, 0, 0),
  c(2, 1, 3, 4, 1, 0, 0, 0),
  c(1, 2, 4, 3, 1, 1, 0, 0),
  c(1, 3, 2, 4, 1, 1, 1, 0)
)
res <- diva(x, algorithm = "quick")
res
res$d_lambda

Sensitivity of the DIVA consensus to the weighting parameter

Description

Computes the minimised average distance of the DIVA consensus over a grid of values of the weighting parameter lambda, which is useful to assess how the relative weight of the ranking and approval components affects the consensus. Unlike diva, only the achieved distance is returned, not the consensus preference-approval itself.

Usage

diva_sensitivity(
  x,
  search = FALSE,
  algorithm = "quick",
  lambda = seq(0, 1, by = 0.1),
  verbose = FALSE
)

Arguments

x

A numeric matrix of preference-approvals with 2n2n columns: the first nn columns are the ranking component and the last nn columns the approval component (see TheOrdinals-package).

search

Logical; if TRUE, when the average approval of some alternatives is exactly tied (0.5) all admissible approval completions are explored instead of breaking the tie deterministically. Defaults to FALSE.

algorithm

Algorithm used by consrank; defaults to "quick", which is convenient for the repeated evaluations of a sensitivity analysis.

lambda

Numeric vector of weights in [0,1][0, 1] at which to evaluate the consensus distance. Defaults to seq(0, 1, by = 0.1).

verbose

Logical; if TRUE progress messages report which branch produced the solution. Defaults to FALSE.

Value

A list with components d_lambda (named numeric vector of the minimised average distances, one per value of lambda) and lambda (the grid used).

See Also

diva

Examples

x <- rbind(
  c(1, 2, 3, 4, 1, 1, 0, 0),
  c(2, 1, 3, 4, 1, 0, 0, 0),
  c(1, 2, 4, 3, 1, 1, 0, 0),
  c(1, 3, 2, 4, 1, 1, 1, 0)
)
s <- diva_sensitivity(x)
s$d_lambda

Admissible approvals of a ranking

Description

Given a (weak) ranking, enumerates the approval vectors that are consistent with it, i.e. the approval boundaries that can be placed between consecutive buckets of the ranking. The result combines the ranking with each admissible approval, so that every row is a valid preference-approval.

Usage

find_approval(ranking)

Arguments

ranking

A numeric vector with the positions of the alternatives in the ranking (ties allowed).

Value

A data frame with 2n2n columns and (buckets + 1) rows, where buckets is the number of distinct positions in ranking. The first nn columns repeat the ranking and the last nn columns hold the admissible approval vectors (from "approve none" to "approve all").

See Also

pa_universe, is_consistent

Examples

find_approval(c(1, 2, 2, 3))

Formula 1 World Championship (1950) preference-approvals

Description

Preference-approval data built from the 1950 Formula 1 World Championship: the classification of each of the 7 Grands Prix is read as a ranking of the 81 drivers, and the top five finishers of each race are taken as approved. Used as a real-data application in Albano and Romano (2026).

Usage

formula1_1950

Format

A numeric matrix with 7 rows (Grands Prix) and 162 columns. The first 81 columns are the ranking component and the last 81 columns the approval component (1 approved, 0 not). Both blocks are named after the drivers.

Source

PrefLib (https://preflib.github.io/PrefLib-Jekyll/); processed in the replication material of Albano and Romano (2026).

References

Albano, A. and Romano, M. (2026). A distance-based aggregation method for finding consensus in preference-approvals. Advances in Data Analysis and Classification. doi:10.1007/s11634-025-00663-4

Examples

data(formula1_1950)
dim(formula1_1950)

French Presidential Election (2002) preference-approvals

Description

Preference-approval data on the 15 candidates of the first round of the 2002 French presidential election, used as a real-data application in Albano and Romano (2026). Each voter provides a ranking of the candidates together with an approval of a subset of them. Only the admissible preference-approvals (those whose ranking and approval are concordant) are retained.

Usage

french_election_2002

Format

A numeric matrix with one row per voter and 30 columns. The first 15 columns are the ranking component (positions, ties allowed) and the last 15 columns the approval component (1 approved, 0 not). Both blocks of columns are named after the candidates' surnames.

Source

Erdamar et al. (2014) and the replication material of Albano and Romano (2026); original survey data file 00029-00000001.dat.

References

Albano, A. and Romano, M. (2026). A distance-based aggregation method for finding consensus in preference-approvals. Advances in Data Analysis and Classification. doi:10.1007/s11634-025-00663-4

Examples

data(french_election_2002)
dim(french_election_2002)

diva(french_election_2002, algorithm = "quick")

Preference-approval consistency check

Description

Checks whether a ranking and an approval vector form an admissible preference-approval, i.e. whether they satisfy the consistency condition of Definition 1 in Albano and Romano (2026): approved alternatives must be ranked above unapproved ones, and tied alternatives must share the same approval status.

Usage

is_consistent(ranking, approval)

Arguments

ranking

A numeric vector with the positions of the alternatives in the ranking (ties allowed).

approval

A numeric (0/1) vector of the same length as ranking, with 1 for approved and 0 for unapproved alternatives.

Value

A single logical value: TRUE if the pair is a valid preference-approval, FALSE otherwise.

References

Albano, A. and Romano, M. (2026). A distance-based aggregation method for finding consensus in preference-approvals. Advances in Data Analysis and Classification. doi:10.1007/s11634-025-00663-4

Examples

is_consistent(c(1, 2, 3, 4), c(1, 1, 0, 0))
is_consistent(c(1, 2, 3, 4), c(0, 1, 0, 0))

Small synthetic universe of preference-approvals (n = 4)

Description

The complete universe of preference-approvals on four alternatives, generated with pa_universe. Provided as a small, fast example for the documentation and the tests.

Usage

pa_small

Format

A numeric matrix with 8 columns. The first 4 columns are the ranking component and the last 4 columns the approval component.

See Also

pa_universe

Examples

data(pa_small)
head(pa_small)

Universe of preference-approvals

Description

Generates the full set (universe) of preference-approvals on n alternatives, by enumerating every weak order on n items (via univranks) and, for each, all the admissible approval boundaries (via find_approval).

Usage

pa_universe(n, verbose = FALSE)

Arguments

n

Number of alternatives. The size of the universe grows very quickly with n, so values beyond a handful are impractical.

verbose

Logical; if TRUE a message reports the number of preference-approvals generated and the elapsed time. Defaults to FALSE.

Value

A data frame with 2n2n columns, one row per preference-approval. The first nn columns are the ranking component and the last nn the approval component.

See Also

find_approval, diva

Examples

u <- pa_universe(3)
head(u)
nrow(u)

Distance between preference-approvals

Description

Computes the family of distances dλd_\lambda for preference-approvals introduced by Erdamar et al. (2014), a convex combination of the (normalised) Kemeny distance on the ranking component and the (normalised) Hamming distance on the approval component.

Usage

pref_dist(x, y = NULL, lambda = 0.5)

Arguments

x

A numeric matrix (or vector) of preference-approvals with 2n2n columns: the first nn columns are the ranking component and the last nn columns are the approval component (see TheOrdinals-package).

y

An optional second set of preference-approvals in the same format. If NULL (the default) the within-set distance matrix of x is returned.

lambda

Weight in [0,1][0, 1] given to the ranking component; the approval component receives weight 1 - lambda. Defaults to 0.5.

Value

A numeric matrix of distances. When y is NULL it is the nrow(x) by nrow(x) matrix of pairwise distances; otherwise it is the nrow(x) by nrow(y) matrix of distances between the rows of x and the rows of y.

References

Erdamar, B., Garcia-Lapresta, J. L., Perez-Roman, D. and Sanver, M. R. (2014). Measuring consensus in a preference-approval context. Mathematical Social Sciences, 39-46. doi:10.1016/j.mathsocsci.2013.10.005

See Also

diva

Examples

x <- rbind(
  c(1, 2, 3, 4, 1, 1, 0, 0),
  c(2, 1, 3, 4, 1, 0, 0, 0),
  c(1, 2, 4, 3, 1, 1, 0, 0)
)
pref_dist(x)
pref_dist(x, lambda = 0.8)