| 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 |
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).
diva(x, search = FALSE, algorithm = "quick", lambda = 0.5, verbose = FALSE)diva(x, search = FALSE, algorithm = "quick", lambda = 0.5, verbose = FALSE)
x |
A numeric matrix of preference-approvals with |
search |
Logical; if |
algorithm |
Branch-and-bound or heuristic algorithm used by
|
lambda |
Weight in |
verbose |
Logical; if |
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.
An object of class "diva": a list with components
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.
The minimised average distance.
A difftime with the computing time.
The arguments used.
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
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_lambdax <- 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
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.
diva_sensitivity( x, search = FALSE, algorithm = "quick", lambda = seq(0, 1, by = 0.1), verbose = FALSE )diva_sensitivity( x, search = FALSE, algorithm = "quick", lambda = seq(0, 1, by = 0.1), verbose = FALSE )
x |
A numeric matrix of preference-approvals with |
search |
Logical; if |
algorithm |
Algorithm used by |
lambda |
Numeric vector of weights in |
verbose |
Logical; if |
A list with components d_lambda (named numeric vector of the
minimised average distances, one per value of lambda) and
lambda (the grid used).
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_lambdax <- 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
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.
find_approval(ranking)find_approval(ranking)
ranking |
A numeric vector with the positions of the alternatives in the ranking (ties allowed). |
A data frame with columns and (buckets + 1) rows,
where buckets is the number of distinct positions in ranking.
The first columns repeat the ranking and the last columns
hold the admissible approval vectors (from "approve none" to "approve all").
find_approval(c(1, 2, 2, 3))find_approval(c(1, 2, 2, 3))
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).
formula1_1950formula1_1950
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.
PrefLib (https://preflib.github.io/PrefLib-Jekyll/); processed in the replication material of Albano and Romano (2026).
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
data(formula1_1950) dim(formula1_1950)data(formula1_1950) dim(formula1_1950)
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.
french_election_2002french_election_2002
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.
Erdamar et al. (2014) and the replication material of Albano and
Romano (2026); original survey data file 00029-00000001.dat.
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
data(french_election_2002) dim(french_election_2002) diva(french_election_2002, algorithm = "quick")data(french_election_2002) dim(french_election_2002) diva(french_election_2002, algorithm = "quick")
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.
is_consistent(ranking, approval)is_consistent(ranking, approval)
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 |
A single logical value: TRUE if the pair is a valid
preference-approval, FALSE otherwise.
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
is_consistent(c(1, 2, 3, 4), c(1, 1, 0, 0)) is_consistent(c(1, 2, 3, 4), c(0, 1, 0, 0))is_consistent(c(1, 2, 3, 4), c(1, 1, 0, 0)) is_consistent(c(1, 2, 3, 4), c(0, 1, 0, 0))
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.
pa_smallpa_small
A numeric matrix with 8 columns. The first 4 columns are the
ranking component and the last 4 columns the approval component.
data(pa_small) head(pa_small)data(pa_small) head(pa_small)
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).
pa_universe(n, verbose = FALSE)pa_universe(n, verbose = FALSE)
n |
Number of alternatives. The size of the universe grows very quickly
with |
verbose |
Logical; if |
A data frame with columns, one row per preference-approval.
The first columns are the ranking component and the last the
approval component.
u <- pa_universe(3) head(u) nrow(u)u <- pa_universe(3) head(u) nrow(u)
Computes the family of distances 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.
pref_dist(x, y = NULL, lambda = 0.5)pref_dist(x, y = NULL, lambda = 0.5)
x |
A numeric matrix (or vector) of preference-approvals with |
y |
An optional second set of preference-approvals in the same format.
If |
lambda |
Weight in |
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.
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
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)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)