BasicElectionForensics: Basic Election Forensics function

Description Usage Arguments Value Examples

View source: R/BasicElectionForensics.R

Description

This function helps to run basic election forensics methods: Benford's 2nd Digit, Last Digit (Counts), Counts (05s), Multimodality Test, Sobyanin-Sukhovolsky test and Correlation test.

Usage

1
2
BasicElectionForensics(data, Candidates, Level,
                             TotalReg, TotalVotes, Methods, R=1000, cores=2)

Arguments

data

data frame

Candidates

variable name referring to vote counts for candidates/parties

Level

variable name depicting the level of analysis ("National", i.e. whole dataset by default)

TotalReg

variable name for the total number of eligible voters

TotalVotes

variable name for the total number of ballots cast

Methods
  • "_2BL" - second-digit mean test (to be compared to the mean value Benford's Law)

  • "LastC" - last-digit mean test (to be compared to the mean value implied by uniformly distributed last digits)

  • "P05s" - percentage last-digit 0/5 indicator mean (to be compared to the mean value implied by uniformly distributed percentages)

  • "C05s" - count last-digit 0/5 indicator mean count (last-digit 0/5 indicator mean)

  • "Sobyanin" - Sobynin-Sukhovolsky measure

  • "Skew" - skewness (the extent to which a variable departs from a normal distribution by being asymmetric)

  • "Kurt" - Kurt (the extent to which a variable departs from a normal distribution by being spread out too much or not enough)

  • "DipT" - Unimodality test (tests whether the distribution of a variable departs from unimodality)

  • "Correlation" - correlation coefficient between turnout and vote share

R

number of simulations (1000 simulations by default)

cores

number of cores for parallel computing (2 cores by default)

Value

A list with the following parameters:

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
library(EFToolkit)

dat<-read.csv(system.file("Albania2013.csv", package="EFToolkit"))

#NB! R=100 to speed up computations for this example.
eldata<-BasicElectionForensics(dat,
                          Candidates=c("C035", "C050"),
                          Level="Prefectures", TotalReg="Registered",
                          TotalVotes="Ballots",
                          Methods=c("P05s", "C05s", "_2BL", "Sobyanin",
                         "DipT", "Skew", "Kurt", "Correlation"), cores=2, R=100)
eldata

kkalininMI/EFToolkit documentation built on Oct. 28, 2020, 1:47 a.m.