# Here are some examples, help yourself:
A <- c(.75,.25);
B <- c(.35,.35,.30);
C <- c(.75,.10,rep(0.01,15))
# Non-trivial example:
# The 1980 presidential election in the US (vote share):
party_1980 <- c("Democratic", "Republican", "Independent", "Libertarian", "Citizens", "Others")
US1980 <- c(0.410, 0.507, 0.066, 0.011, 0.003, 0.003)
politicalDiversity(US1980, index= "herfindahl")
# or
politicalDiversity(US1980, index= "simpson")
party_2004 <- c("Democratic", "Republican", "Independent", "Libertarian",
"Constitution", "Green", "Others")
US2004 <- c(0.481, 0.509, 0.0038, 0.0032, 0.0012, 0.00096, 0.00084)
politicalDiversity(US2004, index= "herfindahl")
# Using Grigorii Golosov approach:
politicalDiversity(US2004, index= "golosov")
# The 1999 Finland election
votes_1999 <- c(612963, 600592, 563835,
291675, 194846, 137330, 111835, 28084, 26440, 28549, 20442, 10378,
10104, 5451, 5194, 4481, 3903, 3455, 21734)
seats_1999 <- c(51, 48, 46, 20, 11, 11, 10, 0, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0)
# Helsinki's 1999
votes_1999 <- c(68885,18343, 86448,
21982, 51587, 27227, 8482, 7250, 365,
2734, 1925, 475, 1693, 693, 308, 980,
560, 590, 185)
#Sainte-Lague allocation:
seats_1999sl <- c(5, 1, 6, 1, 4, 2, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0)
# D'Hondt allocation:
seats_1999dh <- c(5, 1, 7, 1, 4, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0)
# 2010 Brazilian legislative election
party_2010 = c("PT","PMDB","PSDB", "DEM","PR","PP","PSB","PDT","PTB", "PSC","PV",
"PC do B","PPS","PRB", "PMN", "PT do B", "PSOL","PHS","PRTB","PRP","PSL","PTC")
votes_2010 = c(13813587, 11692384, 9421347, 6932420, 7050274, 5987670, 6553345,
4478736, 3808646, 2981714,2886633, 2545279, 2376475, 1659973, 1026220,
605768, 968475, 719611, 283047, 232530, 457490, 563145)
# 2010 Election outcome as proportion of seats
seats_2010 = c(88, 79, 53, 43, 41, 41, 34, 28, 21,
17, 15, 15, 12, 8, 4, 3, 3, 2, 2, 2, 1, 1)/513
# 2014 Election outcome as proportion of seats
seats_2014 = c(70, 66, 55, 37, 38, 34, 34, 26, 22, 20, 19, 15, 12,
11, 10, 9, 8, 5, 4, 3, 3, 3, 2, 2, 2, 1, 1, 1)/513
politicalDiversity(seats_2014, index= "laakso/taagepera")
# or:
politicalDiversity(seats_2014, index= "invsimpson")
politicalDiversity(seats_2014, index= "golosov")
Run the code above in your browser using DataLab