The vote Package: Single Transferable Vote and Other Electoral Systems in R
TThe vote Package: Single Transferable Vote andOther Electoral Systems in R Adrian E. Raftery
University of Washington
Hana Ševčíková
University of Washington
Bernard W. Silverman
University of Nottingham
Abstract
We describe the vote package in R , which implements the plurality (or first-past-the-post), two-round runoff, score, approval and single transferable vote (STV) electoralsystems, as well as methods for selecting the Condorcet winner and loser. We emphasizethe STV system, which we have found to work well in practice for multi-winner electionswith small electorates, such as committee and council elections, and the selection ofmultiple job candidates. For single-winner elections, the STV is also called instant runoffvoting (IRV), ranked choice voting (RCV), or the alternative vote (AV) system. Thepackage also implements the STV system with equal preferences, for the first time in asoftware package, to our knowledge. It also implements a new variant of STV, in whicha minimum number of candidates from a specified group are required to be elected. Weillustrate the package with several real examples. Keywords : alternative vote system, approval vote, Condorcet winner, committee election,council election, equal preferences, first-past-the-post, instant runoff voting, job candidateselection, multi-winner election, plurality vote, proportional representation, ranked choicevoting, single transferable vote, two-round runoff election .
1. Introduction
The vote package implements several electoral methods: plurality voting, approval voting,score voting, Condorcet methods, and single transferable vote (STV) methods (Ševčíková,Raftery, and Silverman 2021).In developing the package, we were motivated particularly by the needs of organizations withsmall electorates, such as learned societies, clubs and university departments, who may needto elect more than one person in a given election. In the early 1980s, one of us (BWS) wasa member of the Royal Statistical Society (RSS) Council. At that time, six members of theCouncil were elected at a time. A nominating committee nominated six candidates and theRSS membership as a whole voted, with each member allowed to vote for up to six candidates,and the six candidates with the most votes being elected. Usually there were only the sixnominated candidates, but that year a seventh candidate stood on a platform different fromthat of the “official” candidates. This candidate received votes from about a quarter of theelectorate, but was not elected because the other three-quarters of the members voted as ablock for the six candidates proposed by the nominating committee.This was viewed as unsatisfactory, because the seventh candidate’s position was not repre- a r X i v : . [ s t a t . C O ] F e b STV and Other Electoral Systems in R sented on the Council, even though it had substantial support among the RSS membership.This led the RSS Council to undertake a study of electoral methods for multi-winner elections,with a view to adopting a more representative system. They selected the Single TransferableVote (STV) method, which was then adopted for Council elections, initially using a programin the Pascal programming language developed by Hill, Wichmann, and Woodall (1987). Inthe next election, held under STV, the seventh candidate stood again, and was elected. STVhas been used since then to elect the RSS Council.In 2002, the Institute of Mathematical Statistics (IMS), the leading international associationof academic mathematical statisticians, considered the same issue and came to the sameconclusion, also adopting STV for its Council elections. They used an R program developedby BWS (Silverman 2002, 2003), who was also then the IMS President. This R programbecame the core of the vote package that we are describing here. This STV electoral methodhas been used since then by the IMS.Since then, another one of us (AER) has implemented the STV method in the context ofsmall electorates selecting or ranking multiple candidates, such as nominating committeesselecting multiple awardees for a prize, or academic departments selecting job candidates forinterviews. Those involved have generally reported finding the method satisfactory. Thisexperience has led to several modifications of the program that are also implemented in thepackage.Our implementation and discussion of STV and other systems is aimed particularly at thoseinvolved in non-party-political elections and decisions, such as those outlined above. Questionsof what approaches are or are not desirable for national elections are matters of politicalscience beyond the scope of this paper, which is not intended to advocate for or againstthe use of any particular voting systems in that context; however a brief review may beinformative.The USA and the UK, for their national legislatures, almost entirely use the plurality, “firstpast the post” or “winner takes all” system, where the leading candidate in each district iselected. The Electoral College for the US presidency is also elected this way, but with anelection between slates rather than individuals, in all states except Maine and Nebraska. Onthe other hand, the majority of countries use some system that (in principle at least) aims forthe elected body to represent proportionately the views of the wider electorate, either over thecountry as a whole or within larger electoral districts. However, pure proportional systemsare fairly unusual, for example because in nationwide proportional systems there is often athreshold below which a party will not have any representation. The Single TransferableVote system is used to elect the parliaments or national assemblies of the Republic of Ireland,Northern Ireland and Malta, as well as upper houses and/or local assemblies in some othercountries (Wikipedia 2020c), and we draw an example from a Dublin election in the paper.As we have said, it is not our purpose to advocate any one electoral method, and indeedit is well known that there is no one method that dominates all others given a reasonableset of criteria, according to the impossibility theorems of Arrow (1963), Gibbard (1973) andSatterthwaite (1975). Indeed, method choice can depend on the purpose of the election, anda method that works well for one purpose (such as representing the views of the electorate),may not be best for others (such as electing an effective team to work together) (Syddique1988). As a result, we have implemented multiple electoral methods in the package. Pros andcons of a wide range of different electoral systems are described in Ace Project (2020), but drian E. Raftery, Hana Ševčíková, Bernard W. Silverman R packagesfor vote-counting.
2. Electoral Methods
In this section, we describe several electoral methods and how they are implemented in the vote package. We defer description of STV to Section 3.We first illustrate the results here with the toy food_election dataset:
R> library (vote)R> data (food_election)R> food_election
Oranges Pears Chocolate Strawberries Sweets1 NA NA 1 2 NA2 NA NA 1 2 NA3 NA NA 1 2 NA4 2 1 NA NA NA5 NA NA NA 1 NA6 1 NA NA NA NA7 NA NA NA NA 18 1 NA NA NA NA9 NA NA 1 2 NA10 NA NA 1 NA 211 1 NA NA NA NA12 NA NA 1 2 NA13 NA NA 1 2 NA14 NA NA 1 2 NA15 NA NA 1 NA 216 1 NA NA NA NA17 NA NA 1 NA 218 2 1 NA NA NA19 NA NA 1 NA 220 NA NA 1 2 NA
In this toy dataset, voters were asked to rank the options in order of preference. They gaveonly their first two preferences although they could have given more; an NA indicates that nopreference was expressed. STV and Other Electoral Systems in R Plurality voting, or First-Past-The-Post, is used for single-winner elections, such as electionsto the House of Representatives in the USA or the House of Commons in the UK. Each votervotes for one candidate and the candidate with the most votes wins.To implement this with our toy dataset, we first converted it to a dataset where only firstpreferences count:
R> food_election_plurality <- 1 * (food_election == 1 & !is.na (food_election))R> head(food_election_plurality)
Oranges Pears Chocolate Strawberries Sweets[1,] 0 0 1 0 0[2,] 0 0 1 0 0[3,] 0 0 1 0 0[4,] 0 1 0 0 0[5,] 0 0 0 1 0[6,] 1 0 0 0 0
We then counted the votes using the plurality command:
R> plurality (food_election_plurality)
Results of Plurality voting===========================Number of valid votes: 20Number of invalid votes: 0Number of candidates: 5Number of seats: 1| |Candidate | Total| Elected ||:---|:------------|-----:|:-------:||1 |Chocolate | 12| x ||2 |Oranges | 4| ||3 |Pears | 2| ||4 |Strawberries | 1| ||5 |Sweets | 1| ||Sum | | 20| |Elected: Chocolate
Plurality voting has the advantage of simplicity. In political elections, it tends not to yieldresults which are in direct proportion to support among the voters, but to amplify pluralitieswhen compared to proportional voting systems which merge single-winner districts into largermulti-member groups. In general, any large party which has strong support across a largenumber of electoral districts will do well under plurality voting, while smaller parties or drian E. Raftery, Hana Ševčíková, Bernard W. Silverman
Two round systems are also used for single-winner elections. In the first round, voters votefor their first preference. If no candidate gets a majority, there is a second round that involvesthe top two candidates. Voters vote again, and the candidate getting more votes wins.In the vote package, we implemented a variant of this system that can be counted in a singlepass over the data. Each voter ranks the candidates in order of preference. The first roundtakes place as described. The second round is counted as if voters voted for the remainingcandidate for which they had a higher preference.To illustrate the two-round runoff system, we modify the food election data by removingvoters 12–15, so that Chocolate does not have a majority on the first round:
R> food_election3 <- food_election[-c(12:15),]R> tworound.runoff (food_election3)
Results of two-round-runoff voting==================================Number of valid votes: 16Number of invalid votes: 0Number of candidates: 5Number of seats: 1| |Candidate | Total| Percent| ROTotal| ROPercent| Elected ||:---|:------------|-----:|-------:|-------:|---------:|:-------:||1 |Oranges | 4| 25.0| 6| 42.9| ||2 |Pears | 2| 12.5| 0| 0.0| ||3 |Chocolate | 8| 50.0| 8| 57.1| x |
STV and Other Electoral Systems in R |4 |Strawberries | 1| 6.2| 0| 0.0| ||5 |Sweets | 1| 6.2| 0| 0.0| ||Sum | | 16| 100.0| 14| 100.0| |Elected: Chocolate We see that no candidate got a majority on the first round, although Chocolate came close.In the second round, the two top vote-getters, Chocolate and Oranges, squared off, andChocolate won.In the tworound.runoff function, a tie in either the first or the runoff round is resolved byrandom draw. A random seed can be specified, so that the results are replicable.Two-round elections are quite common, most famously for French presidential elections since1965. In practice it is usually carried out by voters actually voting twice, rather than rankingcandidates as here. An exception to it is a special case of the two-round runoff, calledsupplementary voting where voters give only their first and second preferences on one ballot,the same way as happened in our food example. Supplementary voting is used for examplein electing mayors in England including the Mayor of London (London Elects 2020).The two-round runoff system differs from plurality voting in that voters for candidates withlow levels of support can change their votes to one of the leading candidates, so that they canexpress support for a possibly less popular first choice without their vote being “wasted”. Ofcourse, the choice between the two finalists shares some of the aspects of plurality voting.
Approval voting was advocated by Brams and Fishburn (1978). In this system, voters votefor as many candidates as they wish. It has been most often advocated for single-winnerelections, in which case the winner is the candidate with the most votes (Brams and Fishburn2007). A direct extension to multi-winner elections with m winners is that voters vote in thesame way, and the m candidates with the most votes win.Counting the votes is simple. The argument mcan determines the number of winners m : R> food_election_approval <- 1 * !is.na (food_election)R> approval (food_election_approval, mcan = 2)
Results of Approval voting==========================Number of valid votes: 20Number of invalid votes: 0Number of candidates: 5Number of seats: 2| |Candidate | Total| Elected ||:---|:------------|-----:|:-------:||1 |Chocolate | 12| x ||2 |Strawberries | 9| x | drian E. Raftery, Hana Ševčíková, Bernard W. Silverman |3 |Oranges | 6| ||4 |Sweets | 5| ||5 |Pears | 2| ||Sum | | 34| |Elected: Chocolate, Strawberries Approval voting for multi-winner elections has been criticized on various grounds, e.g. Hill(1988), and indeed in the book by Brams and Fishburn (1983) that advocated and popularizedapproval voting for single-winner elections. For elections in which there are parties or slates ofcandidates, it would tend to lead to the election of all the members of the most supported partyor slate, as happened in the RSS Council election that first motivated this work. However, oneof us [AER] has participated in multi-winner elections using approval voting and has observedit to work well, particularly when there are many candidates about whom information islimited, and there are no parties or slates. One example could be the early stages of jobcandidate selection, when a long list is being whittled down to a small set of finalists.
In score, or range voting, each voter gives each candidate a score within a prespecified range.If the voter does not give a score to a particular candidate, a corresponding prespecified scoreis assigned. The candidates with the lowest scores win (or the highest scores if higher scoresare better). In the score function, the argument larger.wins specifies whether lower scoresare better or higher scores are better. The argument max.score sets the prespecified non-vote score. Here we illustrate score voting by applying it to the food election example, wherethe score is equal to the preference, a non-vote is assigned a value of 6, and lower scores arebetter:
R> score (food_election, larger.wins = FALSE, mcan = 2, max.score = 6)
Results of Score voting=======================Number of valid votes: 20Number of invalid votes: 0Number of candidates: 5Number of seats: 2| |Candidate | Total| Elected ||:---|:------------|-----:|:-------:||1 |Chocolate | 60| x ||2 |Strawberries | 83| x ||3 |Oranges | 92| ||4 |Sweets | 99| ||5 |Pears | 110| ||Sum | | 444| |Elected: Chocolate, Strawberries
STV and Other Electoral Systems in R Score voting is often used by committees for purposes such as selecting grant applications tobe funded. In such cases there are often many candidates or applications to be assessed, andit would not be feasible for the voters to produce a complete ranking. Score voting is similarto multi-winner approval voting in this sense, but allows for more refined assessment by thevoters. Multi-winner approval voting is actually a special case of score voting.
The Condorcet method is attributed to Marquis de Condorcet (de Condorcet 1785). It is asingle-winner method where voters rank the candidates according to their preferences. Theso-called
Condorcet winner is the candidate who wins the majority of votes in all head-to-headcomparisons. In other words, each candidate is compared pairwise to all other candidates. Tobecome the Condorcet winner one has to win all such comparisons. Analogously, a
Condorcetloser is the candidate who loses in every pairwise comparison.The condorcet function can be applied directly to the food election data:
R> condorcet(food_election)
Results of Condorcet voting===========================Number of valid votes: 20Number of invalid votes: 0Number of candidates: 5Number of seats: 1| | Oranges| Pears| Chocolate| Strawberries| Sweets| Total| Winner | Loser ||:------------|-------:|-----:|---------:|------------:|------:|-----:|:------:|:-----:||Oranges | 0| 1| 0| 0| 1| 2| | ||Pears | 0| 0| 0| 0| 0| 0| | x ||Chocolate | 1| 1| 0| 1| 1| 4| x | ||Strawberries | 1| 1| 0| 0| 1| 3| | ||Sweets | 0| 1| 0| 0| 0| 1| | |Condorcet winner: ChocolateCondorcet loser: Pears
The output above shows the results of all the pairwise comparisons. Chocolate beat all othercandidates and was therefore the Condorcet winner. Similarly, Pears lost against all othercandidates and was thus the Condorcet loser.The Condorcet method does not guarantee that a Condorcet winner exists. There are manydifferent ways to deal with such a situation, see for example Wikipedia (2020a). Our imple-mentation offers the possibility of a run-off (argument runoff ). In this case, two or morecandidates with the most pairwise wins are selected and the Condorcet method is appliedto such subset. If more than two candidates are in such run-off, the selection is performedrepeatedly, until either a winner is selected or no more selection is possible.To our knowledge, the Condorcet method is not used for governmental elections anywhere inthe world. Wikipedia (2020a) cites a few private organizations that use the method, e.g., theStudent Society of the University of British Columbia. drian E. Raftery, Hana Ševčíková, Bernard W. Silverman
3. Single Transferable Vote (STV)
The Single Transferable Vote (STV) system is also referred to as Ranked Choice Voting(RCV), Instant Runoff Voting (IRV), or the Alternative Vote (AV) system for single-winnerelections, and as Multi-Winner Ranked Choice Voting for multi-winner elections. One of theproperties of the Single Transferable Vote system is that if any subset of candidates gets asufficient share of the votes, anything strictly exceeding 1 / ( m + 1), where m is the number ofcandidates to be elected, then one of this group is bound to be elected. To be precise, what isrequired is that a proportion above 1 / ( m +1) of the voters have to put all the candidates in thesubset at the top of their list of preferences, but it does not matter in what order. This wouldapply equally if the subset was a particular slate/party, or specified by some other groupcharacteristic such as sex or race or geographical location or career stage or subject area,even if the subset was not consciously constituted. In particular, if a candidate’s proportionof the first preference votes is above 1 / ( m + 1), then that candidate will be successful.There is also the fact that a group is not disadvantaged if more of its members stand forelection. Unlike in some other systems, they cannot cancel each other out.When STV was adopted for the elections of the Council of the RSS in the mid-1980s andthe IMS in 2002, it was hoped that it would lead to more diverse Councils than the resultsof the previous methods, and also that individual members, other than those chosen by thenominating committee, would feel able to stand with a real chance of being elected. There are many descriptions of the STV system (Newland, Britton, Rosenstiel, and Woodward-Nutt 1997; Fair Vote 2020), and its history (Hill 1988; Tideman 1995). The basic principleis that voters rank the candidates in order of preference. In order to be elected a candidatemust achieve the quota of N/ ( m + 1) + ε , where N is the total number of votes cast, m is thenumber of candidates to be elected (or seats), and ε is a pre-specified small positive number,often taken to be 1 when the electorate is large and 0.001 when it is small. Excess votes overthe quota are appropriately downweighted and allocated to the next preference of voters. Ifno candidate reaches the quota, the candidate with the smallest number of votes is eliminatedand his or her votes are transferred to the next preferences.Voters are asked to rank the candidates 1 , , , . . . until they have no further preference be-tween candidates. Thus 1 is a voter’s first preference, 2 is their next choice, and so on. Thereis no disadvantage to higher candidates in expressing a full list of preferences; later preferencesare used only when the fate of candidates given higher preferences has been decided one wayor the other.By default, a vote is considered spoiled if the preferences are not numbered consecutivelystarting at 1. However, if this is not desired, the votes can be preprocessed to be consecu-tive using the correct.ranking function in the vote package. A useful application of thiscorrection is the case when a candidate has to be removed, perhaps because of having with-drawn his or her candidacy. In this case, the function remove.candidate can be used, whichremoves the given candidate(s) from the set of votes, and also adjusts the preferences to beconsecutive.Also by default, apart from the candidates not numbered at all, no ties are allowed amongthe numbered preferences. However, equal preferences can be allowed by using the setting0 STV and Other Electoral Systems in R equal.ranking=TRUE in the stv function, as described in more detail in Section 3.4,The fact that some voters may not express a full list of preferences can be allowed for byreducing the quota in later counts . In the vote package, the default is that the quota isreduced in later counts. However in some STV systems (such as the electoral system in theRepublic of Ireland), the quota remains constant over counts at the value that is initiallydefined. This is specified in the vote package by setting the argument “ constant.quota =TRUE ” in the stv function. In this implementation of STV, the last candidate is often electedwithout reaching the quota, which does not happen when the quota is reduced appropriatelyat each count.In the vote package, the votes should be entered into a matrix or data frame, with theheader containing the names of the candidates and each row the votes cast, with blankpreferences being replaced by zeroes or NA s. This will often be done by entering the votes intoa spreadsheet first and then reading the spreadsheet into R . If the data are stored in a textfile, the package allows one to pass the name of the file directly into the stv function whilesetting the column separator in the fsep argument.At the end of the process, the program yields a list of the successful candidates in the orderin which they were elected. It also usually yields a complete ordering of the candidates. Thismay be useful, for example, if the purpose of the election is to select job candidates, and onewishes to have an ordered list of the initially unsuccessful candidates in case any of thoseselected decline the offer.Until the 1980s, STV elections were counted manually by physically transferring ballot pa-pers from the pile of the candidate being elected or eliminated, to those of the benefittingcandidates. This remains the case in several long-established STV election systems. Meek(1969, 1970) described the form a computer-based STV system could take, and this was im-plemented in Pascal by Hill et al. (1987). This code was used for the RSS Council elections. Amodified version was implemented in R by Silverman (2002, 2003), and this was the startingpoint for the current STV implementation in the vote package.Here is the result of the food election with two candidates to be elected, using the stv function: R> stv (food_election, mcan = 2)
Results of Single transferable vote===================================Number of valid votes: 20Number of invalid votes: 0Number of candidates: 5Number of seats: 2| | 1| 2-trans| 2| 3-trans| 3| 4-trans| 4||:------------|---------:|-------:|-----:|-------:|------:|-------:|-------:||Quota | 6.668| | 6.667| | 6.667| | 5.278||Oranges | 4.000| 0.000| 4.000| 2| 6.000| 0.000| 6.000| In STV, the process of distributing the surplus or votes of a candidate who is elected or eliminated isreferred to variously as a count, a stage or a round. Here we use the term count. The tabulation of the firstpreference votes is then called the first count. drian E. Raftery, Hana Ševčíková, Bernard W. Silverman |Pears | 2.000| 0.000| 2.000| -2| | | ||Chocolate | 12.000| -5.332| | | | | ||Strawberries | 1.000| 3.555| 4.555| 0| 4.555| 0.000| 4.555||Sweets | 1.000| 1.777| 2.777| 0| 2.777| -2.777| ||Elected | Chocolate| | | | | | Oranges||Eliminated | | | Pears| | Sweets| | |Elected: Chocolate, Oranges Oranges was elected second, whereas under the approval vote system with first and sec-ond preferences treated equally, Strawberries was elected second. This reflects the fact thatOranges had 4 first preferences whereas Strawberries had only 1. Under STV, a vote is cred-ited entirely to the first preference candidate unless that candidate is elected or eliminated,in which case the second preferences come into play. Strawberries had 8 second-preferencevotes, all of which were from voters who voted for Chocolate first. The quota was only 56%of the votes for Chocolate, and so 44% of Chocolate’s votes were transferred when Chocolatewas elected. Strawberries gained 3.555 votes this way from its second preference votes, butthis was not quite enough to overcome Orange’s advantage in first preferences. The completeordering of candidates can be read off the results: Chocolate, Oranges, Strawberries, Sweets,Pears. Setting the argument complete.ranking to TRUE will include the complete orderingas part of the output.The package has several functions for visualizing the STV results, and we will illustrate thesein the Examples section below. In addition, summary functions are available for the resultingobjects of all voting methods in the package. In the case of stv , the summary function returnsa data frame containing the table shown in the above output which can be used for furtherprocessing, for example for storing in a spreadsheet.
The algorithm used for counting STV elections using the stv function in the vote packageis shown in Algorithm 1. There are only two changes needed to implement STV with equalpreferences; these are shown in Section 3.4.
Suppose that on a given count, no candidate is elected and a candidate needs to be selectedfor elimination, and that two or more candidates are tied with the smallest number of votes.Then a method is needed for choosing the one to be eliminated. The same issue arises whentwo candidates can be elected on the same count with the same number of votes, namelywhich surplus to transfer first.Several different methods have been proposed. The Electoral Reform Society, one of the lead-ing organizations advocating the use of STV, recommends using the Forwards Tie-BreakingMethod (Newland et al. vote package uses the Forwards Tie-Breaking Method. This consists of elim-inating/electing the candidate who had the fewest/most votes on the first count, or on the2
STV and Other Electoral Systems in R Algorithm 1: STV algorithm. The input data consist of a matrix X of the votes of size N × M ,with N being the number of ballots and M the number of candidates. m is the number ofseats to be filled, and ε is a small number used for defining the quota. procedure stv ( X, m, ε ) D ← { , , . . . , M } . Set of hopeful candidates E ← {} . Set of elected candidates F ← {} . Set of eliminated candidates L ← m . Remaining number of seats Y ← X .
Remaining votes c ← . Which Count we are at w i ← ∀ i = 1 , . . . , N . Initialize a vector of weights, one per voter while L > do . End if there are no remaining seats c ← c + 1 . Increase Count u i,j ← w i δ Y i,j (1) ∀ i = 1 , . . . , N, j = 1 , . . . , M . Weighted first preferences v c,j ← P Ni =1 u i,j ∀ j = 1 , . . . , M . Sum of weighted first preferences Q ← P Mj =1 v c,j / ( L + 1) + ε . Compute quota if max j ∈ D v c,j ≥ Q then . A candidate is to be elected k ← arg max j ∈ D v c,j . Which candidate has the most votes if || k || > then . If there is more than one such candidate k ← resolve.tie.for.election( k, X, v ) . Break tie end if S ← (max j ∈ D v c,j − Q ) / max j ∈ D v c,j . Compute surplus w r ← u rk ∗ S ∀ r where Y r,k = 1 . Recompute weights L ← L − . Decrease number of available seats E ← E ∪ { k } . Candidate k is elected else . A candidate is to be eliminated k ← arg min j ∈ D v c,j . Which candidate has the least votes if || k || > then . If there is more than one such candidate k ← resolve.tie.for.elimination( k, X, v ) . Break tie end if F ← F ∪ { k } . Candidate k is eliminated end if D ← D \{ k } . Candidate k is removed from the pool of hopefuls Y i,r ← Y i,r − ∀ i = 1 , . . . , N where Y i,k > r = 1 , . . . , M where Y i,r > Y i,k . Above: shift votes for voters who voted for candidate k Y i,k ← ∀ i = 1 , . . . , N . Remove votes for candidate k end while return ( E, F, v ) end procedure Note: δ Y (1) = 1 if Y = 1 and 0 otherwise, is the Kronecker delta function; the arg max andarg min functions return sets, with more than one element when there is a tie; and || k || is thenumber of elements in the set k . drian E. Raftery, Hana Ševčíková, Bernard W. Silverman ties in the stv function isset to " b ", the Backwards Tie-Breaking Method is used. In this case, it eliminates/elects thecandidate who has the fewest/most votes on the latest count where the tied candidates hadunequal votes.There is no guarantee that a tie will be broken by either the Forwards or Backwards Tie-Breaking Method. Also, if one of these two methods does not break the tie, the other willnot either, because the tied candidates will have the same number of votes in all the countsso far. In particular, this will be the case whenever a tie has to be broken on the first count,and it is also relatively likely when a tie arises on the second count.When there is a tie that Forwards and Backwards Tie-Breaking fail to break, the stv func-tion uses a method that compares the candidates on the basis of the numbers of individualpreferences. We call this the Ordered method as it creates an ordering of the candidates be-fore the STV count begins. First, candidates are ordered by the number of first preferences.Any ties are resolved by proceeding to the total number of second preferences, then the thirdpreferences, and so on. If a tie cannot be resolved even by counting the last preference, thenit is broken by a random draw with equal probabilities for the tied candidates. A randomseed is specified so that the result is replicable.Combining Forwards and Backwards Tie-Breaking with the Ordered method and randomsampling, each tie in the stv function is broken in one of the following three ways:1. Forwards (“f”) or Backwards (“b”) Tie-Breaking method alone2. Forwards or Backwards Tie-Breaking followed by the Ordered method (“fo”, “bo”)3. Forwards or Backwards Tie-Breaking followed by the Ordered method, and finally ran-dom sampling (“fos”, “bos”)The abbreviation of these three possibilities in parentheses is included in the STV outputwhenever a tie is broken during the election count.Ties of any kind are relatively rare unless the electorate is small. In very small electoratesties are more common, but cases where Forwards, Backwards and Ordered Tie-Breaking allfail to break the tie are unusual even then, so election by random draw will be a rare event.In the earliest version of the software (Silverman 2002), ties were broken deterministically:if a candidate was to be elected, the last-named member of a tie was chosen. On the otherhand, if there was a tie for elimination, it was the first named who was eliminated. Thesechoices were aimed at compensating in a small way for the tendency of candidates higher upthe ballot paper to get more votes. However, they depended on position on the ballot paper,which might be viewed as somewhat arbitrary, and in the vote package we have used a moresystematic criterion.
Extant implementations of STV require that voters not give equal preferences (except amongthe candidates that they do not rank). However, Meek (1970) has pointed out that the singletransferable vote system does not exclude this possibility, and outlined how the votes mightbe counted. This has never been implemented before in software, to our knowledge, althoughit is used for the election of the Trustees of the John Muir Trust Wikipedia (2020c).4
STV and Other Electoral Systems in R The basic idea is that if, for example, a voter gives their first preference to candidates Aand B, then the vote will be equally split between the two, giving half a vote to each. IfA is elected, then the proportion of the half-vote for A corresponding to A’s surplus will betransferred to their next highest preference. This will be B if B is still in contention, i.e.if B has not been elected or eliminated by that stage. Otherwise, it will be the remainingcandidate with the next highest preference from that voter. Similarly, if A is eliminated, thehalf-vote for A will be fully transferred to their next highest remaining preference. This willbe B if B is still in contention, or otherwise the candidate with the next highest preference.The same principle applies if there are three or more equal preferences. For example, considerthe case where there are three equal preferences A, B and C, and A is eliminated/elected. IfA is elected, the proportion of the one-third vote for A corresponding to A’s surplus is equallydivided between B and C. If A is eliminated, then both B and C get increased to a half vote.Algebraically, this is implemented by the change below in Line 11 of Algorithm 1.Otherwise the count proceeds in the same way as when equal preferences are not allowed.The argument equal.ranking in the stv function is set to
TRUE when equal preferencesare allowed. In this case, votes are postprocessed before counting so that they correctlyreflect preferences. For example, a vote 1, 1, 2, 3, 3, 3 would be recoded to 1, 1, 3, 4,4, 4. This is in contrast with the usual case where equal preferences are not allowed and equal.ranking=FALSE , when votes with non-sequential preferences, such as 1, 2, 4, 5, aredeclared invalid and considered spoiled.STV with equal preferences can be implemented by Algorithm 1 with only two relativelysmall changes, namely:
Line 11 replaced by: u i,j ← w i δ Y i,j (1) / P M‘ =1 δ Y i,‘ (1) ∀ i = 1 , . . . , N, j = 1 , . . . , M Line 20 replaced by: w r ← P Mj =1 u r,j − u r,k + u r,k ∗ S ∀ r where Y r,k = 1Note that if applied to votes with no equal preferences, the modified algorithm yields thesame result as Algorithm 1. In such a case, the denominator in Line 11 is equal to 1 for all i and thus, u is the same as in Algorithm 1. Similarly in Line 20, P Mj =1 u r,j − u r,k = 0 if thereare no equal preferences and thus, w is the same as in Algorithm 1.We illustrate this functionality using the food election data by setting the first three votes toequal first preferences for Chocolate and Strawberries, instead of first and second preferences: R> food_election2 <- food_electionR> food_election2[c(1:3), 4] <- 1R> stv (food_election2, equal.ranking = TRUE)
Results of Single transferable vote with equal preferences==========================================================Number of valid votes: 20Number of invalid votes: 0Number of candidates: 5Number of seats: 2 drian E. Raftery, Hana Ševčíková, Bernard W. Silverman | | 1| 2-trans| 2| 3-trans| 3| 4-trans| 4||:------------|---------:|-------:|-----:|-------:|------:|-------:|-------:||Quota | 6.668| | 6.667| | 6.667| | 5.437||Oranges | 4.000| 0.000| 4.000| 2| 6.000| 0.000| 6.000||Pears | 2.000| 0.000| 2.000| -2| | | ||Chocolate | 10.500| -3.832| | | | | ||Strawberries | 2.500| 2.372| 4.872| 0| 4.872| 0.000| 4.872||Sweets | 1.000| 1.460| 2.460| 0| 2.460| -2.460| ||Elected | Chocolate| | | | | | Oranges||Eliminated | | | Pears| | Sweets| | |Elected: Chocolate, Oranges Once again, Oranges is elected second, ahead of Strawberries, although the margin of victoryis smaller than before.
In addition to having a given number of seats to fill, it may be desired to elect a minimumnumber of candidates from a specified class or group of candidates. For example, the selectionof plenary papers at a conference might wish to reserve at least two slots for students. Orthe election of a committee might wish to ensure that at least three women were elected.We have incorporated this feature into the stv function as an option. Users can specify thenumber of reserved seats with the argument group.mcan and mark the members eligible forthose seats in the argument group.members .When this requirement is present, our STV algorithm is modified as follows. Suppose m denotes the number of seats and g denotes the number of reserved seats and candidates areeither marked (eligible for reserved seats) or unmarked (not eligible). Then on each count,• if the leading candidate exceeds the quota they are elected, except that if m − g unmarkedcandidates have already been elected, they are only elected if they are marked. Or,• if no candidate has been elected on this round, the candidate with the fewest votes iseliminated, except that if there are only g marked candidates still in play (includingany already elected) or if there are already m − g unmarked candidates elected, theunmarked candidate with the fewest votes is eliminated (even if that number of votesis above the quota).We will illustrate the reserved seats feature in Section 4.3.
4. Examples
We now illustrate the different systems using three examples of elections. Perhaps ironically,systems are more robust with larger than smaller electorates, in the sense that their resultsare less sensitive to small changes in the electoral system. We therefore start with a politicalelection with a relatively large electorate, continue with the election of the council of a sci-entific organization with a moderate-sized electorate, and finally describe an election with a6
STV and Other Electoral Systems in R very small electorate. Each of these was a multi-winner election, but we will also use themto illustrate the single-winner electoral methods. The Dublin West constitutency in the 2002 Irish general election had three seats to be filled,nine candidates and just under 30,000 ranked votes. The dataset, called dublin_west , isincluded in the package.
R> data (dublin_west)R> head(dublin_west)
Bonnie Burton Ryan Higgins Lenihan McDonald Morrissey Smyth Terry1 0 4 0 3 0 0 1 5 22 0 0 2 0 1 4 3 0 03 0 0 3 0 1 0 2 0 04 0 2 0 0 0 0 3 0 15 0 2 1 0 0 0 0 0 06 0 3 2 0 1 0 0 0 0
We illustrate the single-winner methods by assuming that there is just one seat to be filled.First the plurality method. It is necessary to convert the dataset into a set of zeros and onesto run the plurality function:
R> dublin_west1 <- 1*(dublin_west == 1)R> plurality (dublin_west1)
Results of Plurality voting===========================Number of valid votes: 29988Number of invalid votes: 0Number of candidates: 9Number of seats: 1| |Candidate | Total| Elected ||:---|:---------|-----:|:-------:||1 |Lenihan | 8086| x ||2 |Higgins | 6442| ||3 |Burton | 3810| ||4 |Terry | 3694| ||5 |McDonald | 2404| ||6 |Morrissey | 2370| ||7 |Ryan | 2300| ||8 |Bonnie | 748| ||9 |Smyth | 134| ||Sum | | 29988| | drian E. Raftery, Hana Ševčíková, Bernard W. Silverman Elected: Lenihan
Lenihan was elected, although he received only 27% of the first preference votes.Here is the two-round runoff result:
R> tworound.runoff (dublin_west)
Results of two-round-runoff voting==================================Number of valid votes: 29988Number of invalid votes: 0Number of candidates: 9Number of seats: 1| |Candidate | Total| Percent| ROTotal| ROPercent| Elected ||:---|:---------|-----:|-------:|-------:|---------:|:-------:||1 |Bonnie | 748| 2.5| 0| 0.0| ||2 |Burton | 3810| 12.7| 0| 0.0| ||3 |Ryan | 2300| 7.7| 0| 0.0| ||4 |Higgins | 6442| 21.5| 12457| 47.3| ||5 |Lenihan | 8086| 27.0| 13900| 52.7| x ||6 |McDonald | 2404| 8.0| 0| 0.0| ||7 |Morrissey | 2370| 7.9| 0| 0.0| ||8 |Smyth | 134| 0.4| 0| 0.0| ||9 |Terry | 3694| 12.3| 0| 0.0| ||Sum | | 29988| 100.0| 26357| 100.0| |Elected: Lenihan
Lenihan was again elected, but this time after a run-off, as he did not get a majority on thefirst count. He got an absolute majority on the second count. This indicates a broader baseof support than the plurality vote.We now illustrate the single-winner approval voting method by assuming that voters “ap-proved” any candidate to whom they gave their first, second or third preference. Under thisassumption, voters approved 2.8 candidates on average.
R> dublin_west2 <- 1*(dublin_west == 1 | dublin_west == 2 | dublin_west == 3)R> approval (dublin_west2)
Results of Approval voting==========================Number of valid votes: 29988Number of invalid votes: 0Number of candidates: 9 STV and Other Electoral Systems in R Number of seats: 1| |Candidate | Total| Elected ||:---|:---------|-----:|:-------:||1 |Lenihan | 15253| x ||2 |Higgins | 13638| ||3 |Burton | 12863| ||4 |Ryan | 10014| ||5 |Terry | 9810| ||6 |Morrissey | 9411| ||7 |McDonald | 6674| ||8 |Bonnie | 4936| ||9 |Smyth | 636| ||Sum | | 83235| |Elected: Lenihan
Once again, Lenihan wins. The multi-winner approval vote method with three seats giveswins to Lenihan, Higgins and Burton, because they got the most votes.The Condorcet method did have both a winner and a loser in this case:
R> condorcet (dublin_west)
Results of Condorcet voting===========================Number of valid votes: 29988Number of invalid votes: 0Number of candidates: 9Number of seats: 1 | | Bonnie| Burton| Ryan| Higgins| Lenihan| McDonald| Morrissey| Smyth| Terry| Total| Winner | Loser ||:---------|------:|------:|----:|-------:|-------:|--------:|---------:|-----:|-----:|-----:|:------:|:-----:||Bonnie | 0| 0| 0| 0| 0| 0| 0| 1| 0| 1| | ||Burton | 1| 0| 1| 0| 0| 1| 1| 1| 1| 6| | ||Ryan | 1| 0| 0| 0| 0| 1| 1| 1| 0| 4| | ||Higgins | 1| 1| 1| 0| 0| 1| 1| 1| 1| 7| | ||Lenihan | 1| 1| 1| 1| 0| 1| 1| 1| 1| 8| x | ||McDonald | 1| 0| 0| 0| 0| 0| 0| 1| 0| 2| | ||Morrissey | 1| 0| 0| 0| 0| 1| 0| 1| 0| 3| | ||Smyth | 0| 0| 0| 0| 0| 0| 0| 0| 0| 0| | x ||Terry | 1| 0| 1| 0| 0| 1| 1| 1| 0| 5| | |Condorcet winner: LenihanCondorcet loser: Smyth
The STV result is as follows:
R> stv.dwest <- stv (dublin_west, mcan = 3, eps = 1, digits = 0)
Results of Single transferable vote=================================== drian E. Raftery, Hana Ševčíková, Bernard W. Silverman Number of valid votes: 29988Number of invalid votes: 0Number of candidates: 9Number of seats: 3 | | 1| 2-trans| 2| 3-trans| 3| 4-trans| 4| 5-trans| 5| 6-trans| 6| 7-trans| 7| 8-trans| 8||:----------|-------:|-------:|-----:|-------:|------:|-------:|--------:|-------:|-------:|-------:|---------:|-------:|----:|-------:|------:||Quota | 7498| | 7491| | 7486| | 7465| | 7303| | 7233| | 7043| | 6143||Bonnie | 748| 8| 756| 20| 776| -776| | | | | | | | | ||Burton | 3810| 55| 3865| 4| 3869| 207| 4076| 295| 4372| 211| 4583| 763| 5345| 1191| 6536||Ryan | 2300| 298| 2598| 23| 2621| 65| 2686| 357| 3042| 77| 3119| 673| 3792| -3792| ||Higgins | 6442| 68| 6510| 21| 6531| 198| 6728| 1124| 7853| -550| | | | | ||Lenihan | 8086| -588| | | | | | | | | | | | | ||McDonald | 2404| 24| 2428| 19| 2447| 76| 2523| -2523| | | | | | | ||Morrissey | 2370| 70| 2440| 13| 2453| 98| 2551| 108| 2659| 52| 2711| -2711| | | ||Smyth | 134| 1| 135| -135| | | | | | | | | | | ||Terry | 3694| 43| 3737| 21| 3758| 69| 3828| 151| 3979| 71| 4050| 896| 4946| 802| 5748||Elected | Lenihan| | | | | | | | Higgins| | | | | | Burton||Eliminated | | | Smyth| | Bonnie| | McDonald| | | | Morrissey| | Ryan| | |Elected: Lenihan, Higgins, Burton
The three candidates elected were also the ones who got the most first preference votes. Allthe candidates represented different political parties or were independents, except Ryan andLenihan, who were both candidates for the Fianna Fáil party, the largest party in Ireland atthe time. Lenihan was elected on the first count with a surplus of 588 votes, and 298 of thesewere transferred to Ryan, the most of any candidate. This reflects the fact that voters tendto give their highest preferences to candidates of the same party, although here we can seethat many of the Lenihan voters did not in fact give their second preferences to Ryan.Although this was an election with almost 30,000 votes and the electoral system appearssomewhat complex, the counting takes just two seconds on a Macbook Pro laptop.Note that the results were slightly different from the results using the Irish STV system,although the same candidates were elected; see Wikipedia (2020b). This is because of severalminor differences between the Irish STV system and the stv function in the vote package. Themost important of these is that in the vote package, the quota declines as the counts proceed,to reflect votes that are not transferred because voters did not express enough preferences.In the Irish STV system, the quota remains the same throughout the counts. We chose tomake the quota adaptive because it allows a more complete transfer of the votes of candidateselected. However, if the argument constant.quota is set to
TRUE , the quota is kept constantfor all counts.The STV results can be visualized in several ways. Figure 1 has been produced by thecommand
R> plot (stv.dwest)
It shows the evolution of the candidate’s vote totals over successive counts, as well as of thequota. It can be seen that, while candidates mostly stayed in the same order, the candidateRyan overtook two other candidates thanks to transfers, even though she was eventuallyeliminated. This reflects the fact that she had high preferences among voters who gave theirfirst preferences to Lenihan and Morrissey.Figure 2 shows the number of each preference votes that each candidate received. The firstpreferences reflect the numbers we know from the first count. It can be seen that Ryan andBurton had the most second preferences; in Ryan’s case this is because she was the second0
STV and Other Electoral Systems in R Quota
Count P r e f e r en c e s selection electedeliminated Candidate
BonnieBurtonRyanHigginsLenihanMcDonaldMorrisseySmythTerry
Figure 1:
Evolution of candidates’ votes over STV counts in the 2002 Irish general election in DublinWest.
Fianna Fáil (FF) candidate behind Lenihan, and got the majority of his second preferences.Burton and Morrissey had the most third preferences.Figure 3 shows the number of votes for each combination of first and second preference. Thebiggest number is those who voted first for Lenihan and then for Ryan, again reflecting thatthey are from the same party, and that Lenihan had the most first preferences.Figure 4 shows the same information, but in the form of the proportion of the first preferencevoters for each candidate that cast their second preference votes for each other candidate.The largest single cell shows that over 60% of Ryan voters cast their second preferences forLenihan.The code for producing Figures 2, 3 and 4 is as follows:
R> image (stv.dwest, all.pref = TRUE)
Note that the image method is available for all functions in the package that use ranked votes,namely, in addition to stv , condorcet and tworound.runoff . However, the method cannotbe used if equal preferences are present in the ballots. drian E. Raftery, Hana Ševčíková, Bernard W. Silverman Figure 2:
Number of each preference votes that each candidate received in the 2002 Irish generalelection in Dublin West.
The ims_election dataset contains the votes in a past election for the Council of the Insti-tute of Mathematical Statistics (IMS). There were four seats to be filled with 10 candidatesrunning, and 620 voters. The names of the candidates have been anonymized . The electionwas carried out by STV. The results were: R> data (ims_election)R> stv.ims <- stv (ims_election, mcan = 4, eps = 1, digits = 0) To ensure confidentiality, the names of the candidates were replaced by arbitrarily chosen first names thathave no connection to the actual names of the candidates. STV and Other Electoral Systems in R B onn i e B u r t on R y an H i gg i n s Len i han M c D ona l d M o rr i ss e y S m y t h T e rr y P r e f e r en c e Preference 2
Figure 3:
Number of votes for each combination of first and second preferences in the 2002 Irishgeneral election in Dublin West.
The results are shown in Figure 5. Although the electorate was much smaller, the resultsshow some common patterns to those from Dublin West. The quota declined slowly in theearly counts, and more rapidly in the later ones. The four candidates elected were the onesthat got the most first preferences. Figure 5(d) shows that, while there are no political partiesin this election, Tilmann and Hillary tended to share voters, as did Jasper and Li. We do drian E. Raftery, Hana Ševčíková, Bernard W. Silverman B onn i e B u r t on R y an H i gg i n s Len i han M c D ona l d M o rr i ss e y S m y t h T e rr y P r e f e r en c e Preference 2
Figure 4:
Proportion of the first preference votes for each candidate that gave their second preferencevote to each other candidate in the 2002 Irish general election in Dublin West. not know the identities of the candidates because their names have been anonymized, butthese pairs of candidates clearly appeal to the same voters, perhaps because of geographicalor intellectual commonalities.However, neither Li nor Hillary was able to benefit from these shared preferences in thiselection. While Jasper was elected on the second count, he reached exactly the number ofvotes needed to reach the quota, namely 119, and thus no surplus was available for a transfer.Tilmann on the other hand was elected last, after which the election ended. If there had beenone more seat available (i.e. mcan = 5 ), Hillary would have got Tilmann’s surplus and thenwould have been elected.
This is a trial election that was carried out to test a proposed use of STV in a universitystatistics department for selecting faculty job candidates to whom to make offers. There weretwo jobs to be filled, five finalists, and ten voters. It was desired to select the two candidatesto whom to make offers, and also to produce a ranking of the other candidates. This is fairlytypical of such elections. The candidates were named Augustin-Louis Cauchy, Carl FriedrichGauss, Pierre-Simon Laplace, Florence Nightingale, and Siméon Poisson.4
STV and Other Electoral Systems in R Quota
Count P r e f e r en c e s selection electedeliminated Candidate
TilmannJulieJasperLiWangHillaryClaireOscarDeclanRoisin T il m ann J u li e J a s pe r L i W ang H ill a r y C l a i r e O sc a r D e c l an R o i s i n P r e f e r en c e Preference 2 0.00.10.20.30.40.5RoisinDeclanOscarClaireHillaryWangLiJasperJulieTilmann T il m ann J u li e J a s pe r L i W ang H ill a r y C l a i r e O sc a r D e c l an R o i s i n P r e f e r en c e Preference 2
Figure 5:
Visualization of results of IMS Council election by STV. (a) Top left: Evolution of votesover counts. (b) Top right: Number of votes for each candidate at each preference level. (c) Bottomleft: Number of votes for each first and second preference combination. (d) Bottom right: Number ofsecond preferences as a proportion of the number of first preference voters for each candidate. drian E. Raftery, Hana Ševčíková, Bernard W. Silverman
R> faculty <- data.frame(Cauchy = c(3, 4, 4, 4, 4, 5, 4, 5, 5, 5),Gauss = c(4, 1, 2, 2, 2, 2, 2, 2, 2, 4),Laplace = c(5, 2, 1, 3, 1, 3, 3, 4, 4, 1),Nightingale = c(1, 3, 5, 1, 3, 1, 5, 1, 1, 2),Poisson = c(2, 5, 3, 5, 5, 4, 1, 3, 3, 3))
The results of the STV election were as follows:
R> stv.faculty <- stv (faculty, mcan = 2, digits = 2, complete.ranking = TRUE)
Results of Single transferable vote===================================Number of valid votes: 10Number of invalid votes: 0Number of candidates: 5Number of seats: 2| | 1| 2-trans| 2| 3-trans| 3| 4-trans| 4||:-----------|-----------:|-------:|------:|-------:|-------:|-------:|-----:||Quota | 3.33| | 3.33| | 3.33| | 3.33||Cauchy | 0.00| 0.00| 0.00| 0| | | ||Gauss | 1.00| 1.33| 2.33| 0| 2.33| 1.33| 3.67||Laplace | 3.00| 0.00| 3.00| 0| 3.00| 0.00| 3.00||Nightingale | 5.00| -1.67| | | | | ||Poisson | 1.00| 0.33| 1.33| 0| 1.33| -1.33| ||Elected | Nightingale| | | | | | Gauss||Eliminated | | | Cauchy| | Poisson| | |Complete Ranking================| Rank|Candidate | Elected ||----:|:-----------|:-------:|| 1|Nightingale | x || 2|Gauss | x || 3|Laplace | || 4|Poisson | || 5|Cauchy | |Elected: Nightingale, Gauss
Nightingale and Gauss were elected. The complete ranking could be useful for a vote likethis, where an ordering beyond the winning candidates may be desired, for example to make6
STV and Other Electoral Systems in R further offers if one of the top two declines the offer. Note that the complete ranking isconditional on the pre-specified number of seats or winners in the election.The results are illustrated in Figure 6. An interesting feature that can be seen from Figure6(a) is that Laplace got more first preference votes than Gauss, but Gauss ended up beatinghim by a small margin for the second offer because almost every voter gave Gauss either theirfirst or second preference. Thus, as other candidates were elected or eliminated, their voteswere transferred to Gauss rather than Laplace. The large number of second preferences forGauss is apparent from Figure 6(b). Figure 6(c) and especially Figure 6(d) show that Gaussgot the highest number and proportion of second preference votes from the electors of eachof the other candidates.If this had been done by approval voting, and all the voters had approved their top twochoices, the same two candidates would have been selected as by STV (i.e. Nightingale andGauss).It is interesting to note that there was no Condorcet winner in this election, even thoughNightingale was far ahead of the other candidates by most criteria: > condorcet (faculty) Results of Condorcet voting===========================Number of valid votes: 10Number of invalid votes: 0Number of candidates: 5Number of seats: 0| | Cauchy| Gauss| Laplace| Nightingale| Poisson| Total| Loser ||:-----------|------:|-----:|-------:|-----------:|-------:|-----:|:-----:||Cauchy | 0| 0| 0| 0| 0| 0| x ||Gauss | 1| 0| 1| 0| 1| 3| ||Laplace | 1| 0| 0| 0| 1| 2| ||Nightingale | 1| 1| 0| 0| 1| 3| ||Poisson | 1| 0| 0| 0| 0| 1| |There is no condorcet winner (no candidate won over all other candidates).Condorcet loser: Cauchy
This illustrates the fact that even in a relatively clearcut case there may be no Condorcetwinner.To illustrate the feature of reserved seats in STV, let us assume that it is required that atleast one French candidate be selected. Then,
R> stv (faculty, mcan = 2, group.mcan = 1,+ group.members = c("Laplace", "Poisson", "Cauchy"), digits = 2)
Results of Single transferable vote=================================== drian E. Raftery, Hana Ševčíková, Bernard W. Silverman Quota
Count P r e f e r en c e s selection electedeliminated Candidate
CauchyGaussLaplaceNightingalePoisson C au c h y G au ss Lap l a c e N i gh t i nga l e P o i ss on P r e f e r en c e Preference 2 0.00.20.40.60.81.0PoissonNightingaleLaplaceGaussCauchy C au c h y G au ss Lap l a c e N i gh t i nga l e P o i ss on P r e f e r en c e Preference 2
Figure 6:
Visualization of results of the trial faculty recruitment vote by STV. (a) Top left: Evolutionof votes over counts. (b) Top right: Number of votes for each candidate at each preference level.(c) Bottom left: Number of votes for each first and second preference combination. (d) Bottomright: Number of second preferences as a proportion of the number of first preference voters for eachcandidate. STV and Other Electoral Systems in R Number of valid votes: 10Number of invalid votes: 0Number of candidates: 5Number of seats: 2Number of reserved seats: 1Eligible for reserved seats: 3| | 1| 2-trans| 2| 3-trans| 3||:-----------|-----------:|-------:|-----:|-------:|-------:||Quota | 3.33| | 3.33| | 3.33||Cauchy* | 0.00| 0.00| 0.00| 0.00| 0.00||Gauss | 1.00| 1.33| 2.33| -2.33| ||Laplace* | 3.00| 0.00| 3.00| 1.67| 4.67||Nightingale | 5.00| -1.67| | | ||Poisson* | 1.00| 0.33| 1.33| 0.67| 2.00||Elected | Nightingale| | | | Laplace||Eliminated | | | Gauss| | |Elected: Nightingale, Laplace
Here, the modifications to the algorithm described in Section 3.5 ensured that none of theFrench candidates was eliminated on the second count, as the only seat left at that point wasthe reserved seat. Thus, Gauss, the only non-French candidate left, was eliminated in spite ofhaving more votes than Cauchy or Poisson. Laplace was then elected on the following count.In the output, the candidates eligible for reserved seats are marked with a star.We now modify this dataset slightly to illustrate the equal ranking STV method. Four of thevotes were changed so as to include equal preferences:
R> faculty2 <- facultyR> faculty2[1,] <- c(2,2,3,1,1)R> faculty2[4,] <- c(3,1,2,1,3)R> faculty2[9,] <- c(4,1,3,1,2)R> faculty2[10,] <- c(2,1,1,1,1)R> faculty2
Cauchy Gauss Laplace Nightingale Poisson1 2 2 3 1 12 4 1 2 3 53 4 2 1 5 34 3 1 2 1 35 4 2 1 3 56 5 2 3 1 47 4 2 3 5 18 5 2 4 1 39 4 1 3 1 210 2 1 1 1 1 drian E. Raftery, Hana Ševčíková, Bernard W. Silverman
R> stv.faculty.equal <- stv (faculty2, equal.ranking = TRUE, digits = 2)
Results of Single transferable vote with equal preferences==========================================================Number of valid votes: 10Number of invalid votes: 0Number of candidates: 5Number of seats: 2| | 1| 2-trans| 2| 3-trans| 3| 4-trans| 4||:-----------|-----------:|-------:|------:|-------:|-------:|-------:|-----:||Quota | 3.33| | 3.33| | 3.33| | 3.33||Cauchy | 0.00| 0.00| 0.00| 0| | | ||Gauss | 2.25| 0.34| 2.59| 0| 2.59| 1.69| 4.28||Laplace | 2.25| 0.01| 2.26| 0| 2.26| 0.13| 2.39||Nightingale | 3.75| -0.42| | | | | ||Poisson | 1.75| 0.06| 1.81| 0| 1.81| -1.81| ||Elected | Nightingale| | | | | | Gauss||Eliminated | | | Cauchy| | Poisson| | |Elected: Nightingale, GaussWarning message:In correct.ranking(votes, quiet = quiet) :Votes 1, 4, 9, 10 were corrected to comply with the required format.
The warning message indicates that the ranking was corrected. When equal.ranking=TRUE ,this correction will be made with any input, as long as the preferences are recorded as positivenumbers (not necessarily integers). The corrected votes are stored in the data element of theresulting object:
R> stv.faculty.equal$data[c(1, 4, 9, 10),]
Cauchy Gauss Laplace Nightingale Poisson1 3 3 5 1 14 4 1 3 1 49 5 1 4 1 310 5 1 1 1 1
Such a correction is not made in the default case in which equal.ranking=FALSE , when thepreferences have to be an ordered sequence of integers starting at one, with no ties and nogaps. However, votes can be corrected in the same way also from outside stv , using thefunction correct.ranking .Finally, we give the results when there is a single winner to illustrate tie-breaking, as it sohappens that tie-breaking is needed on two different counts in this case:
R> stv.faculty.tie <- stv (faculty, mcan = 1)
Results of Single transferable vote===================================Number of valid votes: 10 STV and Other Electoral Systems in R Number of invalid votes: 0Number of candidates: 5Number of seats: 1| | 1| 2-trans| 2| 3-trans| 3| 4-trans| 4| 5-trans| 5||:-----------|------:|-------:|-------:|-------:|-----:|-------:|-------:|-------:|-----------:||Quota | 5.001| | 5.001| | 5.001| | 5.001| | 5.001||Cauchy | 0.000| 0| | | | | | | ||Gauss | 1.000| 0| 1.000| 1| 2.000| -2| | | ||Laplace | 3.000| 0| 3.000| 0| 3.000| 2| 5.000| -5| ||Nightingale | 5.000| 0| 5.000| 0| 5.000| 0| 5.000| 5| 10.000||Poisson | 1.000| 0| 1.000| -1| | | | | ||Tie-breaks | | | fo| | | | f| | ||Elected | | | | | | | | | Nightingale||Eliminated | Cauchy| | Poisson| | Gauss| | Laplace| | |Elected: Nightingale
On the second count, Gauss and Poisson both had one vote, the lowest number, and so weretied for elimination. The Forwards Tie-Breaking method did not break the tie, as they bothhad the same number of votes also on the first count. The Ordered method did break the tie,however, because Gauss had 7 second preferences, and Poisson had only 1, so Poisson waseliminated. The notation “fo” in the Tie-breaks row indicates the tie-breaking method used,here Forwards followed be Ordered.On the fourth count, Laplace and Nightingale were tied with 5 votes each, so they were tiedfor elimination as neither reached the quota of 5.001. The Forwards Tie-Breaking methodwas then used, and involved looking first at their numbers of votes on the first count, whenLaplace had 3 votes and Nightingale had 5. As a result, Laplace was eliminated and thenNightingale was elected. If the Backwards Tie-Breaking method had been used (by setting ties = "b" ), the comparison would have been done based on the third count instead of thefirst count. Here too, Laplace had 3 votes and Nightingale had 5 on the third count and thus,Laplace would have been eliminated.Note that the ranking used by the Ordered method can be viewed via the ordered.tiebreak function:
R> ordered.tiebreak(stv.faculty.tie$data)
Cauchy Gauss Laplace Nightingale Poisson1 3 4 5 2attr(,"sampled")[1] FALSE FALSE FALSE FALSE FALSE
It gives the elimination ranking. When used for electing a candidate, the order is reversed.The attribute “sampled" indicates for each candidate whether sampling was involved to deter-mine its rank, which was not the case in our example. The function ordered.preferences can be used to view the matrix of preference counts from which the ordered ranking is derived.It gives the same information as the image plot with all.pref = TRUE , but in matrix form. drian E. Raftery, Hana Ševčíková, Bernard W. Silverman
5. Discussion
We have described and illustrated the vote package in R , which implements several electoralsystems, namely the plurality, two-round runoff, approval, score and single transferable vote(STV) systems (Ševčíková et al. R packages that implement electoral systems. The votesys packageimplements several electoral methods, including several that are not included in the vote package (Wu 2018). It implements the instant runoff system (IRV), which is the specialcase of STV for single-winner elections, but it does not implement the full version of STVfor multi-winner elections. The rcv package also implements IRV (calling it Ranked ChoiceVoting), but has been removed from CRAN (Lee and Yancheff 2019).The STV package implements the STV method (Emerson, Chandra, and Orr 2019). Theresults are generally very similar to those from the stv function in the vote package. However,there are some minor differences that can lead to different results, particularly in electionswith small electorates. Notably, in the
STV package all quotas, vote counts and transfers arerounded to integers, which can lead to different results when the electorate is small. Also,in the
STV package all tie-breaking is done at random, in contrast with the vote package,which uses forwards and backwards tie-breaking. Unlike the vote package, none of these otherpackages implements the STV method with equal ranking, or allows for reserved positionsfor marked groups.The
HighestMedianRules implements voting rules electing the candidate with the highestmedian grade (Fabre 2020a,b). The electoral and esaps packages compute various measuresof electoral systems; in spite of their names, they do not implement electoral systems or votingrules (Albuja 2020; Schmidt 2018).
Acknowledgements:
The research of Raftery and Ševčíková was supported by NIH grantR01 HD070936. The authors are grateful to Salvatore Barbaro and Brendan Murphy forhelpful discussions.2
STV and Other Electoral Systems in R References
Ace Project (2020). “The Systems and Their Consequences.” Accessed November 24, 2020,URL https://aceproject.org/ace-en/topics/es/esd/default .Albuja J (2020). electoral: Allocating Seats Methods and Party System Scores . R packageversion 0.1.2, URL https://CRAN.R-project.org/package=electoral .Arrow K (1963).
Social Choice and Individual Values . 2nd edition. Yale University Press,New Haven, Conn.Brams SJ, Fishburn PC (1978). “Approval Voting.”
American Political Science Review , ,831–847.Brams SJ, Fishburn PC (1983). Approval Voting . Birkhauser, Boston, Mass.Brams SJ, Fishburn PC (2007).
Approval Voting . 2nd edition. Springer Science & BusinessMedia.de Condorcet M (1785).
Essai sur l’Application de l’Analyse à la Probabilité des DecisionsRendues à la Pluralité des Voix . Imprimerie Royale, Paris, France.Electoral Reform Society (2020). “Party List Proportional Representation.” AccessedDecember 18, 2020, URL .Emerson J, Chandra S, Orr L (2019).
STV: Single Transferable Vote Counting . R packageversion 1.0.1, URL https://CRAN.R-project.org/package=STV .Fabre A (2020a).
HighestMedianRules: Implementation of Voting Rules Electing the Candi-date with Highest Median Grade . R package version 1.0, URL https://CRAN.R-project.org/package=HighestMedianRules .Fabre A (2020b). “Tie-breaking the highest median: alternatives to the majority judgment.”
Social Choice and Welfare . doi:https://doi.org/10.1007/s00355-020-01269-9 .Fair Vote (2020). “Multi-Winner Ranked Choice Voting.” Accessed December 4, 2020, URL .Gibbard A (1973). “Manipulation of Voting Schemes: A General Result.” Econometrika , ,587–601.Hill ID (1988). “Some Aspects of Elections–To Fill One Seat or Many (with Discussion).” Journal of the Royal Statistics Society, Series A (Statistics in Society) , , 243–275.Hill ID, Wichmann BA, Woodall DR (1987). “Single transferable vote by Meek’s method.” Computer Journal , , 277–281.Kitchener E (2005). “A new way to break STV ties in a special case.” Voting Matters , ,9–11. URL . drian E. Raftery, Hana Ševčíková, Bernard W. Silverman rcv: Ranked Choice Voting . R package version 0.2.1, URL https://cran.r-project.org/src/contrib/Archive/rcv/ .London Elects (2020). “Mayor of London & London Assembly Elections: Counting thevotes.” Accessed December 6, 2020, URL .Lundell J (2006). “Random tie-breaking in STV.” Voting Matters , , 1–6. URL .Meek BL (1969). “Une nouvelle approche du scrutin transférable.” Mathématiques et SciencesHumaines , , 13–23.Meek BL (1970). “Une nouvelle approche du scrutin transférable (fin).” Mathématiques etSciences Humaines , , 33–39.Newland RA, Britton FS, Rosenstiel C, Woodward-Nutt J (1997). How to Conduct anElection by the Single Transferable Vote . Electoral Reform Society, London, U.K. URL .O’Neill JC (2004). “Tie-Breaking with the Single Transferable Vote.”
Voting Matters , ,14–17. URL .Satterthwaite M (1975). “Strategy-proofness and Arrow’s conditions: Existence and Cor-respondence Theorems for Voting Procedures and Social Welfare Functions.” Journal ofEconomic Theory , , 187–217.Schmidt N (2018). esaps: Indicators of Electoral Systems and Party Systems . R packageversion 0.1.0, URL https://CRAN.R-project.org/package=esaps .Ševčíková H, Raftery AE, Silverman BW (2021). vote: Election Vote Counting . R packageversion 2.2-0, URL https://CRAN.R-project.org/package=vote .Silverman BW (2002). “Single Transferable Voting System: Counting IMSelections by single transferable vote.” URL https://imstat.org/elections/single-transferable-voting-system .Silverman BW (2003). “Counting IMS elections: new procedure.” IMS Bulletin , , 3.Syddique E (1988). “Discussion of ‘Some Aspects of Elections–To Fill One Seat or Many’.” Journal of the Royal Statistical Society, Series A (Statistics in Society) , , 265.Tideman N (1995). “The Single Transferable Vote.” Journal of Economic Perspectives , ,27–38.Wikipedia (2020a). “Condorcet method.” Accessed December 6, 2020, URL https://en.wikipedia.org/wiki/Condorcet_method .Wikipedia (2020b). “Dublin West Dáil constituency.” Accessed November 24, 2020, URL https://en.wikipedia.org/wiki/Dublin_West .4 STV and Other Electoral Systems in R Wikipedia (2020c). “Single transferable vote.” Accessed December 16, 2020, URL https://en.wikipedia.org/wiki/Single_transferable_vote .Wu J (2018). votesys: Voting Systems, Instant-Runoff Voting, Borda Method, Various Con-dorcet Methods . R package version 0.1.1, URL https://CRAN.R-project.org/package=votesyshttps://CRAN.R-project.org/package=votesys