trinomial.bound {elec} | R Documentation |
trinomial.audit
converts the audited total counts for candidates to overstatements and
taints. trinomial.bound
calculates the trinomial bound given the size of an audit sample, the
number of non-zero errors, and the size of the small-error threshold.
It can also plot a contour of the distribution space, bounds, and alpha lines.
trinomial.audit(Z, audit) trinomial.bound(n = 11, k = 2, d = 40, e.max = 100, xlim = c(0.4, 1), ylim = c(0, 0.55), alpha.lvls = c(10), zero.threshold = 0.3, tick.lines = NULL, alpha.lwd = 2, bold.first = FALSE, plot = TRUE, p.value.bound = NULL, grid.resolution = 300, ... )
Z |
An elec.data object that is the race being audited. |
audit |
A data.frame with a column for each candidate and a row
for each audited precinct, holding the audit totals for each
candidate. An additional column, count , holds the number of
times that precinct was sampled (since sampling was done by replacement). |
n |
Size of the sample (not precincts, but samples which could potentially be multiple samples of the same precinct). |
k |
The number of positive taints found in sample. |
d |
The maximum size of a small taint. This is the threshold for being in the middle bin of the trinomial. All taints larger than d would be in the largest error bin. |
e.max |
The size of the largest error bin. Typically 100 (for percent) or 1. |
xlim |
Range of possible values of p0 worth considering |
ylim |
Range of possible values of pd worth considering |
alpha.lvls |
List of alphas for which bounds should be calculated. The first is the one that will be returned. The others will be graphed. |
zero.threshold |
Since the method calculates on a numerical grid, what difference between alpha and the calculated probabilty should be considered no difference. |
tick.lines |
A list of bounds. For these bound levels, add tick-lines (more faint lines) to graph |
alpha.lwd |
Line width for alpha line. |
bold.first |
TRUE/FALSE. Should first alpha line be in bold. |
plot |
Should a plot be generated. |
p.value.bound |
What is the bound (1/U) that would correspond to the entire margin. Finding the alpha corresponding to this bound is a method for finding the p-value for the trinomial bound test. |
grid.resolution |
How many divisions of the grid should there be? More gives greater accuracy in the resulting p-values and bounds. |
... |
Extra arguments passed to the plot command. |
Right now the p-value is computed in a clumsy, bad way. A grid of points over (0, xlim) X (0, ylim) is generated corresponding to values of p0 and pd, and for each point the mean of that distribution and the chance of generating an outcome as extreme as k is calculated. Then the set of points with an outcome close to alpha is extrated, and the corresponding bound is optimized over this subset. Not the best way to do things.
List with charactaristics of the audit and the final results.
n |
Size of sample. |
k |
Number of non-zero taints. |
d |
Threshold for what a small taint is. |
e.max |
The worst-case taint. |
max |
The upper confidence bound for the passed alpha-level. |
p |
A length three vector. The distribution (p0, pd, p1) that achieves the worst case. |
p.value |
The p.value for the test, if a specific worst-case bound 1/U was passed via p.value.bound. |
Luke W. Miratrix
See Luke W. Miratrix and Philip B. Stark. (2009) Election Audits using a Trinomial Bound. http://www.stat.berkeley.edu/~stark
See elec.data
for information on the object that holds
vote counts. See
tri.sample
for drawing the actual sample.
See tri.calc.sample
for figuring out how
many samples to draw. See tri.audit.sim
for simulating audits using this method. See CAST for an SRS audit method.
## Auditing Santa Cruz data(santa.cruz.audit) data(santa.cruz) Z = elec.data(santa.cruz, C.names=c("leopold","danner")) res = trinomial.audit( Z, santa.cruz.audit ) res plan = tri.calc.sample( Z, beta=0.75, guess.N = 10, p_d = 0.05, swing=10, power=0.9, bound="e.plus" ) ## Compute the bound. Everything is scaled by 100 (i.e. to percents) for easier numbers. trinomial.bound(n=res$n, k = res$k, d=100*plan$d, e.max=100, p.value.bound=100/plan$T, xlim=c(0.75,1), ylim=c(0.0,0.25), alpha.lvls=c(25), asp=1, main="Auditing Santa Cruz with Trinomial Bound" )