make.audit: Make a fake audit given specified error for simulations

View source: R/KM_package.R

make.audit.from.ZR Documentation

Make a fake audit given specified error for simulations

Description

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

Usage

make.audit.from.Z(Z, N = 400, ...)

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,
  ...
)

Arguments

Z

elec.data 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.

N

The desired size of the new election.

...

other arguments to the method functions

method

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.

p_d

percent chance of error in precinct (for ok method)

swing

vote swing if batch has error (for ok method)

max.taint

maximum taint allowed in batch

print.race

print info on race to command line?

Details

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.

Value

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

Author(s)

Miratrix

See Also

truth.looker


elec documentation built on April 27, 2022, 1:05 a.m.