View source: R/event_probabilities_from_event_list.R
election_event_probs | R Documentation |
election_event_probs()
takes an election
argument
(created by e.g. plurality_election()
or irv_election()
) and
returns a list containing, for each election event (i.e. each class of
election outcomes),
a scalar integral
indicating the probability of the event,
a matrix P
indicating which candidate elected (rows) as a
function of which action the voter takes (columns), and
other objects depending on the method used to compute the event probabilities.
election_event_probs(
election,
method = "sc",
mc_method = "density",
alpha = NULL,
mu = NULL,
precision = NULL,
sigma = NULL,
sims = NULL,
num_sims = 1e+05,
sim_window = 0.01,
cand_names = NULL,
drop_dimension = F,
merge_adjacent_pivot_events = F,
skip_non_pivot_events = T,
skip_compound_pivot_events = T,
minimum_volume = 0,
force_condition_based_mc = F,
store_time = T,
maxEvals = .Machine$integer.max,
tol = 0.01,
eval_points_for_1d_integral = 100,
ev_increments = 50,
en_increments_1st_round = 30,
en_increments_2nd_round = 100,
bw_divisor = 2,
...
)
election |
A list with elements |
method |
Method for estimating event probabilities: one of "sc" (SimplicialCubature), "mc" (Monte Carlo), "ev" (Eggers-Vivyan), or "en" (Eggers-Nowacki). See below for details. |
mc_method |
Method for Monte Carlo estimation of pivot event probabilities: one of "rectangular", "density", "naive_density". |
alpha |
Optional vector of parameters for Dirichlet distribution (one for each ballot type). In a plurality election with k candidates, should be of length k; in an ordinal system with 3 candidates, should be length 6. |
mu |
Optional vector of location parameters for Dirichlet distribution or logistic normal distribution. |
precision |
Optional scalar precision parameter for Dirichlet distribution. |
sigma |
Optional covariance matrix for logistic normal distribution. |
sims |
Optional matrix of simulated elections, one column per ballot type. |
num_sims |
Optional number of simulated elections, if not
provided in |
sim_window |
Vote share discrepancy within which two candidates will be
"nearly tied" when |
cand_names |
Optional vector of candidate names. If not supplied, will be "a", "b", "c", etc. |
drop_dimension |
Method "sc" can be sped up for pivot events by
integrating the belief function on facets where one candidate is exactly
1/2n behind the other (or they are exactly tied, if |
merge_adjacent_pivot_events |
If |
skip_non_pivot_events |
Set to |
skip_compound_pivot_events |
Set to |
minimum_volume |
If greater than zero, we check the volume of |
force_condition_based_mc |
Set to |
store_time |
By default we store the time each computation takes, in seconds. |
maxEvals |
The maximum number of function evaluations to compute an
integral via method "sc" (passed to
|
tol |
The relative error requested in computing an
integral via method "sc" (passed to
|
eval_points_for_1d_integral |
Sets the |
ev_increments |
Increments for numerical integration in method "ev". |
en_increments_1st_round |
Increments for numerical integration of first-round pivot events in method "en". |
en_increments_2nd_round |
Increments for numerical integration of second-round pivot events in method "en". |
bw_divisor |
If ks::hpi determines optimal bandwidth
for density estimation is h, we use h/bw_divisor when
|
There are four methods for computing the probability of a given election event:
"sc" (or "SC" or "SimplicialCubature") partitions the election event
into disjoint simplices and uses the SimplicialCubature to integrate the
belief function over these simplices using the adaptive algorithm of
Genz and Cools. Slow, but can be sped up by skipping non_pivot_events
(skip_non_pivot_events=T
), dropping a dimension
(drop_dimension=T
), merging adjacent pivot events
(merge_adjacent_pivot_events=T
), and/or (when relevant) skipping compound
pivot events (skip_compound_pivot_events=T
). Currently implemented only for
Dirichlet and Logistic Normal beliefs, but with some adjustment to the syntax
could be extended to handle other distributions (get in touch!).
"mc" (or "MC" or "Monte Carlo") counts the proportion of simulated elections
(supplied by the user or generated from user-supplied parameters) that satisfy
election event conditions. Also slow (especially with large num_sums
),
but like "sc" can be sped up. Can generate simulations from Dirichlet or Logistic Normal belief distributions, or can be applied to any matrix of simulated elections
supplied by the user.
"ev" (or "EV" or "Eggers-Vivyan") uses numerical integration of the Dirichlet distribution to estimate pivot event probabilities in plurality elections, making an independence assumption when there are more than four candidates. Fast but overstates the probability of low-probability events and limited to Dirichlet beliefs.
"en" (or "EN" or "Eggers-Nowacki") uses numerical integration of the Dirichlet distribution to estimate pivot event probabilities in three-candidate IRV elections up to an arbitrary degree of precision. Fast but limited to Dirichlet beliefs.
A list containing one list per election event. Each of these lower-level lists contains
integral
the event probability
P
the election probability matrix, indicating which candidate (rows)
is elected at this event depending on which action (columns) the voter takes.
seconds_elapsed
the time to compute this event probability.
For method "sc" these event-specific lists include other output from SimplicialCubature::adaptIntegrateSimplex()
, such as functionEvaluations
and message
.
alpha3 <- c(.4, .35, .25)*85
sc_out <- plurality_election(k = 3) %>%
election_event_probs(method = "sc", alpha = alpha3, tol = .1)
sc_out[["a_b"]]$integral
sc_out[["a_b"]]$seconds_elapsed
mc_out <- plurality_election(k = 3) %>%
election_event_probs(method = "mc", alpha = alpha3, num_sims = 500000)
mc_out[["a_b"]]$integral
mc_out[["a_b"]]$seconds_elapsed
mc_out <- plurality_election(k = 3) %>%
election_event_probs(method = "ev", alpha = alpha3)
mc_out[["a_b"]]$integral
mc_out[["a_b"]]$seconds_elapsed
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.