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      自民 17712373
2      公明  6536336
3      立憲  7917721
4      維新  4907844
5      共産  4483411
6      国民  3481078
7    れいわ  2280253
8      社民  1046012
9       N国   987885
10   安楽死   269052
11     幸福   202278
12 オリーブ   167897
13   労働者    80055

Result:
      Party Vote
1      自民   18
2      公明    7
3      立憲    8
4      維新    5
5      共産    5
6      国民    3
7    れいわ    2
8      社民    1
9       N国    1
10   安楽死    0
11     幸福    0
12 オリーブ    0
13   労働者    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    自民   863300 1628233   2172065     2590787 2000084  1468380 2515841
2    公明   294371  456287    823930      850667  715450   322535  784976
3    立憲   682913  991505   1391149     1651562 1293281   773076 1485947
4    共産   207189  292830    444115      534493  670340   225551  408606
5    維新   215344  258690    617531      863897  858577   361476  694630
6    国民    73621  195754    298056      384482  306180   133600  382734
7    社民    41248  101442     97963      124447   92995    71185   84220
8    れ新   102086  143265    239592      302675  360387   111281  273208
9     N党    42916   52664     87702      111298   92353    43529   98238
10 支なし    46142       0         0           0       0        0       0
11   第一        0       0         0           0   33661        0       0
12 やまと        0       0         0           0   16970        0       0
13 コロナ        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    自民        3      6         7           7     5        5     8     8
2    公明        1      2         3           2     2        1     3     4
3    立憲        2      3         5           5     4        3     5     4
4    共産        1      1         1           2     2        1     1     2
5    維新        1      1         2           3     2        1     2    10
6    国民        0      1         1           1     1        0     1     1
7    社民        0      0         0           0     0        0     0     0
8    れ新        0      0         1           1     1        0     1     1
9     N党        0      0         0           0     0        0     0     0
10 支なし        0      0         0           0     0        0     0     0
11   第一        0      0         0           0     0        0     0     0
12 やまと        0      0         0           0     0        0     0     0
13 コロナ        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