Proportional Representation Calculator

Description

Proportional Representation Calculator

Usage

prcalc(x, m, method, extra = NULL, threshold = 0)

Arguments

x a data.frame or tibble object.
m a numeric vector of district magnitude.
method a character string giving a method for computing seat allocation. See "Allocation methods" section.
extra a numeric vector of length m. If method is “custom divisor” (“cd”) or “custom quota” (“cq”), this parameter is mandatory. See "About custom methods" section.
threshold a threshold. It must be equal or larger than 0 (0%) and smaller than 0.1 (10%). a default is 0.

Value

a prcalc object

Allocation methods

aaa

About custom methods

Custom methods (“custom divisor” and “custom quota”) require extra parameter. In the case of “custom divisor” (“cd”), a numeric vector of the same length as the magnitude (m) must be specified. If the magnitude (m) is a vector of length 2 or longer, the extra must have a length equal to max(m). For example, if m = c(5, 7, 4), then the length of the extra must be 7.

In the case of “custom quota”, extra must be a vector of the same length as m. For example, if m = c(5, 7, 4), extra must also be a numeric vector of length 3. If length of extra is 1, the same quota is applied to all blocks.

See Also

print.prcalc, summary.prcalc, plot.prcalc

Examples

library("PRcalc")

data(jp_upper_2019)
data(jp_lower_2021)
prcalc(jp_upper_2019, m = 50, method = "dt")
Raw:
       Party     Vote
1      Jimin 17712373
2      Komei  6536336
3   Ritsumin  7917721
4      Ishin  4907844
5     Kyosan  4483411
6    Kokumin  3481078
7      Reiwa  2280253
8     Shamin  1046012
9        NHK   987885
10 Anrakushi   269052
11    Kofuku   202278
12     Olive   167897
13   Rodosha    80055

Result:
       Party Vote
1      Jimin   18
2      Komei    7
3   Ritsumin    8
4      Ishin    5
5     Kyosan    5
6    Kokumin    3
7      Reiwa    2
8     Shamin    1
9        NHK    1
10 Anrakushi    0
11    Kofuku    0
12     Olive    0
13   Rodosha    0

Parameters:
  Allocation method: D'Hondt (Jefferson) method 
  Extra parameter: 
  Threshold: 0 

Magnitude: 50
japan_2021 <- prcalc(jp_lower_2021,
                     m = c(8, 14, 20, 21, 17, 11, 21, 30, 11, 6, 21),
                     method = "hare")
japan_2021
Raw:
        Party Hokkaido  Tohoku Kitakanto Minamikanto   Tokyo Hokuriku   Tokai
1       Jimin   863300 1628233   2172065     2590787 2000084  1468380 2515841
2       Komei   294371  456287    823930      850667  715450   322535  784976
3    Ritsumin   682913  991505   1391149     1651562 1293281   773076 1485947
4      Kyosan   207189  292830    444115      534493  670340   225551  408606
5       Ishin   215344  258690    617531      863897  858577   361476  694630
6     Kokumin    73621  195754    298056      384482  306180   133600  382734
7      Shamin    41248  101442     97963      124447   92995    71185   84220
8       Reiwa   102086  143265    239592      302675  360387   111281  273208
9         NHK    42916   52664     87702      111298   92353    43529   98238
10 Shijinashi    46142       0         0           0       0        0       0
11    Daiichi        0       0         0           0   33661        0       0
12     Yamato        0       0         0           0   16970        0       0
13     Corona        0       0         0           0    6620        0       0
     Kinki Chugoku Shikoku  Kyushu    Total
1  2407699 1352723  664805 2250966 19914883
2  1155683  436220  233407 1040756  7114282
3  1090666  573324  291871 1266801 11492095
4   736156  173117  108021  365658  4166076
5  3180219  286302  173826  540338  8050830
6   303480  113899  122082  279509  2593397
7   100980   52638   30249  221221  1018588
8   292483   94446   52941  243284  2215648
9   111539   36758   21285   98506   796788
10       0       0       0       0    46142
11       0       0       0       0    33661
12       0       0       0       0    16970
13       0       0       0       0     6620

Result:
        Party Hokkaido Tohoku Kitakanto Minamikanto Tokyo Hokuriku Tokai Kinki
1       Jimin        3      6         7           7     5        5     8     8
2       Komei        1      2         3           2     2        1     3     4
3    Ritsumin        2      3         5           5     4        3     5     4
4      Kyosan        1      1         1           2     2        1     1     2
5       Ishin        1      1         2           3     2        1     2    10
6     Kokumin        0      1         1           1     1        0     1     1
7      Shamin        0      0         0           0     0        0     0     0
8       Reiwa        0      0         1           1     1        0     1     1
9         NHK        0      0         0           0     0        0     0     0
10 Shijinashi        0      0         0           0     0        0     0     0
11    Daiichi        0      0         0           0     0        0     0     0
12     Yamato        0      0         0           0     0        0     0     0
13     Corona        0      0         0           0     0        0     0     0
   Chugoku Shikoku Kyushu Total
1        5       2      8    64
2        2       1      3    24
3        2       1      4    38
4        1       0      1    13
5        1       1      2    26
6        0       1      1     8
7        0       0      1     1
8        0       0      1     6
9        0       0      0     0
10       0       0      0     0
11       0       0      0     0
12       0       0      0     0
13       0       0      0     0

Parameters:
  Allocation method: Hare-Niemeyer quota 
  Extra parameter: 
  Threshold: 0 

Magnitude: 
   Hokkaido      Tohoku   Kitakanto Minamikanto       Tokyo    Hokuriku 
          8          14          20          21          17          11 
      Tokai       Kinki     Chugoku     Shikoku      Kyushu 
         21          30          11           6          21