stark.test: Workhorse driver for stark.test

View source: R/elec_functions.R

stark.test.ZR Documentation

Workhorse driver for stark.test

Description

These main methods conduct the test of the election audit and returns a p-value and other related info on that test.

Usage

stark.test.Z(
  Z,
  calc.e_p = calc.pairwise.e_p,
  w_p = weight.function("no.weight"),
  max_err = maximumMarginBound,
  bound.col = Z$tot.votes.col,
  strat.col = NULL,
  drop = NULL,
  strat.method = NULL,
  err.override = NULL,
  n = NULL,
  t = NULL,
  q = NULL
)

stark.test(
  votes,
  audits,
  C.names = NULL,
  f = 1,
  pool = TRUE,
  pairwise = FALSE,
  ...
)

Arguments

Z

The object holding all the voting information. See below for details.

calc.e_p

The Function used to calculate maximum error bounds

w_p

The function used to calculate weights of error (A list of two functions)

max_err

Function to compute max error bounds for each precint

bound.col

Name (or column index) of column in the vote matrix corresponding to maximum number of votes allowed in precinct.

strat.col

Name of column that determines how to stratify if NULL will not stratify

drop

Either a vector of TRUE/FALSE or a name of a column in Z\$V of T/F values. Precincts identified by drop will be dropped from calculations.

strat.method

Not currently implemented.

err.override

If non-null, use this as the found error in votes rather than the actual errors found in the audit.

n

Elements of the test statistic. Can pass to avoid computation if those values are already known (e.g., for a simulation)

t

Elements of the test statistic. Can pass to avoid computation if those values are already known (e.g., for a simulation)

q

Elements of the test statistic. Can pass to avoid computation if those values are already known (e.g., for a simulation)

votes

data.frame of votes. Each row is precinct.

audits

data.frame of audits. Each row is precinct. Table reports overstatement by candidate.

C.names

Names of candidates (and names of cor columns in votes and audits tables. If NULL will derive from cols 2 on of votes

f

The number of winners

pool

If TRUE, combine small candidates into single pseudo-candidates to increase power

pairwise

if TRUE then do a pairwise test for all pairs and return highest p-value

...

Extra arguments passed directly to the work-horse method stark.test.Z

Details

It is an older method. Most likely CAST.audit or trinomial.audit should be used instead.

stark.test() will do the entire test. It is basically a driver function that sets up 'Z' matrix and passes buck to the stark.test.Z

The Z object, in particular has: Z\$V: The table of reported votes Z\$audit: The table of audits as differences from recorded votes

Value

Return an htest object with pvalue, some relevant statistics, and the Z object used (possibly constructed) that produced those results.

Author(s)

Luke W. Miratrix

See Also

See elec.data for description of the main object. See find.q and compute.stark.t for the main components of this test. find.stark.SRS.p is a utility function for computing a p-value for a specific situation. See weight.function for functions used to weight audit errors. See MaximumBound for a bound on error that one might use for these tests. See find.stratification for a utility for stratification.

Examples


## pretending that santa cruz audit was a SRS audit (which it was not)
data(santa.cruz)
Z = elec.data(santa.cruz, C.names=c("leopold","danner"))
data(santa.cruz.audit)
## do some work to get the audit totals to overstatements
rownames(santa.cruz.audit) = santa.cruz.audit$PID
Z$audit = audit.totals.to.OS(Z, santa.cruz.audit)
Z$audit
stark.test.Z(Z)



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