library(knitr) opts_chunk$set(warning=FALSE)
The coalitions
package implements a Bayesian framework for the estimation of
event probabilities in multi-party electoral systems (Bauer et al., 2019) like Germany, Austria etc.
To support estimation, the package also implements scrappers that
obtain data for German federal and general elections as well as Austrian
general election. The implementation can be extended to support other elections.
To get started, see our workflow vignette
Check out our interactive shiny app on German (state and federal) elections/surveys
Updates are available from our KOALA_LMU twitter account!
# To install from CRAN use: install.packages("coalitions") # To install the most current version from GitHub use: devtools::install_github("adibender/coalitions")
Detailed workflow is outlined in the workflow vignette.
A short overview is presented below.
The wrapper get_surveys()
which takes no arguments, downloads all surveys
currently available at wahlrecht and
stores them in a nested tibble
:
library(coalitions) library(dplyr) library(tidyr) surveys <- get_surveys() surveys
Each row represents a polling agency and each row in the surveys
column again
contains a nested tibble
with survey results from different time-points:
surveys %>% filter(pollster == "allensbach") %>% unnest() survey <- surveys %>% unnest() %>% slice(1) survey %>% unnest()
For each survey (row) we can calculate the coalition probabilities
survey %>% get_probabilities(nsim=1e4) %>% unnest()
Bauer, Alexander, Andreas Bender, André Klima, and Helmut Küchenhoff. 2019. “KOALA: A New Paradigm for Election Coverage.” AStA Advances in Statistical Analysis, June. https://doi.org/10.1007/s10182-019-00352-6.
Bender, Andreas, and Alexander Bauer. 2018. “Coalitions: Coalition Probabilities in Multi-Party Democracies,” March. https://doi.org/10.21105/joss.00606.
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.