# Here are some examples, help yourself:
# The wikipedia examples
A <- c(.75,.25);
B <- c(.75,.10,rep(0.01,15))
C <- c(.55,.45);
# The index by "laakso/taagepera" is the default
politicalDiversity(A)
politicalDiversity(B)
# Using Grigorii Golosov method gives:
politicalDiversity(B, index="golosov")
politicalDiversity(C, index="golosov")
# The 1980 presidential election in the US (vote share):
US1980 <- c("Democratic"=0.410, "Republican"=0.507,
"Independent"=0.066, "Libertarian"=0.011, "Citizens"=0.003,
"Others"=0.003)
politicalDiversity(US1980)
politicalDiversity(US1980, index= "herfindahl")
politicalDiversity(US1980, index = "H") # will match Herfindahl
# 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)
# 2010 Brazilian legislative election
votes_2010 = c("PT"=13813587, "PMDB"=11692384, "PSDB"=9421347,
"DEM"=6932420, "PR"=7050274, "PP"=5987670, "PSB"=6553345,
"PDT"=4478736, "PTB"=3808646, "PSC"=2981714, "PV"=2886633,
"PC do B"=2545279, "PPS"=2376475, "PRB"=1659973, "PMN"=1026220,
"PT do B"=605768, "PSOL"=968475, "PHS"=719611, "PRTB"=283047,
"PRP"=232530, "PSL"=457490,"PTC"=563145)
seats_2010 = c("PT"=88, "PMDB"=79, "PSDB"=53, "DEM"=43,
"PR"=41, "PP"=41, "PSB"=34, "PDT"=28, "PTB"=21, "PSC"=17,
"PV"=15, "PC do B"=15, "PPS"=12, "PRB"=8, "PMN"=4, "PT do B"=3,
"PSOL"=3, "PHS"=2, "PRTB"=2, "PRP"=2, "PSL"=1,"PTC"=1)
politicalDiversity(seats_2010)
politicalDiversity(seats_2010, index= "golosov")
Run the code above in your browser using DataLab