anesrakefinder: Function to determine what variables should be used for...

Description Usage Arguments Value Author(s)

Description

anesrake takes a list of variables and target values and determines which variables should be used for weighting in accordance with DeBell and Krosnick, 2009. Used as part of anesrake.

Usage

1
2
anesrakefinder(inputter, dataframe, weightvec = NULL,
choosemethod = "total")

Arguments

inputter

The inputter object should contain a list of all target values for the raking procedure. Each list element in inputter should be a vector corresponding to the weighting targets for a single variable. Hence, the vector enumerating the weighting targets for a variable with 2 levels should be of length 2, while a vector enumerating the weighting targets for a variable with 5 levels should be of length 5. List elements in inputter should be named according to the variable that they will match in the corresponding dataset. Hence, a list element enumerating the proportion of the sample that should be of each gender should be labeled "female" if the variable in dataframe is also titled "female."

inputter elements must be vectors and can be of class numeric, or factor and must match the class of the corresponding variable in dataframe. Logical variables in dataframe can be matched to a numeric vector of length 2 and ordered with the TRUE target as the first element and the FALSE target as the second element. Targets for factors must be labeled to match every level present in the dataframe (e.g. a variable with 2 age groups "under40" and "over40" should have elements named "under40" and "over40" respectively). anesrake attempts to conform any unrecognized types of vectors to class(numeric). Weighting targets can be entered either as an N to be reached or as a percent for any given variable. Targets can be either proportions (ideal) or the number of individuals in the population in each target category (N). Totals of greater than 1.5 for any given list element are treated as Ns, while values of less than 1.5 are treated as percentages.

dataframe

The dataframe command identifies a data.frame object of the data to be weighted. The data.frame must contain all of the variables that will be used in the weighting process and those variables must have the same names as are present in the inputter list element.

weightvec

weightvec is an optional input if some kind of base weights, stratification correction, or other sampling probability of note that should be accounted for before weighting is conducted. If defined, weightvec must be of a length equivalent to the number of cases in the dataframe. If undefined, weightvec will be automatically seeded with a vector of 1s.

choosemethod

choosemethod is the method for choosing most discrepant variables. Six options are available: choosemethod=c("total", "max", "average", "totalsquared", "maxsquared", "averagesquared"). If choosemethod="total", variable choice is determined by the sum of the differences between actual and target values for each prospective weighting variable. If choosemethod="max", variable choice is determined by the largest individual difference between actual and target values for each prospective weighting variable. If choosemethod="average", variable choice is determined by the mean of the differences between actual and target values for each prospective weighting variable. If choosemethod="totalsquared", variable choice is determined by the sum of the squared differences between actual and target values for each prospective weighting variable. If choosemethod="maxsquared", variable choice is determined by the largest squared difference between actual and target values for each prospective weighting variable (note that this is identical to choosemethod="max" if the selection type is nlim). If choosemethod="averagesquared", variable choice is determined by the mean of the squared differences between actual and target values for each prospective weighting variable.

Value

Returns a vector of variable names and discrepancies via the method chosen in choosemethod.

Author(s)

Josh Pasek, Assistant Professor of Communication Studies at the University of Michigan (www.joshpasek.com).


anesrake documentation built on May 2, 2019, 1:42 p.m.