choose_best_weighting: Use bootstrap resampling of survey to find best weighting...

Description Usage Arguments Details Value Examples

Description

Use bootstrap resampling of survey to find best weighting indicators

Usage

1
2
3
4
choose_best_weighting(inputfile, outputpath, n, response, ...)

choose_best_weighting_(inputfile, outputpath = "./wwc_weighted.csv", n,
  response_col, dots)

Arguments

inputfile

A file containing the input survey data (a survey data frame, such as that created by simulate_survey). Either a path to a file, a connection, or literal data (either a single string or a raw vector). Files starting with http://, https://, ftp://, or ftps:// will be automatically downloaded, and zipped files wll be uncompressed.

outputpath

Path to write a csv file of the output weighted results. The new file will contain the original survey data with 2 columns added, weight_best, the post-stratification weight for each row in the survey using the best indicators, and weight_all, the post-stratification weight for each row using all the indicators available. Default will write a csv to the working directory.

n

Number of bootstrap resamplings to generate in order to find the best weighting indicators

response

A column in mysurvey that contains the quantity to be weighted, such as the response to a yes/no question as in simulate_survey

...

Weighting indicator(s) to be tested for post-stratification. One or more of sex, raceethnicity, age, and/or education which must be columns in the survey data frame. Both age and education cannot be used for post-stratification at the same time because of how the ACS tables are organized.

response_col

Response column as string

dots

List of weighting indicator(s) as string(s)

Details

choose_best_weighting is given bare names while choose_best_weighting_ is given strings and is therefore suitable for programming with. One column of the survey data in inputfile must be geography, to indicate what ACS data to use for post-stratification weighting.

Value

A list of the best indicators. This function also saves a csv file of the output weighted results

Examples

1
2
3
4
 
tmp <- tempfile() 
choose_best_weighting(system.file("extdata/examplesurvey.csv", package = "WWC"), 
                      tmp, 5, response, sex, raceethnicity)

heathermkrause/WWC documentation built on May 17, 2019, 3:20 p.m.