
Implements Plug-in Bias-Corrected Estimators for Ranking Data
Source:R/imprr_direct.R
imprr_direct.RdThis function implements the bias correction of the ranking distribution using a paired anchor question.
Usage
imprr_direct(
data,
J = NULL,
main_q,
anc_correct = NULL,
population = "non-random",
assumption = "contaminated",
n_bootstrap = 200,
seed = 123456,
weight = NULL,
verbose = FALSE,
p_random = NULL
)Arguments
- data
The input dataset with ranking data.
- J
The number of items in the ranking question. Defaults to NULL, in which case it will be inferred from the data.
- main_q
Ranking question to be analyzed. When `main_q` is a single column name or unquoted symbol such as `my_ranking`, the function looks for `my_ranking_1`, `my_ranking_2`, `my_ranking_3`, and so on. You may also supply `main_q` directly as a character vector or unquoted `c(...)` expression of ranking columns such as `c(party, religion, gender, race)`.
- anc_correct
Optional indicator for passing the anchor question. If `NULL`, `p_random` is used when supplied; otherwise the function defaults to `p_random = 0` and applies no correction.
- population
Choice of the target population out of non-random respondents (default) or all respondents.
- assumption
Choice of identifying assumption when `population = "all"`: `uniform` assumes random respondents would have uniform counterfactual preferences, while `contaminated` assumes their counterfactual preferences match those of non-random respondents.
- n_bootstrap
Number of bootstraps. Defaults to 200.
- seed
Seed for
set.seedfor reproducibility.- weight
The name of the weight column in `data`. Defaults to `NULL`, which uses equal weights. This can also be supplied as a numeric vector or as an unquoted column name.
- verbose
Indicator for verbose output. Defaults to FALSE.
- p_random
Optional fixed proportion of random/inattentive respondents. When supplied, this overrides `anc_correct` and a message is shown if both are provided.
Value
A list with two elements:
- est_p_random
A data frame with summary statistics for the estimated proportion of random respondents, including columns
mean,lower, andupper(95% confidence interval).- results
A tibble with bias-corrected estimates grouped by
item,qoi(quantity of interest), andoutcome, including columnsmean,lower, andupper.
Examples
out <- imprr_direct(
identity,
main_q = c("party", "religion", "gender", "race"),
anc_correct = "anc_correct_identity",
n_bootstrap = 1,
seed = 123
)
#> No weight column supplied; using equal weights for all observations.
out$est_p_random
#> mean lower upper
#> 1 0.310536 0.310536 0.310536
head(out$results)
#> # A tibble: 6 × 6
#> item qoi outcome mean lower upper
#> <chr> <chr> <chr> <dbl> <dbl> <dbl>
#> 1 gender average rank Avg: gender 1.62 1.62 1.62
#> 2 gender marginal ranking Ranked 1 0.509 0.509 0.509
#> 3 gender marginal ranking Ranked 2 0.373 0.373 0.373
#> 4 gender marginal ranking Ranked 3 0.111 0.111 0.111
#> 5 gender marginal ranking Ranked 4 0.00670 0.00670 0.00670
#> 6 gender pairwise ranking v. party 0.916 0.916 0.916