Description Usage Arguments Value Examples
Trim survey weights. Wrapper for the trimWeights()
function in the survey
package that eliminates
the need to create a svydesign
object.
1 2 3 4 5 6 7 8 | trim_weights(
weight,
lower_quantile = 0.01,
upper_quantile = 0.99,
minval = NULL,
maxval = NULL,
strict = FALSE
)
|
weight |
A numeric vector of weights |
lower_quantile |
The quantile at which the weights should be trimmed on the lower end |
upper_quantile |
The quantile at which the weights should be trimmed on the upper end |
minval |
NULL by default. If the lower quantile is less than the minimum value, minval will be used for the trim. |
maxval |
NULL by default. If the upper quantile is greater than the maximum value, maxval will be used for the trim. |
strict |
When the trimmed weights are reapportioned, some values may exceed the specificed threshold value.
If |
A numeric vector of trimmed weights
1 2 3 4 5 | calculate_deff(dec13_excerpt$weight)
trimmed <- trim_weights(dec13_excerpt$weight, lower_quantile = 0.1, upper_quantile = 0.9)
# Trimming reduces the standard deviation of the weights, reducing reducing the design effect
# and increasing the effective sample size.
calculate_deff(trimmed)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.