make.audit: make.audit functions

Description Usage Arguments Details Value Author(s) See Also


Functions that make fake audits given a specified error mechanism and a object holding reported outcomes.


make.audit(Z = NULL, method = c("tweak", "opt.bad", "opt.bad.WPM", "opt.bad.packed", "opt.bad.packed.WPM", "ok", "no error"), p_d = 0.2, swing = 20, max.taint = 1, print.race = FALSE, ...)
make.audit.from.Z(Z, N = 400, ...)


Z object. For make.audit.from.Z, this is the large election, holding precincts with size, votes, etc., that get sampled to make an election of a requested number of batches.


the method of error generation. if "tweak" (the default), then add random amounts of swing to some precincts, and call that the "truth". The other methods generate the truth according to various metrics.


percent chance of error in precinct (for ok method)


vote swing if batch has error (for ok method)


maximum taint allowed in batch


print info on race to command line?


The desired size of the new election.


other arguments to the method functions


make.audit is to make the election results that can be sampled from with the simulator. This method generates the true taint and sampling weights of all precincts in the race. The taint is in column 'taint', sampling weights in 'e.max'

make.audit.from.Z Given the structure of some large election, make a small election by sampling batches (with replacement) from the full list. This first samples N precincts (and gets the totals from them) and then builds the 'truth' as normal using the make.audit() method. Note different calls to this will produce different margins based on precincts selected.

WARNING: It is concievable that the winner will flip due to the sampling, if the sample has too many batches for the loser.


Data frame with precinct information for the race. NOTE- The reported vote totals are just that, reported.



See Also


Search within the elec package
Search all R packages, documentation and source code

Questions? Problems? Suggestions? or email at

Please suggest features or report bugs with the GitHub issue tracker.

All documentation is copyright its authors; we didn't write any of that.