|
1 | | -#' Set SMC options |
2 | | -#' |
3 | | -#' @param n_particles Number of particles |
4 | | -#' @param n_particle_filters Initial number of particle filters for each |
5 | | -#' particle |
6 | | -#' @param max_particle_filters Maximum number of particle filters. |
7 | | -#' @param resampling_threshold Effective sample size threshold for resampling |
8 | | -#' @param doubling_threshold Threshold for particle filter doubling. If the |
9 | | -#' acceptance rate of the rejuvenation step falls below this threshold, the |
10 | | -#' number of particle filters is doubled. Defaults to 0.2. |
11 | | -#' @param max_rejuvenation_steps Maximum number of rejuvenation steps. If the |
12 | | -#' number of unique particles has not exceeded half the number of particles |
13 | | -#' after this many steps, the rejuvenation is still stopped. |
14 | | -#' @param metric Metric |
15 | | -#' @param resampler resampler |
16 | | -#' @param latent_rank_proposal latent rank proposal |
17 | | -#' @param verbose Boolean |
18 | | -#' @param trace Logical specifying whether to save static parameters at each |
19 | | -#' timestep. |
20 | | -#' @param trace_latent Logical specifying whether to sample and save one |
21 | | -#' complete set of latent rankings for each particle and each timepoint. |
22 | | -#' |
23 | | -#' @return A list |
| 1 | +#' Set SMC options for nested sequential Monte Carlo algorithm |
| 2 | +#' |
| 3 | +#' Configure parameters for the nested SMC2 algorithm used in sequential |
| 4 | +#' Bayesian Mallows model estimation. This function sets both outer-level |
| 5 | +#' (parameter particle) and inner-level (latent state particle filter) |
| 6 | +#' algorithm parameters. |
| 7 | +#' |
| 8 | +#' @details |
| 9 | +#' The nested SMC2 algorithm requires careful tuning of both levels: |
| 10 | +#' |
| 11 | +#' **Outer SMC Level**: Controls the number of parameter particles and their |
| 12 | +#' rejuvenation through MCMC moves. More particles provide better approximation |
| 13 | +#' but increase computational cost. |
| 14 | +#' |
| 15 | +#' **Inner SMC Level**: Each parameter particle maintains multiple particle |
| 16 | +#' filters for latent rankings. More filters improve latent state estimation |
| 17 | +#' but multiply computational cost by the number of parameter particles. |
| 18 | +#' |
| 19 | +#' @param n_particles Integer. Number of parameter particles in the outer SMC |
| 20 | +#' sampler. Each particle represents a sample from the posterior distribution |
| 21 | +#' of static parameters (alpha, rho, tau). Larger values improve posterior |
| 22 | +#' approximation accuracy but increase computational cost linearly. |
| 23 | +#' @param n_particle_filters Integer. Initial number of particle filters |
| 24 | +#' maintained by each parameter particle for sampling latent rankings and |
| 25 | +#' cluster assignments. This creates the nested structure where each of the |
| 26 | +#' `n_particles` parameter particles runs `n_particle_filters` inner particle |
| 27 | +#' filters. |
| 28 | +#' @param max_particle_filters Integer. Maximum number of particle filters |
| 29 | +#' allowed per parameter particle. The algorithm may double the number of |
| 30 | +#' filters when rejuvenation acceptance rates are low, up to this limit. |
| 31 | +#' @param resampling_threshold Numeric. Effective sample size threshold for |
| 32 | +#' triggering resampling of parameter particles. When ESS falls below this |
| 33 | +#' value, multinomial resampling is performed. Default is `n_particles / 2`. |
| 34 | +#' @param doubling_threshold Numeric. Acceptance rate threshold for particle |
| 35 | +#' filter doubling during rejuvenation. If the acceptance rate of MCMC |
| 36 | +#' rejuvenation moves falls below this threshold, the number of particle |
| 37 | +#' filters is doubled to improve mixing. Defaults to 0.2. |
| 38 | +#' @param max_rejuvenation_steps Integer. Maximum number of MCMC rejuvenation |
| 39 | +#' steps applied to parameter particles. Rejuvenation stops early if the |
| 40 | +#' number of unique particles exceeds half the total number of particles, |
| 41 | +#' indicating sufficient diversity. |
| 42 | +#' @param metric Character. Distance metric for the Mallows model. Options |
| 43 | +#' include "kendall", "cayley", "hamming", "footrule", "spearman", and "ulam". |
| 44 | +#' Different metrics capture different aspects of ranking disagreement. |
| 45 | +#' @param resampler Character. Resampling algorithm for parameter particles. |
| 46 | +#' Options include "multinomial", "residual", "stratified", and "systematic". |
| 47 | +#' Systematic resampling often provides better performance. |
| 48 | +#' @param latent_rank_proposal Character. Proposal mechanism for sampling |
| 49 | +#' latent rankings in the inner particle filters. Options include "uniform" |
| 50 | +#' and other problem-specific proposals. |
| 51 | +#' @param verbose Logical. Whether to print algorithm progress and diagnostics |
| 52 | +#' during execution. Useful for monitoring convergence and performance. |
| 53 | +#' @param trace Logical. Whether to save static parameter values (alpha, rho, |
| 54 | +#' tau) from all particles at each timestep. Enables detailed posterior |
| 55 | +#' analysis but increases memory usage. |
| 56 | +#' @param trace_latent Logical. Whether to sample and save one complete set |
| 57 | +#' of latent rankings for each parameter particle at each timepoint. Provides |
| 58 | +#' full posterior samples of latent states but significantly increases memory |
| 59 | +#' requirements. |
| 60 | +#' |
| 61 | +#' @return A list containing all SMC2 algorithm parameters for use in |
| 62 | +#' [compute_sequentially()]. |
| 63 | +#' |
| 64 | +#' @references |
| 65 | +#' Sørensen, Ø., Stein, A., Netto, W. L., & Leslie, D. S. (2025). |
| 66 | +#' Sequential Rank and Preference Learning with the Bayesian Mallows Model. |
| 67 | +#' \emph{Bayesian Analysis}. DOI: 10.1214/25-BA1564. |
| 68 | +#' |
| 69 | +#' @seealso [compute_sequentially()], [set_hyperparameters()] |
| 70 | +#' |
| 71 | +#' @examples |
| 72 | +#' # Basic SMC options for small problems |
| 73 | +#' basic_opts <- set_smc_options( |
| 74 | +#' n_particles = 100, |
| 75 | +#' n_particle_filters = 20, |
| 76 | +#' metric = "kendall" |
| 77 | +#' ) |
| 78 | +#' |
| 79 | +#' # High-precision options for larger problems |
| 80 | +#' precise_opts <- set_smc_options( |
| 81 | +#' n_particles = 1000, |
| 82 | +#' n_particle_filters = 100, |
| 83 | +#' max_particle_filters = 500, |
| 84 | +#' resampling_threshold = 500, |
| 85 | +#' metric = "footrule", |
| 86 | +#' resampler = "systematic", |
| 87 | +#' verbose = TRUE, |
| 88 | +#' trace = TRUE |
| 89 | +#' ) |
| 90 | +#' |
| 91 | +#' # Memory-efficient options |
| 92 | +#' efficient_opts <- set_smc_options( |
| 93 | +#' n_particles = 200, |
| 94 | +#' n_particle_filters = 30, |
| 95 | +#' trace = FALSE, |
| 96 | +#' trace_latent = FALSE, |
| 97 | +#' verbose = FALSE |
| 98 | +#' ) |
| 99 | +#' |
24 | 100 | #' @export |
25 | 101 | #' |
26 | 102 | set_smc_options <- function( |
|
0 commit comments