|
7 | 7 | #' |
8 | 8 | #' @param data A data frame containing ranking or preference data with temporal |
9 | 9 | #' structure. The data frame must include `timepoint` and `user` columns. |
10 | | -#' |
| 10 | +#' |
11 | 11 | #' For complete or partial rankings, additional columns should be: |
12 | 12 | #' \itemize{ |
13 | 13 | #' \item `timepoint`: Numeric vector denoting the timepoint, starting at 1. |
14 | 14 | #' \item `user`: Vector identifying the user providing the ranking. |
15 | 15 | #' \item `item1`, `item2`, etc.: Rankings of items (use NA for missing items |
16 | 16 | #' in partial rankings). |
17 | 17 | #' } |
18 | | -#' |
| 18 | +#' |
19 | 19 | #' For pairwise preferences, the structure should be: |
20 | 20 | #' \itemize{ |
21 | 21 | #' \item `timepoint`: Numeric vector denoting the timepoint, starting at 1. |
|
24 | 24 | #' \item `bottom_item`: Identifier for the less preferred item. |
25 | 25 | #' } |
26 | 26 | #' |
27 | | -#' @param hyperparameters A list of hyperparameters returned from |
| 27 | +#' @param hyperparameters A list of hyperparameters returned from |
28 | 28 | #' \code{\link{set_hyperparameters}}. Defines the prior distributions for |
29 | 29 | #' model parameters. |
30 | | -#' @param smc_options A list of SMC algorithm options returned from |
| 30 | +#' @param smc_options A list of SMC algorithm options returned from |
31 | 31 | #' \code{\link{set_smc_options}}. Controls the behavior of the particle |
32 | 32 | #' filtering algorithm. |
33 | | -#' @param topological_sorts A list returned from |
| 33 | +#' @param topological_sorts A list returned from |
34 | 34 | #' \code{\link{precompute_topological_sorts}}. Required when using pairwise |
35 | 35 | #' preference data, otherwise should be \code{NULL} (default). |
36 | 36 | #' |
|
42 | 42 | #' # Example with complete rankings |
43 | 43 | #' set.seed(123) |
44 | 44 | #' n_items <- 4 |
45 | | -#' |
| 45 | +#' |
46 | 46 | #' # Create synthetic ranking data |
47 | 47 | #' ranking_data <- data.frame( |
48 | 48 | #' timepoint = c(1, 1, 2, 2), |
|
52 | 52 | #' item3 = c(3, 4, 2, 4), |
53 | 53 | #' item4 = c(4, 3, 4, 2) |
54 | 54 | #' ) |
55 | | -#' |
| 55 | +#' |
56 | 56 | #' # Set up hyperparameters and options |
57 | 57 | #' hyper <- set_hyperparameters(n_items = n_items) |
58 | 58 | #' opts <- set_smc_options(n_particles = 100, verbose = FALSE) |
59 | | -#' |
60 | | -#' \dontrun{ |
61 | | -#' # Run sequential inference (requires compiled C++ code) |
| 59 | +#' |
| 60 | +#' # Run sequential inference |
62 | 61 | #' result <- compute_sequentially( |
63 | 62 | #' data = ranking_data, |
64 | 63 | #' hyperparameters = hyper, |
65 | 64 | #' smc_options = opts |
66 | 65 | #' ) |
67 | | -#' } |
68 | | -#' |
| 66 | +#' |
69 | 67 | #' @references |
70 | 68 | #' \insertRef{sorensen2025sequential}{BayesMallowsSMC2} |
71 | | -#' |
| 69 | +#' |
72 | 70 | #' @export |
73 | 71 | #' |
74 | 72 | compute_sequentially <- function( |
@@ -115,7 +113,7 @@ compute_sequentially <- function( |
115 | 113 | user_timepoint_combinations <- unique(data[c("user", "timepoint")]) |
116 | 114 | if(max(table(user_timepoint_combinations$user)) > 1) { |
117 | 115 | stop("Each user can only enter the pool once. Users appearing at multiple timepoints: ", |
118 | | - paste(names(table(user_timepoint_combinations$user))[table(user_timepoint_combinations$user) > 1], |
| 116 | + paste(names(table(user_timepoint_combinations$user))[table(user_timepoint_combinations$user) > 1], |
119 | 117 | collapse = ", ")) |
120 | 118 | } |
121 | 119 |
|
|
0 commit comments