Skip to content

Commit

Permalink
add example
Browse files Browse the repository at this point in the history
  • Loading branch information
YukiAtsusaka committed Nov 28, 2024
1 parent 2dfb3e8 commit 7b57fa3
Showing 1 changed file with 60 additions and 0 deletions.
60 changes: 60 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,66 @@ remotes::install_github(
)
```

## Example

``` r
data("identity")

head(identity)
# # A tibble: 6 × 16
# s_weight app_identity app_identity_1 app_identity_2 app_identity_3 app_identity_4
# <dbl> <chr> <dbl> <dbl> <dbl> <dbl>
# 1 0.844 1423 1 4 2 3
# 2 0.886 1423 1 4 2 3
# 3 2.96 3412 3 4 1 2
# 4 0.987 1423 1 4 2 3
# 5 1.76 4132 4 1 3 2
# 6 0.469 3124 3 1 2 4


# Perform bias correction via plug-in estimator
out_direct <- imprr_direct(
data = identity,
J = 4,
main_q = "app_identity",
anc_correct = "anc_correct_identity"
)

out_direct$results
# # A tibble: 44 × 6
# # Groups: item, qoi [16]
# item qoi outcome mean lower upper
# <chr> <chr> <chr> <dbl> <dbl> <dbl>
# 1 app_identity_1 average rank Avg: a… 3.27 3.24 3.33
# 2 app_identity_1 marginal rank… Ranked… 0.0407 0.0232 0.0496
# 3 app_identity_1 marginal rank… Ranked… 0.150 0.137 0.163
# 4 app_identity_1 marginal rank… Ranked… 0.305 0.275 0.336
# 5 app_identity_1 marginal rank… Ranked… 0.504 0.475 0.541
# 6 app_identity_1 pairwise rank… v. app… 0.357 0.333 0.374
# 7 app_identity_1 pairwise rank… v. app… 0.108 0.0739 0.136
# 8 app_identity_1 pairwise rank… v. app… 0.262 0.238 0.284
# 9 app_identity_1 top-k ranking Top-1 0.0407 0.0232 0.0496
# 10 app_identity_1 top-k ranking Top-2 0.306 0.291 0.339


# Perform bias correction via IPW
out_weights <- imprr_weights(
data = identity,
J = 4,
main_q = "app_identity",
anc_correct = "anc_correct_identity"
)

head(out_weights$rankings)
# ranking n prop_obs prop_bc weights prop_bc_raw prop_bc_adj
# 1 1234 14 0.012939002 0.000000000 0.0000000 -0.0003526508 0.000000000
# 2 1243 11 0.010166359 0.000000000 0.0000000 -0.0044081345 0.000000000
# 3 1324 14 0.012939002 0.000000000 0.0000000 -0.0003526508 0.000000000
# 4 1342 7 0.006469501 0.000000000 0.0000000 -0.0098154461 0.000000000
# 5 1423 50 0.046210721 0.046944603 1.0158812 0.0483131539 0.048313154
# 6 1432 20 0.018484288 0.007538549 0.4078355 0.0077583167 0.007758317
```

## Website

Please visit the [package site](https://sysilviakim.com/rankingQ/) for vignettes and references.

0 comments on commit 7b57fa3

Please sign in to comment.