Shapley-Shubik Power Index in R

March 13, 2012

(This article was first published on R snippets, and kindly contributed to R-bloggers)

This spring we have Rector Elections at Warsaw School of Economics. One of my collegues Tomasz Szapiro agreed to start in the elections. This induced me to write Shapley-Shubik Power Index calculation snippet in R.
Rector elections in Warsaw School of Economics are organized in eleven constituencies representing different communities of our school. Each constituency is represented by different number of electors. I have written a simple R code calculating relative power of electors representing those constituencies. To reduce the volume of calculations I have joined some constituencies (6 and 7, 8 and 9, 10 and 11).

Here is the code performing the Shapley-Shubik Power Index calculations:


# number of electors in each constituency
const <- c(30, 22, 27, 27, 41, + 11, 38 + 5, 1 + 9)

perms <- permutations(8, 8)
outcome <- apply(perms, 1, function(x) {
    x[sum(cumsum(const[x]) < 107) + 1] })

sspi <- prop.table(table(outcome))
names(sspi) <- c(“C_1”,“C_2”, “C_3”, “C_4”, “C_5”,
                 “C_67”, “C_89”, “C_1011”)
plot(sspi / (const / sum(const)),
     xlab=“constituency”, ylab=“power index / votes”)

The plot generated by the code shows relative power of constituency to number of its votes. Here it goes:

Interestingly relative power index of almost all constituencies is balanced. However, power index of constituency #2 is very low in comparison to the fraction of electors it possesses.

To leave a comment for the author, please follow the link and comment on their blog: R snippets. offers daily e-mail updates about R news and tutorials on topics such as: Data science, Big Data, R jobs, visualization (ggplot2, Boxplots, maps, animation), programming (RStudio, Sweave, LaTeX, SQL, Eclipse, git, hadoop, Web Scraping) statistics (regression, PCA, time series, trading) and more...

If you got this far, why not subscribe for updates from the site? Choose your flavor: e-mail, twitter, RSS, or facebook...

Comments are closed.


Mango solutions

RStudio homepage

Zero Inflated Models and Generalized Linear Mixed Models with R

Quantide: statistical consulting and training




CRC R books series

Six Sigma Online Training

Contact us if you wish to help support R-bloggers, and place your banner here.

Never miss an update!
Subscribe to R-bloggers to receive
e-mails with the latest R posts.
(You will not see this message again.)

Click here to close (This popup will not appear again)