---
title: "Measures of Political Behavior"
author: "Daniel Marcelino <<dmarcelino@live.com>>"
date: "`r format(Sys.Date(), '%B %d, %Y')`"
bibliography: SciencesPo.bib
output: 
   rmarkdown::html_vignette:
    toc: true
    toc_depth: 2
    number_sections: true
    css: SciencesPo.css
create_dir: false
abstract: This tutorial describes some of the political behavior indices that are most visible in scholarly literature, along with measures of political diversity, seats allocation, and a small number of examples for graphically displaying results. The very high-level framework for this tutorial is provided by the R package **SciencesPo**--version **`r packageVersion("SciencesPo")`** [@SciencesPo], but other packages are also engaged to help with various tasks.
vignette: >
  %\VignetteEngine{knitr::rmarkdown}
  %\VignetteIndexEntry{Measures of Political Behavior}
  \usepackage[T1]{fontenc}
  \usepackage[utf8]{inputenc}
nocite: | 
  @ggplot2, @knitr, 
---


```{r setup, echo = FALSE, include=FALSE}
knitr::opts_chunk$set(cache=TRUE, echo=TRUE, warning = FALSE, message=FALSE, collapse = FALSE, prompt=FALSE,comment=NA, fig.align="center", fig.width=5, fig.height=4, dpi = 96, fig.show = "hold", fig.keep="last", sanitize=TRUE)

options(java.parameters="-Xmx2g")# optional, but more memory for Java helps
options(dplyr.print_min=25)
```


  
# Introduction

This vignette describes a number of applications available in the R library **SciencesPo** for computing some of the most visible indices in the scholarship. These indices are important political abstractions because they provide grounding for categorizing units; therefore, making the way for causal comparison. Examples at the core of the discipline include measures of political concentration/fragmentation, political competition, and apportionment methods used to translate votes into seats.

This document is structured as follows. Section 2 gives a technical overview of the function, formulas, and examples of seat apportionment methods. Section 3 illustrates the use of political diversity methods to obtain empirical statistics of a political system environment, such as the effective number of parties, the nationalization of political parties, and political competition. Section 4 provides examples of computing proportionality measures. Section 5 ends with inequality measures. 

# Seat Apportionment Methods 

Most democratic countries use apportionment methods to transform election results into whole numbers, which in turn indicate the number of seats that each party earns in a legislative body, administrative council, or committee. Which apportionment method does this best is not a trivial topic for mathematicians as well as for political scientists. Actually, several formulas have been proposed since the early time of representative assemblies. The following sections briefly present some of these allotment methods.

## Highest Averages Methods of Allocating Seats Proportionally

Highest averages methods allocate seats proportionally to the number of votes by assigning seats in a way that assures the highest quotient by seat for each party. Other methods divide the votes by a mathematically derived quota, such as Droop and Hare quotas. In what follows are illustrative examples taken from Lijphart (1994) of the operation of some highest averages formulas in a six-member district with four parties.

```{r}
# Table A.l
lijphart <- c("A"=41000, "B"=29000,"C"=17000, "D"=13000)
```

The basic inputs for this class of functions are: 1) a list of parties, 2) a list of positive votes, and 3) a constant value for the number of seats to be returned. A numeric value (0~1) for the threshold is optional.

By default, the function prints the apportionment method being used, a snippet of the divisors used, the effective number of parties (or candidates) index for both before and after the seat allocation method takes place, and the least squares index--or Gallagher index.
The effective number of parties measured the before seat allocation is a measure of the party system fragmentation, once it deals with the effective number of parties at the electoral level, while the index computed after the seat allocation, the effective number of parliamentary parties. The Gallagher’s index is an indication of the disproportionality and runs from 0 to 100. The higher the value, the higher the disproportionality of the election outcome. 

### d'Hondt
Under the D'Hondt formula, seats are allocated using divisors of 1, 2, 3, 4, etc. Thus, suggesting that the divisors are simply one more than the number of seats that party already has. 


```{r}
library("SciencesPo", quietly = TRUE)

# The d'Hondt will give the same results as Jefferson's method
HighestAverages(parties=names(lijphart),
                votes=lijphart,
                seats = 6, 
                method = "dh") 
```

The d'Hondt is only one way of allocating seats in party list systems. Other methods include the Saint-Laguë, the modified Saint-Laguë, the Danish version, Imperiali (do not to confuse with the Imperiali quota, which is a Largest remainder method), Hungtinton-Hill, Webster, etc. 


### Saint-Laguë

Named after its founder, the pure Sainte-Laguë formula, also known as Schepers method, uses the odd-integer divisor series (1, 3, 5, 7, ...) to elect candidates from political parties in approximate proportion as the proportion of votes won by the party. The outcome would be the same as the outcome produced by the Webster's divisors method.

```{r }
# The Sainte-Laguë will give the same results as the Webster's method (wb)

HighestAverages(parties=names(lijphart),
            votes=lijphart,
                seats = 6,
                method = "sl") 
```

### Modified Saint-Laguë

The modified Sainte-Laguë use divisors of 1.4, 3, 5, 7, etc. How does the d'Hondt divisor compare to the Modified Sainte-Laguë one? Which divisor method tend to favor larger parties and which one smaller parties?

```{r }
HighestAverages(parties=names(lijphart),
                votes=lijphart, 
                seats = 6,
                method = "msl") 
```


### Danish

The Danish divisors (1, 4, 7, 10, ...) increase so fast that large parties are quickly cut down, acting much to the benefit of smaller parties.

```{r }
HighestAverages(parties=names(lijphart), 
                votes=lijphart, 
                seats = 6, 
                method = "danish") 
```

### Hungarian

The Hungarian version of Sainte-Laguë uses divisors of (1.5, 3, 5, 7, 9, ...) increase so fast that large parties are quickly cut down, acting much to the benefit of smaller parties.

```{r }
HighestAverages(parties=names(lijphart),
                votes=lijphart, 
                seats = 6, 
                method = "hsl") 
```


### Webster

This approach does not use a standard divisor either. It uses instead a different divisor and modified quota such that rounding with cut-off point at *algebraic* mean of lower and upper quotas: wb = $\frac{L + (L + 1)}{2}$.

```{r}
HighestAverages(parties=names(lijphart),
                votes=lijphart, 
                seats = 6, 
                method = "wb") 
```


### Imperiali

The Italian Imperiali divisor system has a slowly-increasing sequence (1, 1.5, 2, 2.5, 3, ...), with 0.5 difference between consecutive divisors. This is tighter than the d'Hondt divisors for which this difference is 1. Like d'Hondt, the Imperiali system is designed to encourage coalitions and secure majority governments under a PR system, but the Imperiali will be the most favorable to large parties as they will gain many seats before their quotients are reduced below those of the smaller parties.

```{r}
HighestAverages(parties=names(lijphart),
                votes=lijphart, 
                seats = 6, 
                method = "imperiali") 
```

The Belgian municipal councils were elected by the Imperiali highest averages method. The following example comes from the 2006 election in Bruges, where 47 seats were upon.

```{r}
Bruges=c("CD&V/N-VA"=32092, "SP.A/Spirit"=20028, 
         "Flemish Interest"=13408, "Open VLD/Vivant"=9520,
         "Green!"=5328, "Other"=2207)

HighestAverages(parties=names(Bruges),
                votes=Bruges, 
                seats = 47,
                method = "imperiali") 
```

### Hungtinton-Hill

The method proposed by Joseph Hill and Edward Huntington does not use a standard divisor, but a different one and also a modified quota such that rounding with cut-off point at *geometric* mean: hh = $\sqrt{L(L + 1)}$. This method makes sense only if every party is guaranteed at least one seat. It has been used for allotting seats in the US House of Representatives to the states.

```{r}
HighestAverages(parties=names(lijphart),
                votes=lijphart, 
                seats = 6, method = "hh") 
```

### Using Thresholds

Let's assume that we have an election with 1,000 total voters in which five parties (*A*, *B*, *C*, *D*, and *E*) have gained 100 (10\%), 150 (15\%), 300 (30\%), 400 (40\%), and 50 (5\%) votes, respectively. In this constituency, there are 3 seats up for election, and all votes cast are valid. What is more, this hypothetical electoral system has a 7\% vote threshold, meaning that parties must get at least 7\% of the total unspoiled votes cast in order to participate on the distribution of seats. Party *E* would then be eliminated from this contest at the outset. 

If D'Hondt divisor were employed in this hypothetical election, then party *C* would get 1 seat (or 33\% of the seats), party *D* 2 seats (or 67\% of the seats), and parties *A* and *B* none.

```{r}

const <- c("A"=100, "B"=150,"C"=300, "D"=400, "E"=50)

HighestAverages(parties=names(const),
                votes=const,
                seats = 3, method = "dh",
                threshold = 7/100) 
```


The following example is taken from the 2015 general elections in Spain. The region of Valencia returned 15 seats allocated using the D'Hondt method in a closed list PR system. Only lists that poll at least 3% of the total vote (which includes spoiled votes "en blanco") can be considered.

```{r Valencia-election}
(Valencia <- c("PP"=442005, "Podemos"=395729, "PSOE"=275680,
              "C's"=221299, "IU"=68759, "PACMA"=14445, "Others"=35943)) 
blanco=8738
nulo=11891
```


```{r Valencia}
# Valencia returned 15 members
HighestAverages(parties=names(Valencia),
                votes=Valencia, 
                seats=15, method = "dh",
                threshold = 3/100)
```


Next, the methods that divide the votes by mathematically derived quotas, such as the Droop quota, the Hare quota (or Hamilton/Vinton), and the Imperiali quota. 


## Largest Remainder Methods of Allocating Seats Proportionally

Highest averages methods allocate seats proportionally to the number of votes by dividing the number of votes required for each party by a quota. The quota may vary because it is the result of dividing the number of unspoiled votes ($v$) by some whole number close to the number of seats that would next be assigned ($s$). In what follows are illustrative examples of the operation of some largest remainders formulas in an eight member district with the same four parties of the previous examples.

### Hare quota
The Hare quota is obtained by quota: $\frac{v}{s}$.

```{r}
LargestRemainders(parties=names(lijphart),
                  votes=lijphart, 
                  seats = 8, method = "hare") 
```

### Droop quota
The Droop quota is obtained by quota: $\frac{v}{(s + 1)}+1$.

```{r}
LargestRemainders(parties=names(lijphart), 
                  votes=lijphart, 
                  seats = 8, method = "droop") 
```


### Hagenbach-Bischoff
The Hagenbach-Bischoff quota is obtained by $\frac{v}{(s + 1)}$.

```{r, eval=FALSE}
LargestRemainders(parties=names(lijphart),
                  votes=lijphart, 
                  seats = 8, method = "hagb") 
```


### Imperiali quota

The Imperiali quota is obtained by $\frac{v}{(s + 2)}$. For Italian elections during the 1950s, the quota used was a reinforced version of that quota: $\frac{v}{(s + 3)}$.
 
```{r data-Italy}
# The 1946 Italian Constituent Assembly election results: parties and unspoiled votes

Italy = data.frame(party=c("DC", "PSIUP", "PCI", "UDN", "UQ", "PRI",
                            "BNL", "PdA", "MIS", "PCd'I", "CDR",
                           "PSd'Az", "MUI", "PCS", "PDL", "FDPR"),
                   votes=c(8101004, 4758129, 4356686, 1560638,	1211956,
                           1003007, 637328, 334748, 171201, 102393,
                           97690, 78554, 71021, 51088, 40633, 21853))
```


```{r , eval=FALSE}
with(Italy, LargestRemainders(parties=party,
                              votes=votes, seats = 556,
                              method = "imperiali") )
```


```{r, eval=FALSE}
with(Italy, LargestRemainders(parties=party,
                              votes=votes, seats = 556,
                              method = "imperiali.adj") )
```


## Suitable output for recycling within RMarkdown documents 

The output produced by `HighestAverages()` and `LargestRemainders()`  functions is of class `data.frame`, which R users are already familiar with, and makes the process of using the output with other applications very straightforward. Let's take the data from 2014 Brazilian legislative elections. I will look at one electoral district--the state of Ceará--to compare how that caucus would look like if different apportionment methods were in place, keeping voters' preference constant.

```{r Ceara-election}
# Results for the state legislative house of Ceará (2014):
Ceara <- c("PCdoB"=187906, "PDT"=326841,"PEN"=132531, "PMDB"=981096,
           "PRB"=2043217,"PSB"=15061, "PSC"=103679, "PSTU"=109830,
           "PTdoB"=213988, "PTC"=67145, "PTN"=278267)
```

Once the data is loaded, producing a table with seat apportionment results is effortless with packages like **knitr**, **pander**, **gtable**, **xtable**, etc. In the following, I demonstrate this using the `kable()` function from the **knitr** package.

```{r}
mytable = HighestAverages(parties=names(Ceara), 
                          votes=Ceara,
                          seats = 42, method = "dh") 

library(knitr)

kable(mytable, align=c("l","c","c"), caption="Outcome under d'Hondt")
```


If you rather prefer to visualize data using graphs, that's fine. I've chosen a bar plot with colors alluding to the parties' identification colors. The graph is made with **ggplot2** library along with the **SciencesPo** theme `theme_fte`, which mimics the colors used in the <http://fivethirtyeight.com>.

```{r, fig.width=6.5, fig.height=4.5}

gg <- ggplot()
gg <- gg +  geom_bar( data = mytable, aes(x = reorder(Party, -Seats), y = Seats, fill = Party), stat = "identity", alpha=.9)
gg <- gg + geom_label(data = mytable,
aes(x = reorder(Party, -Seats), y= Seats + 1, label = Seats), hjust = .5)
gg <- gg + scale_y_continuous(expand = c(0, 0), limits = c(0, 25))
gg <- gg + scale_fill_party("BRA")
gg <- gg + labs(list(x = "", y = "# Seats obtained",
title = "The 2014 election in the Ceará State (seats won by party)"))
gg <-  gg + theme_fte(base_size = 10, base_family = "Tahoma")
gg
```


Next, I use the same example above to make a plot comparing three highest-averages formulas, D'Hondt, Imperiali, and Saint-Laguë. I've chosen a plot resembling a *Cleveland* dot plot (something between a bar and dot plot), and the **SciencesPo** theme.  

```{r, fig.width=6.5, fig.height=4.5, fig.cap= "2014 Legislative Election in Ceará (M=42)"}

out1 = HighestAverages(
  parties = names(Ceara),
  votes = Ceara,
  seats = 42,
  method = "dh"
  )
  out2 = HighestAverages(
  parties = names(Ceara),
  votes = Ceara,
  seats = 42,
  method = "imperiali"
  )
  out3 = HighestAverages(
  parties = names(Ceara),
  votes = Ceara,
  seats = 42,
  method = "sl"
  )
  
  # add the method:
  out1$Method = "d'Hondt"
  out2$Method = "Imperiali"
  out3$Method = "Saint-Laguë"
  
 data <- rbind(out1, out2, out3)
```


```{r, echo=FALSE, fig.width=7, fig.height=4.5, fig.cap= "2014 Legislative Election in Ceará (M=42)"}
  
  p <- ggplot()
  p <- p + geom_bar(
  data = data,
  aes(
  x = reorder(Party, -Seats),
  y = Seats,
  fill = Method
  ), 
  stat = "identity",
  position = position_dodge()
  )
  p <- p + labs(x = "", y = "# Seats obtained", title="The 2014 election in the Ceará State (seats won by party)")
  p <- p  + scale_fill_pub("fte")
  p <- p + theme_fte(legend = "top", base_size = 10, base_family = "Tahoma")
  p  + theme(panel.grid.major.x=element_blank()) 

```



```{r , eval=FALSE, echo=FALSE}

# 2014 Federal elections, 30 seats to be returned in the state of Parana, Brazil.

PR = c(
  "PSDB/DEM/PR/PSC/PTdoB/PP/SD/PSD/PPS" = 2601709,
  "PT/PDT/PRB/PTN/PCdoB" = 1109905,
  "PSDC/PEN/PTB/PHS/PMN/PROS" = 501148,
  "PV/PPL" = 280767
  )
```



```{r, eval=FALSE, echo=FALSE}

# 2014 Federal elections, 70 seats to be returned in the state of Sao Paulo, Brazil.

SP = c(
  "PSDB/DEM/PPS" = 5537630,
  "PT/PCdoB" = 3170003,
  "PMDB/PROS/PP/PSD" = 2384740,
  "PSOL/PSTU" = 462992,
  "PSL/PTN/PMN/PTC/PTdoB" = 350186,
  "PHS/PRP" = 252205
  )

```


# Measures of Political Diversity 

```{r echo=FALSE}
# The 2004 presidential election in the US (vote share):

US2004 <- c(
  "Democratic" = 0.481,
  "Republican" = 0.509,
  "Independent" = 0.0038,
  "Libertarian" = 0.0032,
  "Constitution" = 0.0012,
  "Green" = 0.00096,
  "Others" = 0.00084
  )

print(US2004)
```


```{r }
PoliticalDiversity(US2004); # ENEP (laakso/taagepera) method 
```

```{r }

PoliticalDiversity(US2004, index= "golosov");
```

The Herfindahl-Hirschman Index (HDI) is a well established tool to assess the degree of competition in a market (or, the closeness to a monopolistic market structure), with low values indicating a high degree of competition and, conversely, higher values betraying closeness to a monopoly. In this sense, it has been used by  political scientists as a mesure of political competition. In fact, the more common version is the inverted HDI (or 1 - HDI).  

```{r }

PoliticalDiversity(US2004, index= "inv.herfindahl");

# Compares to:
Herfindahl(US2004)
```


Considers the following `data.frame` with electoral results for the 1999 election in Helsinki. Seats were allocated using both Saint-Laguë and D'Hondt methods, so we can compare the effect of the allocation formulas on the effective number of parties.  

```{r Helsinki-election, echo=FALSE}
# Helsinki's 1999:
Helsinki <- 
  data.frame(
  votes = c(68885, 18343, 86448, 21982, 51587,
            27227, 8482, 7250, 365, 2734, 1925,
            475, 1693, 693, 308, 980, 560, 590, 185),
  seats.SL=c(5, 1, 6, 1, 4, 2, 1, 0, 0, 0, 0, 0, 0, 0,
             0, 0, 0, 0, 0),
  seats.dH=c(5, 1, 7, 1, 4, 2, 0, 0, 0, 0, 0, 0, 0, 0,
             0, 0, 0, 0, 0))
```


```{r }
# Helsinki's 1999 election:
Helsinki

```

```{r }

PoliticalDiversity(Helsinki$votes); #ENP given votes

PoliticalDiversity(Helsinki$seats.SL); #ENP for Saint-Lague 

PoliticalDiversity(Helsinki$seats.dH); #ENP for D'Hondt
```


# Measures of Proportionality

What is electoral disproportionality? A perfectly proportional election is one that every party wins seats in exact proportion to its share of votes. That is, a party with 25% of the votes wins 25% of the seats, a party with 5% of the votes wins 5% of the seats, and so on. This condition hardily holds in reality. To measure and compare the level of disproportionality from this ideal there are quite a few methods one can use. However, which one measures it best is far from clear. One should consider, why larger party deviations should be potentiated while smaller ones attenuated, or vice-versa.

How do we measure (dis)proportionality in practice? Let's consider the following two real-data examples taken from Wikipedia. These two sets of data refer to subnational elections, one from Queensland (Australia) and the other from Quebec (Canada).  

```{r Queensland-election, echo=FALSE}
# 2012 Queensland state elecion:
Queensland <-
data.frame(
party = c("LNP", "ALP", "Katter", "Greens", "Ind", "Others"),
votes = c(1214553, 652092, 282098, 184147, 77282, 35794),
pvotes = c(49.65, 26.66, 11.5, 7.53, 3.16, 1.47),
seats = c(78, 7, 2, 0, 2, 0),
pseats = c(87.64, 7.87, 2.25, 0.00, 2.25, 0.00)
)
```

```{r Quebec-election, echo=FALSE}
# 2012 Quebec provincial election:
Quebec <-
  data.frame(
  party = c("PQ", "Lib", "CAQ", "QS", "Option", "Green", "Others"),
  votes = c(1393703, 1360968, 1180235, 263111, 82539, 43394, 38738),
  pvotes = c(31.95, 31.20, 27.05, 6.03, 1.89, 0.99, 0.89),
  seats = c(54, 50, 19, 2, 0, 0, 0),
  pseats =  c(43.2, 40, 15.2, 1.6, 0, 0, 0)
  )

```

```{r Queensland}
# 2012 Queensland state elecion:
Queensland
```


```{r Quebec}
# 2012 Quebec provincial election:
Quebec
```

Following the years, most of the standalone functions used to compute proportionality measures methods were encompassed in a single function `Proportionality()`, and the original function being deprecated.

## Rae's Proportionality Index

The Rae's proportionality score also known as RID (Rae index of disproportionality) is calculated as: the sum of the absolute differences $|v_i - s_i|$ divided by the number of parties ($v_i > 0.5$ percent). It measures the average deviation per party. 

$$Index = \frac{1}{n}\sum_{i=1}^{n}\,|v_i - s_i|$$

Where, $v_i$ = the votes of party *i*, $s_i$ = the share of seats of party *i*, $n$ = the raw number of parties.

```{r }

with(Queensland, Proportionality(pvotes, pseats, 
                     index = "Rae") )

with(Quebec, Proportionality(pvotes, pseats, 
                     index = "Rae") )
```


## Loosemore-Hanby's Proportionality Index

The Loosemore-Hanby's score (LHI) is calculated as: the half of the sum of the absolute differences $|v_i - s_i|$. It measures the (half) total deviation, and the purpose is to measure the total party over-representation.

$$Index = \frac{1}{2}\sum_{i=1}^{n}\,|v_i - s_i|$$

```{r }

with(Queensland, Proportionality(pvotes, pseats, 
                     index = "Loosemore-Hanby") )

with(Quebec, Proportionality(pvotes, pseats, 
                     index = "Loosemore-Hanby") )
```


## Gallagher's Proportionality Index (Least Squares Index)
The Gallagher's Index also known as the "Least Squares Index" is calculated as: 

$$Index = \sqrt{\frac{1}{2}\sum_{i=1}^{n}\,(v_i - s_i)^{2}}$$

sqrt(sum((V-S)^2)/2). It's considered as a hybrid index between Rae's and Loosemore-Hanby's indices. It's also used the inverted version this index, calculated as 1 - (sqrt(sum((V - S)^2)/2)).

```{r }

with(Queensland, Proportionality(pvotes, pseats, 
                     index = "Gallagher") )

with(Quebec, Proportionality(pvotes, pseats, 
                     index = "Gallagher") )

## The inverted version
with(Quebec, Proportionality(pvotes, pseats, 
                     index = "inv.Gallagher") )
```

## Modified Gallagher Proportionality Index
Koppel and Diskin (2009) set forth a modified version of the Gallagher score computed as: sqrt(sum((V* - S*)^{2})/2), where $V*$ is V/sum({V_i}^2)^{1/2}, and $S*$ is S/sum({S_i}^{2})^{1/2}. 

$$Index = \sqrt{\frac{\sum_{i=1}^{n}\,(v_i^* - s_i^*)^{2}}{2}}$$

Where $v_i^*$ is

The inverted version can be obtained by subtracting 1 from the computed score.

```{r eval=FALSE}

with(Queensland, Proportionality(pvotes, pseats, 
                     index = "mod.Gallagher") )

with(Quebec, Proportionality(pvotes, pseats, 
                     index = "mod.Gallagher") )

## The inverted version
with(Quebec, Proportionality(pvotes, pseats, 
                     index = "mod.inv.Gallagher") )
```


## Rose's Proportionality Index

The Rose proportionality index (RPI) is computed by the sum the absolute differences between the fraction of votes the parties received and their fraction of seats. A division by 2 is used to standardize values between 0 and 1, and a subtraction from 1 is used so that higher values correspond to smaller differences. The Rose's Index is essentially the inverted version of the Loosemore-Hanby's Index; thus, 1 - LHI = RPI.


```{r }

with(Queensland, Proportionality(pvotes, pseats, 
                     index = "Rose") )

with(Quebec, Proportionality(pvotes, pseats, 
                     index = "Rose") )
```


## Grofman's Proportionality Index
The Grofman index calculated as the sum the absolute differences between the fraction of the votes and seats for each political group. Then, a division by the effective number of parties is applied to make the measure less sensitive to peripherical parties. 

$$Index = \frac{1}{N}\sum_{i=1}^{n}\,|v_i - s_i|$$


$v_i$ = the votes of the party, $s_i$ = share of political seats, N = the effective number of parties

```{r }

with(Queensland, Proportionality(pvotes, pseats, 
                     index = "Grofman") )

with(Quebec, Proportionality(pvotes, pseats, 
                     index = "Grofman") )

## The inverted version:
with(Quebec, Proportionality(pvotes, pseats, 
                     index = "inv.Grofman") )
```


## Modified Grofman's Proportionality Index
I will write soon... 

## Lijphart's Proportionality Index

$$Index = \max\big(|v_i - s_i|\big)$$

```{r }

with(Queensland, Proportionality(pvotes, pseats, 
                     index = "Lijphart") )


with(Quebec, Proportionality(pvotes, pseats, 
                     index = "Lijphart") )


## The inverted version:
with(Quebec, Proportionality(pvotes, pseats, 
                     index = "invlijphart") )

```


## Farina's Proportionality Index

```{r}

with(Queensland, Proportionality(pvotes, pseats, 
                     index = "Farina") )

with(Quebec, Proportionality(pvotes, pseats, 
                     index = "Farina") )

```


## Cox-Shugart's Proportionality Measure (Regression Index)

This function calculates the Cox-Shugart measure of proportionality. It provides the slope of the regression line. For perfect representation, a score of 1 is calculated, for values smaller than 1, smaller groups in population are numerically over-represented. The Cox-Shugart measure of proportionality indicates the direction of mis-representation. It is also known as the regression index.

$$Regression - Index =\frac{\sum\,{v_1}{s_i}}{\sum\,{v_i^2}}$$

```{r}

with(Queensland, Proportionality(pvotes, pseats, 
                     index = "Cox-Shugart") )

with(Quebec, Proportionality(pvotes, pseats, 
                     index = "Cox-Shugart") )

## The inverted version:
with(Quebec, Proportionality(pvotes, pseats, 
                     index = "inv.Cox-Shugart") )
```


## Sainte-Laguë Index

The Sainte-Laguë index is a measure of disproportionality that is minimized by Sainte-Laguë (Webster). The index is smiply the sum of, over all parties (or other distinct groups), $((V_i - S_i)^{2} / V_i)$, where $V_i$ is the share of votes for party (or group) $i$, and $S_i$ is its share of seats. If there were as many seats as voters, then $V_i - S_i$ would be 0 and $0/x$ is 0 for any $x != 0$, so in the case of perfect proportionality, this index is 0.
Because Sainte-Laguë (Webster) is considered the least biased Divisor method, and immune to paradox, Gallagher (1991) recommends using Sainte-Laguë as the standard measure of disproportionality. The inverted version of this index is also very common $((S_i - V_i)^{2}/V_i)$.

$$SL - Index = \sum_{i=1}^{n}\, \frac{1}{v_i}\,(v_i - s_i)^{2} = \sum_{i=1}^{n}\,{v_i}(1 - \frac{s_i}{v_i})^{2}$$

```{r}

with(Queensland, Proportionality(pvotes, pseats, 
                     index = "Sainte-Lague") )

with(Quebec, Proportionality(pvotes, pseats, 
                     index = "Sainte-Lague") )

with(Quebec, Proportionality(pvotes, pseats, 
                     index = "inv.Sainte-Lague") )
```


## D'Hondt (Jefferson) Index

Another option to measuring party proportionality is to compute the D'Hondt score of proportionality. As it goes above 1, more seats are apportioned than the equivalent fraction of votes, and less seats than votes otherwise.

$$Index =\max\bigg(\frac{s_i}{v_i}\bigg)$$

```{r}

with(Queensland, Proportionality(pvotes, pseats, 
                     index = "DHondt") )
```

```{r}

with(Quebec, Proportionality(pvotes, pseats, 
                     index = "DHondt") )
```


## Hamilton Index
I will write soon... 

## Gini Disproportionality Index
I will write soon... 

## Monroe's Inequity Index
I will write soon... 


$$Index = \sqrt{ \frac{\sum(v_i - s_i)^{2}}{1 +\sum(v_i/100)^{2}} }$$


# Measures of Inequality and Concentration


## Gini Index

I will write soon... 


## Atkinson's Index

$$Index = 1 - \bigg[ \frac{1}{N}\sum_{i=1}^{N}\:\bigg(\frac{y_i}{y}\bigg)^{1-e}\:\bigg]^\frac{1}{(1-e)}$$, for $\epsilon \neq 1$

$$Index = {\displaystyle 1 - \frac{\prod_{i=1}^{N}\big(y_i^{(1/N)}\big)}{\bar{y}} }$$, for $\epsilon = 1$

## Herfindahl's Index


## Rosenbluth's Index

# R Session Details  
```{r, echo=FALSE}
library("devtools", quietly = TRUE)
session_info()
```


# References

Cowell, F. A. (2000) Measurement of Inequality in Atkinson, A. B. / Bourguignon, F. (Eds): *Handbook of Income Distribution.* Amsterdam.

Benoit, Kenneth. (2000) *Which Electoral Formula is the Most Proportional? A New Look with New Evidence.* Political Analysis 8(4): 381-388.

Blais, A., and L. Massicotte (1997) *Electoral Formulas: A Macroscopic Perspective*, European Journal of Political Research, 32, 107–129.

Gallagher, Michael and Paul Mitchell (2005) *The Politics of Electoral Systems.* Oxford University Press.

Gallagher, Michael (1992) *Comparing Proportional Representation Electoral Systems: Quotas, Thresholds, Paradoxes and Majorities.* British Journal of Political Science, 22, 4, 469-496.

Gallagher, M. (1991) *Proportionality, disproportionality and electoral systems.* Electoral Studies 10(1):33-51.

Golosov, Grigorii (2010) *The Effective Number of Parties: A New Approach.* Party Politics, 16: 171-192.

Laakso, Markku and Rein Taagepera (1979) *Effective Number of Parties: A Measure with Application to West Europe.* Comparative Political Studies, 12: 3-27.

Lijphart, Arend (1994) *Electoral Systems and Party Systems: A Study of Twenty-Seven Democracies, 1945-1990.* Oxford University Press.

Koppel, M. and Diskin, A. (2009) *Measuring disproportionality, volatility and malapportionment: axiomatization and solutions.* Social Choice and Welfare 33(2):281-6.

Mackie, T. T. and Rose, R. (1991) *The International Almanac of Electoral History*. Macmillan, Basingstoke.

Monroe, B. L. (1994) *Disproportionality and Malapportionment: Measuring Electoral Inequity.* Electoral Studies 13, 132–49.

Nicolau, Jairo (2008) *Sistemas Eleitorais.* Rio de Janeiro, FGV.

Norris, Pippa (1997) *Choosing electoral systems: proportional, majoritarian and mixed systems.*

Rae, D. (1967) *The Political Consequences of Electoral Laws.* London: Yale University Press.

Taagepera, R., and B. Grofman (2003) *Mapping the indices of seats-votes disproportionality and inter-election volatility.* Party Politics 9, 6: 659-77.

Taagepera, Rein and Matthew S. Shugart (1989) *Seats and Votes: The Effects and Determinants of Electoral Systems.* New Haven: Yale University Press.

