Weight your survey
weight_to.Rd
Generate statistical weights for your survey responses to better represent some population of interest.
Usage
weight_to(
data,
target = "us_genpop_acs18",
auto.remove = TRUE,
initial.weights = NULL,
trim.weights = c(0.01, 0.99),
verbose = TRUE
)
Arguments
- data
input data frame of survey responses.
- target
either name of target population (run
list_targets()
for options) or a list of dataframes corresponding to different population distributions to weight survey to.- auto.remove
remove any weighting variables that can't be found in survey.
- initial.weights
initial set of weights as starting point for raking algorithm.
- trim.weights
percentiles to trim your weights (default are 0.01 and .99, or 1% and 99%); can specify either an upper percentile or both a lower and upper percentile.
- verbose
output helpful progress and warning messages (recommended).
Details
The default SurveyMonkey to weight surveys is via raking. For an overview of raking, see this guide.
Examples
if (FALSE) { ## not run
data("smda23")
tgt <- get_target("us_genpop_acs19")
wtd <- weight_to(smda23, target = tgt)
hist(wtd$weights)
print(wtd$weight.summary)
}