View source: R/diagnose_weights.R
diagnose_weights | R Documentation |
This function assesses the convergence of data to target proportions given weights and returns diagnostic results.
diagnose_weights(data, target = NULL, weights = NULL)
data |
A data frame (tibble) or matrix containing all variables in the
|
target |
A list of target proportions in the population of interest.
This argument can be one of two formats: a list of named numeric vectors,
or a data frame (tibble) with three columns (variable, variable level, and
proportion) in order. No level may have a negative proportion or an NA, and
each variable should sum to 1. If this argument is not provided, and
|
weights |
Optionally, a numeric vector of weights equal in length to
the number of rows in |
A data frame with seven rows: "variable" (the variable among the
target variables), "level" (the specific value of that variable),
"prop_original" (the unweighted proportion in data
),
"prop_weighted" (the weighted proportion in data
),
"target" (the proportion expressed in target
),
"error_original" (absolute deviation in the unweighted data
),
"error_weighted" (absolute deviation in data
after applying
weights).
## Not run:
# Sample pipe workflow
respondent_data %>%
harvest(ns_target) %>%
diagnose_weights()
# Explicit calls
result = harvest(respondent_data, ns_target)
diagnose_weights(data=result,
target=ns_target,
weights=result$weights)
## End(Not run)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.