library(knitr)
opts_chunk$set(warning=FALSE)

coalitions

Travis-CI Build Status AppVeyor Build Status Coverage Status CRAN_Status_Badge MIT license

Overview

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.

Installation

# To install from CRAN use:
install.packages("coalitions")

# To install the most current version from GitHub use:
devtools::install_github("adibender/coalitions")

Usage

Detailed workflow is outlined in the workflow vignette.

A short overview is presented below.

Scrape surveys

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()

Calculate coalition probabilities

For each survey (row) we can calculate the coalition probabilities

survey %>% get_probabilities(nsim=1e4) %>% unnest()

References

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.



adibender/coalitions documentation built on July 23, 2024, 4:28 p.m.