allocate_seats: Allocate seats after election

Description Usage Arguments Value Author(s) References Examples

View source: R/weights_and_seats.R

Description

Allocates seats in Parliament after an election using the Sainte-Lague allocation formula

Usage

1
2
allocate_seats(votes, parties = names(votes), nseats = 120,
  threshold = 0.05, electorate = rep(0, length(votes)))

Arguments

votes

vector of vote proportions or counts.

parties

vector of names of parties.

nseats

number of seats to allocate. Note that in mixed systems such as New Zealand's where electorate is not all zero, there may be a "hangover" and total number of seats ends up larger than nseats due to parties that win an electorate seat but received less than 1/nseats of the vote.

threshold

minimum proportion of votes needed to be allocated a seat.

electorate

a numeric vector of same length as parties, for use in mixed-member proportional systems such as New Zealand's. If the ith electorate > 0, the ith party is allocated seats regardless of whether the party exceeded threshold. This is needed in a mixed-member proportional system such as New Zealand's.

Value

A list with two elements: a data frame seats_df and a vector seats_v, each of which provides information on the number of seats allocated to each party.

The data frame has four columns: proportionally_allocated, electorate_seats, final and party. In New Zealand, the number of "list MPs" for each party is final - electorate_seats.

The vector is the same as final in the data frame, with names equal to party.

Author(s)

Peter Ellis

References

http://www.elections.org.nz/voting-system/mmp-voting-system/sainte-lague-allocation-formula

See also Wikipedia on the Webster/Sainte-Lague method.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
# From Wikipedia; should return 3, 2, 2:
allocate_seats(c(53000, 24000, 23000), nseats = 7, threshold = 0)

# From 2014 New Zealand election
votes <- c(National = 1131501, Labour = 604535, Green = 257359,
           NZFirst = 208300, Cons = 95598, IntMana = 34094, 
           Maori = 31849, Act = 16689, United = 5286,
           Other = 20411)
electorate = c(41, 27, 0, 
               0, 0, 0, 
               1, 1, 1,
               0)
               
# Actual result:               
allocate_seats(votes, electorate = electorate)

# Result if there were no 5% minimum threshold:
allocate_seats(votes, electorate = electorate, threshold = 0)$seats_v

nzelect documentation built on May 2, 2019, 3:44 p.m.