two_round_runoff: Two-Round Runoff Vote Count

tworound.runoffR Documentation

Two-Round Runoff Vote Count

Description

Count votes using the two-round voting method with ranked ballots. If no candidate reaches the majority, the top two candidates go into a run-off.

Usage

tworound.runoff(votes, fsep = '\t', seed = NULL, quiet = FALSE, ...)
    
## S3 method for class 'vote.tworound.runoff'
summary(object, ...)
    
## S3 method for class 'vote.tworound.runoff'
view(object, ...)
    
## S3 method for class 'vote.tworound.runoff'
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.

fsep

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

seed

Integer. Seed of the random number generator (RNG). Only used if there are ties either between candidates to enter the run-off, or between the two run-off contenders. If set to NULL, the RNG is not initialized.

quiet

If TRUE no output is printed.

object, x

Object of class vote.tworound.runoff.

...

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

First, the number of first preferences is counted. If there is a candidate with more than 50%, that candidate gets elected. Otherwise, there is a runoff between the top two candidates.

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. Equal preferences are not 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.

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 tworound.runoff returns an object of class vote.tworound.runoff which is a list with the following objects:

elected

The elected candidate.

totals

Vector of total votes in the same order as candidates (columns) in the input data.

totals2r

Vector of total votes from the run-off (second round).

coin.toss.winner

TRUE if the winner was sampled between candidates with the same score, otherwise FALSE.

coin.toss.runoff

TRUE if the run-off contenders were sampled from candidates with the same score. Otherwise it is FALSE.

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

Sen A. (2017). Collective Choice and Social Welfare. Harvard University Press, Cambridge, Massachusetts, Chapter 10*3 (p. 243ff).

https://en.wikipedia.org/wiki/Two-round_system

Examples

data(ims_election)
trr <- tworound.runoff(ims_election)
summary(trr)

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