| step_trim_weights | R Documentation |
Caps weights into [lower, upper] and redistributes the change among the
untrimmed units to preserve the total, mirroring survey::trimWeights().
By default no weight may fall below 1, and the upper cap is chosen by an
automatic rule: the Tukey far-out fence (Q3 + 3*IQR) or, with
method = "potter", Potter's MSE-optimal cutoff.
step_trim_weights(
spec,
lower = 1,
upper = NULL,
method = c("tukey", "potter"),
strict = TRUE,
maxit = 50L
)
spec |
a weighting_spec. |
lower |
numeric. Lower floor (default 1: no weight below 1). |
upper |
numeric or NULL. Upper cap. If NULL, the cap is chosen
automatically by |
method |
rule for the automatic cap when |
strict |
logical. If TRUE (default), iterate cap+redistribution until no
weight is outside |
maxit |
integer. Maximum iterations when strict = TRUE. |
The input weighting_spec with this step appended to its recipe. The
step is recorded only; it is evaluated when prep() is called.
weighting_spec(sample_survey, base_weights = pw) |>
step_nonresponse(respondent = responded, method = "weighting_class", by = "region") |>
step_trim_weights(lower = 1, strict = TRUE) |> prep()
# Potter MSE-optimal cutoff chosen from the data
weighting_spec(sample_survey, base_weights = pw) |>
step_nonresponse(respondent = responded, method = "weighting_class", by = "region") |>
step_trim_weights(method = "potter") |> prep()
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.