|
1 | 1 | #' Set hyperparameters |
2 | 2 | #' |
| 3 | +#' Set the hyperparameters for the Bayesian Mallows model. This function |
| 4 | +#' creates a list of hyperparameter values that can be passed to |
| 5 | +#' [compute_sequentially()]. |
| 6 | +#' |
3 | 7 | #' @param n_items Integer defining the number of items. |
4 | | -#' @param alpha_shape Shape of gamma prior for alpha. |
5 | | -#' @param alpha_rate Rate of gamma prior for alpha. |
6 | | -#' @param cluster_concentration Concentration parameter of Dirichlet distribution for cluster probabilities. |
7 | | -#' @param n_clusters Integer defining the number of clusters. |
| 8 | +#' @param alpha_shape Shape parameter of the gamma prior distribution for the |
| 9 | +#' scale parameter alpha. Defaults to 1. |
| 10 | +#' @param alpha_rate Rate parameter of the gamma prior distribution for the |
| 11 | +#' scale parameter alpha. Defaults to 0.5. |
| 12 | +#' @param cluster_concentration Concentration parameter of the Dirichlet |
| 13 | +#' distribution for cluster probabilities. Only used when `n_clusters > 1`. |
| 14 | +#' Defaults to 10. |
| 15 | +#' @param n_clusters Integer defining the number of clusters. Defaults to 1. |
8 | 16 | #' |
9 | | -#' @return A list |
| 17 | +#' @return A list with components `n_items`, `alpha_shape`, `alpha_rate`, |
| 18 | +#' `cluster_concentration`, and `n_clusters`. |
10 | 19 | #' @export |
11 | 20 | #' |
| 21 | +#' @examples |
| 22 | +#' # Example: Set hyperparameters and use them with partial rankings |
| 23 | +#' # Set hyperparameters with default values |
| 24 | +#' hyperparams1 <- set_hyperparameters(n_items = 5) |
| 25 | +#' |
| 26 | +#' # Set hyperparameters with custom prior for alpha |
| 27 | +#' # A larger alpha_shape and smaller alpha_rate increases the prior mean |
| 28 | +#' hyperparams2 <- set_hyperparameters( |
| 29 | +#' n_items = 5, |
| 30 | +#' alpha_shape = 2, |
| 31 | +#' alpha_rate = 1 |
| 32 | +#' ) |
| 33 | +#' |
| 34 | +#' # Use the hyperparameters with compute_sequentially |
| 35 | +#' # This example uses partial rankings with a small number of particles |
| 36 | +#' # for fast execution suitable for CRAN checks |
| 37 | +#' set.seed(123) |
| 38 | +#' mod <- compute_sequentially( |
| 39 | +#' partial_rankings, |
| 40 | +#' hyperparameters = hyperparams2, |
| 41 | +#' smc_options = set_smc_options( |
| 42 | +#' n_particles = 20, |
| 43 | +#' n_particle_filters = 4, |
| 44 | +#' max_rejuvenation_steps = 3 |
| 45 | +#' ) |
| 46 | +#' ) |
| 47 | +#' |
12 | 48 | set_hyperparameters <- function( |
13 | 49 | n_items, alpha_shape = 1, alpha_rate = .5, cluster_concentration = 10, |
14 | 50 | n_clusters = 1) { |
|
0 commit comments