Making a strat.elec.data Object from a Votes data.frame and an Audit data.frame

Share:

Description

Makes a strat.elec.data and an elec.data object from a votes data.frame and an audit data.frame.

Usage

1
2
3
	strat.elec.data(V, C.names=names(V)[2:length(V)], f = 1, 
	audit=NULL, pool=TRUE, tot.votes.col="tot.votes", PID.col="PID", 
	strat.col = NULL, CID = NULL, auditTable = NULL)

Arguments

V

A data.frame of votes.

C.names

Names of candidates.

f

The number of winners.

audit

An audit data.frame.

pool

Combine small candidates into single pseudo-candidates to increase power.

tot.votes.col

Name of column that has the total votes for the batches.

PID.col

Name of column that identifies unique batches.

strat.col

Name of column in votes that identifies strata.

CID

A vector of length nrow(votes) that identifies strata.

auditTable

A data.frame of dimension length(unique(CID) x 2 used to identify the number of samples taken from each stratum. The auditTable is not necessary if an audit data.frame is included.

Details

strat.elec.data creates a strat.elec.data object: an elec.data object with additional entries for easy use with theelec.strat package.

strat.elec.data allows for two ways to specify the stratification:

  • Specify strat.col: the name of the column in V that contains strata information.

  • Provide a CID vector of length nrow(V) specifying the stratification.

If neither method is used to specify stratification, only an elec.data object is created.

If audit is not NULL and strat.col is provided, strat.elec.data will find the strat.col column in audit to create an auditTable. If no column in audit is labeled as strat.col, strat.elec.data will throw an error.

If audit is not NULL, strat.col is NULL, and CID is provided, strat.elec.data will try to find the column in audit labeled PID.col to generate the auditTable. If the PID.col column is not in audit, then auditTable will need to be given; otherwise Z$strat$audit defaults to a zero vector.

The argument auditTable should be a data.frame of dimensions unique(CID) x 2. The first column is a list of unique stratum IDs. The second column is the number of batches sampled within the corresponding stratum.

strat.elec.data first calls elec.data to create an elec object Z. An auditTable is either created through audit or given by the auditTable argument, and makeStratObj is called to create a strat.elec.data object.

For a detailed description of the structure of a strat.elec.data object, see makeStratObj. For a more detailed description of the arguments V, C.names, f, pool, audit, tot.votes.col, see elec.data.

Author(s)

Mike Higgins

See Also

See elec.data to create an elec.data object. See makeStratObj to create a strat.elec.data object from an elec.data object. Both elec.data and makeStratObj are called by strat.elec.data.

Examples

1
2
3
4
5
6
	data(MN_Senate_2006)
	votes <- MN_Senate_2006.strat$V
	audit <- MN_Senate_2006.strat$audit
	CID <- MN_Senate_2006.strat$V$CID
	names <- c("Klo","Ken")
	strat.elec.data(V = votes, C.names = names, audit = audit, CID = CID)