View source: R/seat-distribution.R
get_seats | R Documentation |
Calculate seat distribution from draws from posterior
get_seats(
dirichlet.draws,
survey,
distrib.fun = sls,
samplesize = NULL,
hurdle = 0.05,
others = "others",
...
)
dirichlet.draws |
Matrix containing random draws from posterior. |
survey |
The actual survey results on which |
distrib.fun |
Function to calculate seat distribution. Defaults to
|
samplesize |
Number of individuals participating in the |
hurdle |
The percentage threshold which has to be reached by a party to enter the parliament. Any party called "ssw" will be exempt from the hurdle. |
others |
A string indicating the name under which parties not listed explicitly are subsumed. |
... |
Further arguments passed to |
A data frame containing seat distributions for each simulation in
dirichlet.draws
draw_from_posterior
, sls
,
dHondt
library(coalitions)
library(dplyr)
# get the latest survey for a sample of German federal election polls
surveys <- get_latest(surveys_sample)
# simulate 100 seat distributions
surveys <- surveys %>% mutate(draws = purrr::map(survey, draw_from_posterior, nsim = 100),
seats = purrr::map2(draws, survey, get_seats))
surveys$seats
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.