Bootstrapping experiment, with fractional counts of a ballot box.
testFraction.Rd
Starting from some number (astart
) of randomly-selected ballots, an
increasingly-large collection of randomly-selected ballots are counted. The
ballots are chosen independently without replacement for each experimental
unit; if you want to count decreasingly-sized portions of a single sample of
ballots, use testDeletions()
.
Usage
testFraction(
votes = NULL,
astart = NULL,
ainc = NULL,
arep = NULL,
trep = NULL,
rankMethod = "safeRank",
countMethod = "stv",
countArgs = list(),
exptName = NULL,
equiet = FALSE,
everbose = FALSE
)
Arguments
- votes
A numeric matrix: one row per ballot, one column per candidate
- astart
Starting number of ballots (min 2)
- ainc
Number of ballots to be added in each step. Must be non-negative.
- arep
Number of repetitions of the test on each step. Required to be non-
NULL
ifainc=0
&& is.null(trep)`.- trep
Limit on the total number of simulated elections. Required to be non-
NULL
ifainc=0 && is.null(arep)
.- rankMethod
"safeRank" (default), "elected", or "rank". "rank" is a total ranking of the candidates, with ties broken at random. "elected" assigns rank=1 to elected candidates, rank=2 for eliminated candidates.
- countMethod
countMethod "stv" (default) or "condorcet"
- countArgs
List of args to be passed to
countMethod
(in addition tovotes
)- exptName
stem-name of experimental units e.g. "E". If
NULL
, then a 3-character string of capital letters is chosen at random.- equiet
TRUE
to suppress all experimental output- everbose
TRUE
to produce diagnostic output from the experiment
Examples
data(food_election)
testFraction(food_election, countMethod="condorcet",
countArgs=list(safety=0.5,complete.ranking=TRUE))
#> Progress in counting condorcet ballots:
#> 10%, 20%, 30%, 40%, 50%, 60%, 70%, 80%, 90%, 100%
#>
#> Results of testFraction at 2023-01-18 01:51:21
#>
#> Dataset = food_election, countMethod = condorcet, rankMethod = safeRank
#>
#> | | safety| complete.ranking|
#> |:---------|------:|----------------:|
#> |countArgs | 0.5| TRUE|
#>
#>
#> | | astart| ainc| arep|
#> |:------------|------:|----:|----:|
#> |otherFactors | 2| 2| 1|
#>
#> Experiment ID, number of ballots in simulated election, ranks, winning margins:
#>
#> |exptID | nBallots| Oranges| Pears| Chocolate| Strawberries| Sweets| m.Oranges| m.Pears| m.Chocolate| m.Strawberries| m.Sweets|
#> |:------|--------:|-------:|-----:|---------:|------------:|------:|---------:|-------:|-----------:|--------------:|--------:|
#> |VHR1 | 2| 1| 4| 1| 4| 1| 4| 0| 5| 0| 3|
#> |VHR2 | 4| 3| 1| 1| 3| 5| 6| 4| 2| 12| 0|
#> |VHR3 | 6| 1| 1| 1| 1| 5| 8| 6| 5| 4| 0|
#> |VHR4 | 8| 4| 5| 1| 2| 3| 4| 0| 11| 4| 5|
#> |VHR5 | 10| 4| 4| 1| 2| 3| 0| 1| 13| 10| 5|
#> |VHR6 | 12| 4| 4| 1| 2| 3| 3| 0| 18| 5| 6|
#> |VHR7 | 14| 2| 4| 1| 2| 4| 8| 0| 14| 16| 2|
#> |VHR8 | 16| 2| 4| 1| 2| 4| 13| 0| 14| 26| 1|
#> |VHR9 | 18| 3| 5| 1| 2| 4| 6| 0| 16| 9| 9|
#> |VHR10 | 20| 3| 5| 1| 2| 4| 6| 0| 20| 6| 8|
testFraction(dublin_west, astart=20, ainc=10, arep=2, trep=3,
countMethod="stv", rankMethod="elected", equiet=FALSE)
#> Progress in counting stv ballots:
#> 33.3%, 66.7%, 100%
#>
#> Results of testFraction at 2023-01-18 01:51:21
#>
#> Dataset = dublin_west, countMethod = stv, rankMethod = elected
#>
#> | | astart| ainc| arep|
#> |:------------|------:|----:|----:|
#> |otherFactors | 20| 10| 2|
#>
#> Experiment ID, number of ballots in simulated election, ranks, winning margins:
#>
#> |exptID | nBallots| Bonnie| Burton| Ryan| Higgins| Lenihan| McDonald| Morrissey| Smyth| Terry| m.Bonnie| m.Burton| m.Ryan| m.Higgins| m.Lenihan| m.McDonald| m.Morrissey| m.Smyth| m.Terry|
#> |:------|--------:|------:|------:|----:|-------:|-------:|--------:|---------:|-----:|-----:|---------:|--------:|--------:|---------:|---------:|----------:|-----------:|---------:|--------:|
#> |IVR1 | 20| 2| 1| 1| 1| 1| 2| 2| 2| 2| 0.0000000| 3.366221| 1.306703| 5.509364| 6.509364| 3.090162| 0.9239122| 0.8668796| 2.282800|
#> |IVR2 | 30| 2| 1| 2| 1| 1| 2| 2| 2| 1| 2.0000000| 0.847273| 6.000000| 6.469400| 4.469400| 1.000000| 6.2854286| 0.0000000| 5.469400|
#> |IVR3 | 20| 1| 2| 2| 1| 1| 2| 1| 2| 2| 0.7476131| 2.000000| 4.290456| 3.965526| 1.965526| 1.000000| 0.7657261| 0.0000000| 5.181312|