condorcet | R Documentation |
Count votes using the Condorcet voting method.
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, ...)
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 |
fsep |
If |
quiet |
If |
object , x |
Object of class |
... |
Additional arguments passed to the underlying functions. For the |
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
).
Function condorcet
returns an object of class vote.condorcet
which is a list with the following objects:
elected |
The Condorcet winner if exists, otherwise |
loser |
The Condorcet loser if exists, otherwise |
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.participants |
List of run-off participants if the |
data |
Input data (possibly corrected) with invalid votes removed. |
invalid.votes |
Matrix of invalid votes that were removed from the original dataset. |
Hana Sevcikova, Salvatore Barbaro
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*).
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)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.