Learn R Programming

elec (version 0.1.2.2)

sim.race: Simulate CAST audits to assess performance

Description

Simulate a race (using the make.cartoon method) and run a CAST audit on that simulation. CAST is a system devised by Dr. Philip B., Stark, UC Berkeley Department of Statistics.

Usage

sim.race(
  n = 800,
  beta = 0.75,
  stages = 2,
  truth.maker = make.truth.opt.bad,
  print.trail = FALSE
)

Arguments

n

Desired sample size.

beta

the confidence level desired

stages

number of auditing stages. Each stage will have the same confidence level, determined by a function of beta.

truth.maker

Function to generate "truth"

print.trail

Print out diagnostics.

Value

A vector of 3 numbers. The first is the stage reached. The second is the total number of precincts audited. The third is 0 if the audit failed to certify (i.e. found large error in the final stage), and 1 if the audit certified the election (did not find large error in the final stage).

References

See http://www.stat.berkeley.edu/~stark/Vote/index.htm for relevant information.

See Also

See CAST.audit and CAST.calc.opt.cut for methods regarding CAST audits. Also see do.audit, make.sample, and make.truth for doing other simulation studies of this method.

Examples

Run this code
# NOT RUN {
     ## See how many times the CAST method fails to catch a wrong
     ##  election in 20 trials.
     replicate( 20, sim.race( beta=0.75, stages=2, truth.maker=make.truth.opt.bad) )

     ## Now see how much work the CAST method does for typical elections.
     replicate( 20, sim.race( beta=0.75, stages=2, truth.maker=make.ok.truth) )

# }

Run the code above in your browser using DataLab