condorcet: Condorcet Vote Count

View source: R/condorcet.R

condorcetR Documentation

Condorcet Vote Count

Description

Count votes using the Condorcet voting method.

Usage

condorcet(votes, runoff = FALSE, fsep = '\t', quiet = FALSE, ...)

## S3 method for class 'vote.condorcet'
summary(object, ...)

## S3 method for class 'vote.condorcet'
view(object, ...)

## S3 method for class 'vote.condorcet'
image(x, ...)

Arguments

votes

Matrix or data frame containing the votes. Rows correspond to the votes, columns correspond to the candidates. If it is a character string it is interpreted as a file name from which the votes are to be read. See below for more details.

runoff

Logical. If TRUE and no condorcet winner exists, the election goes into a run-off, see below for details.

fsep

If votes is a file name, this argument gives the column separator in the file.

quiet

If TRUE no output is printed.

object, x

Object of class vote.condorcet.

...

Additional arguments passed to the underlying functions. For the image function, see arguments for image.vote.stv, especially xpref, ypref, all.pref and proportion.

Details

The Condorcet method elects the candidate that wins a majority of the ranked vote in every head-to-head election against each of the other candidates. I.e., the Condorcet winner is a candidate that beats all other candidates in pairwise comparisons. Analogously, a Condorcet loser is a candidate that loses against all other candidates. Neither Condorcet winner nor loser might exist.

If the runoff argument is set to TRUE and no Condorcet winner exists, two or more candidates with the most pairwise wins are selected and the method is applied to such subset. If more than two candidates are in such run-off, the selection is performed repeatedly, until either a winner is selected or no more selection is possible.

The input data votes is structured the same way as for the stv method: Row i contains the preferences of voter i numbered 1, 2, \dots, r, 0,0,0,0, in some order, while equal preferences are allowed. The columns correspond to the candidates. The dimnames of the columns are the names of the candidates; if these are not supplied then the candidates are lettered A, B, C, .... If the dataset contains missing values (NA), they are replaced by zeros.

Note that if equal preferences are used, they are automatically converted into a format where for each preference i that does not have any duplicate, there must be exactly i-1 preferences j with 0 < j < i. It is the same ranking as one would obtain with rank(x, ties.method = "min"). If a conversion of a vote occurs, a warning is issued. That is done internally by calling the correct.ranking function.

The image function visualizes the joint distribution of two preferences (if all.pref=FALSE) given by xpref and ypref, as well as the marginal distribution of all preferences (if all.pref=TRUE). The joint distribution can be shown as proportions (if proportion=TRUE) or raw vote counts (if proportion=FALSE).

Value

Function condorcet returns an object of class vote.condorcet which is a list with the following objects:

elected

The Condorcet winner if exists, otherwise NULL.

loser

The Condorcet loser if exists, otherwise NULL.

totals

nc x nc matrix where nc is the number of candidates. Element ij = 1 if i won against j, otherwise 0.

runoff.winner

The run-off winner if exists and if the runoff argument was set to TRUE, otherwise NULL.

runoff.participants

List of run-off participants if the runoff argument was set to TRUE, otherwise NULL.

data

Input data (possibly corrected) with invalid votes removed.

invalid.votes

Matrix of invalid votes that were removed from the original dataset.

Author(s)

Hana Sevcikova, Salvatore Barbaro

References

Condorcet, Marquis de (1785). Essai sur l'application de l'analyse a la probabilite des decisions rendues a la probabilite des voix. Paris: De l'imprimerie royale.

https://en.wikipedia.org/wiki/Condorcet_method

Sen A. (2017). Collective Choice and Social Welfare. Harvard University Press, Cambridge, Massachusetts (Chapter A4*).

Examples

data(food_election)
cdc.food <- condorcet(food_election)
summary(cdc.food)
# show the marginal distribution of the preferences
par(mai=c(1, 1.2, 0.8, 0.4)) # expand the left margin
image(cdc.food, all.pref = TRUE)

# Example with a runoff
votes <- matrix(c(2, 1, 3, 4,
                  2, 1, 3, 4,
                  4, 3, 2, 1,
                  4, 3, 2, 1,
                  1, 4, 3, 2), byrow = TRUE, nrow = 5)
colnames(votes) <- LETTERS[1:4]  
cdc.v <- condorcet(votes, runoff = TRUE)

vote documentation built on May 29, 2024, 8:35 a.m.