Skip to content

Commit 4f2d408

Browse files
committed
updated docs
1 parent 2ba84ef commit 4f2d408

File tree

8 files changed

+74
-41
lines changed

8 files changed

+74
-41
lines changed

DESCRIPTION

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
Package: BayesMallowsSMC2
22
Type: Package
33
Title: Nested Sequential Monte Carlo for the Bayesian Mallows Model
4-
Version: 0.2.1.9000
4+
Version: 0.3.0
55
Authors@R: c(person("Oystein", "Sorensen",
66
email = "oystein.sorensen.1985@gmail.com",
77
role = c("aut", "cre"),

NEWS.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,9 @@
1+
# BayesMallowsSMC2 version 0.3.0
2+
3+
## New features
4+
5+
* Implemented Conditional Particle Filter with Independent Backward Simulation (CPF-IBS) to mitigate path degeneracy during the rejuvenation step. This can be enabled via `backward_sampling = TRUE` in `set_smc_options()`.
6+
17
# BayesMallowsSMC2 version 0.2.1
28

39
## Bug fixes

R/compute_sequentially.R

Lines changed: 24 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -76,11 +76,16 @@
7676
#' algorithm automatically performs resampling and rejuvenation steps when the
7777
#' effective sample size drops below the specified threshold.
7878
#'
79+
#' Rejuvenation steps can optionally use Particle Gibbs with Backward Simulation
80+
#' \\insertCite{Whiteley2010Discussion,Lindsten2013Backward}{BayesMallowsSMC2}, enabled via the `backward_sampling` argument in [set_smc_options()].
81+
#'
7982
#' The returned object has S3 methods for printing ([print.BayesMallowsSMC2]),
8083
#' summarizing ([summary.BayesMallowsSMC2]), and plotting ([plot.BayesMallowsSMC2]).
8184
#' For visualization of parameter evolution over time, see [trace_plot()].
8285
#'
8386
#' @references
87+
#' \insertAllCited{}
88+
#'
8489
#' \insertRef{10.1214/25-BA1564}{BayesMallowsSMC2}
8590
#'
8691
#' @export
@@ -100,31 +105,31 @@
100105
#' plot(mod, parameter = "alpha")
101106
#'
102107
compute_sequentially <- function(
103-
data,
104-
hyperparameters = set_hyperparameters(),
105-
smc_options = set_smc_options(),
106-
topological_sorts = NULL
107-
){
108+
data,
109+
hyperparameters = set_hyperparameters(),
110+
smc_options = set_smc_options(),
111+
topological_sorts = NULL
112+
) {
108113
rank_columns <- grepl("item[0-9]+", colnames(data))
109114
preference_columns <- grepl("top\\_item|bottom\\_item", colnames(data))
110115

111-
if(any(rank_columns)) {
112-
input_timeseries <- split(data, f = ~ timepoint) |>
113-
lapply(split, f = ~ user) |>
116+
if (any(rank_columns)) {
117+
input_timeseries <- split(data, f = ~timepoint) |>
118+
lapply(split, f = ~user) |>
114119
lapply(function(x) lapply(x, function(y) as.numeric(y[rank_columns])))
115120

116-
if(any(is.na(data[rank_columns]))) {
121+
if (any(is.na(data[rank_columns]))) {
117122
attr(input_timeseries, "type") <- "partial rankings"
118123
} else {
119124
attr(input_timeseries, "type") <- "complete rankings"
120125
}
121126
sort_matrices <- sort_counts <- list()
122-
} else if(sum(preference_columns) == 2) {
123-
if(is.null(topological_sorts)) {
127+
} else if (sum(preference_columns) == 2) {
128+
if (is.null(topological_sorts)) {
124129
stop("topological_sorts must be provided with preference data.")
125130
}
126-
input_timeseries <- split(data, f = ~ timepoint) |>
127-
lapply(split, f = ~ user) |>
131+
input_timeseries <- split(data, f = ~timepoint) |>
132+
lapply(split, f = ~user) |>
128133
lapply(function(x) lapply(x, function(y) as.matrix(y[preference_columns])))
129134
attr(input_timeseries, "type") <- "pairwise preferences"
130135

@@ -139,15 +144,16 @@ compute_sequentially <- function(
139144
stop("Something wrong with data")
140145
}
141146

142-
if(max(table(data$user)) > 1 &&
143-
attr(input_timeseries, "type") != "pairwise preferences") {
147+
if (max(table(data$user)) > 1 &&
148+
attr(input_timeseries, "type") != "pairwise preferences") {
144149
stop("Updated users not supported.")
145150
}
146151

147-
ret <- run_smc(input_timeseries, hyperparameters, smc_options,
148-
sort_matrices, sort_counts)
152+
ret <- run_smc(
153+
input_timeseries, hyperparameters, smc_options,
154+
sort_matrices, sort_counts
155+
)
149156

150157
class(ret) <- "BayesMallowsSMC2"
151158
ret
152159
}
153-

R/set_smc_options.R

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -48,11 +48,7 @@
4848
#' can be used to inspect the evolution of rankings over time but
4949
#' substantially increases memory usage. Defaults to `FALSE`.
5050
#' @param backward_sampling Logical specifying whether to use Particle Gibbs with
51-
#' Backward Simulation (PGBS) during the rejuvenation step. PGBS greatly improves
52-
#' mixing for static parameters like cluster probabilities and the error rate by
53-
#' eliminating path degeneracy in the latent variables. Since user preferences are
54-
#' conditionally independent, this utilizes $\\mathcal{O}(S)$ independent
55-
#' Backward Simulation (CPF-IBS). Defaults to `FALSE`.
51+
#' Backward Simulation (PGBS) \insertCite{Whiteley2010Discussion,Lindsten2013Backward}{BayesMallowsSMC2} during the rejuvenation step. Defaults to `FALSE`.
5652
#'
5753
#' @details
5854
#' The SMC2 algorithm uses a nested particle filter structure:
@@ -79,6 +75,9 @@
7975
#'
8076
#' @seealso [compute_sequentially()], [set_hyperparameters()]
8177
#'
78+
#' @references
79+
#' \insertAllCited{}
80+
#'
8281
#' @export
8382
#'
8483
#' @examples
@@ -127,11 +126,12 @@
127126
#' )
128127
#'
129128
set_smc_options <- function(
130-
n_particles = 1000, n_particle_filters = 50, max_particle_filters = 10000,
131-
resampling_threshold = n_particles / 2, doubling_threshold = .2,
132-
max_rejuvenation_steps = 20,
133-
metric = "footrule", resampler = "multinomial",
134-
latent_rank_proposal = "uniform", verbose = FALSE,
135-
trace = FALSE, trace_latent = FALSE, backward_sampling = FALSE) {
129+
n_particles = 1000, n_particle_filters = 50, max_particle_filters = 10000,
130+
resampling_threshold = n_particles / 2, doubling_threshold = .2,
131+
max_rejuvenation_steps = 20,
132+
metric = "footrule", resampler = "multinomial",
133+
latent_rank_proposal = "uniform", verbose = FALSE,
134+
trace = FALSE, trace_latent = FALSE, backward_sampling = FALSE
135+
) {
136136
as.list(environment())
137137
}

cran-comments.md

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -10,12 +10,9 @@
1010

1111
## Submission notes
1212

13-
This is a resubmission to fix test failures reported on CRAN checks for the BayesMallowsSMC2 package.
13+
This release introduces major algorithmic improvements for the SMC2 rejuvenation step.
1414

1515
### Changes in this version
1616

17-
* Adjusted numerical tolerance in `test-compute_sequentially_partial.R` (line 11) to account for platform-specific differences in Monte Carlo results. The test was failing on r-oldrel-macos and noLD platforms due to slight variations in the computed alpha_hat value (0.046 vs expected > 0.06). The tolerance has been relaxed from 0.06 to 0.04 to accommodate these platform differences while still ensuring the test validates the expected behavior.
18-
19-
## Previous submission
20-
21-
This package was initially released to CRAN as version 0.2.0. The test failures appeared after release on specific platforms (r-oldrel-macos and noLD) due to numerical differences in stochastic computations.
17+
* Implemented Conditional Particle Filter with Independent Backward Simulation (CPF-IBS) for the rejuvenation step. This resolves path degeneracy in latent variables during Particle Gibbs and improves mixing. It is available via the `backward_sampling` argument in `set_smc_options()`.
18+
* Retained numerical tolerance fixes from 0.2.1 that accommodated platform-specific variations on r-oldrel-macos and noLD.

inst/REFERENCES.bib

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,3 +9,23 @@ @article{10.1214/25-BA1564
99
doi = {10.1214/25-BA1564},
1010
URL = {https://doi.org/10.1214/25-BA1564}
1111
}
12+
13+
@article{Whiteley2010Discussion,
14+
author = {Whiteley, N.},
15+
title = {{Discussion on 'Particle Markov chain Monte Carlo methods'}},
16+
journal = {Journal of the Royal Statistical Society: Series B (Statistical Methodology)},
17+
volume = {72},
18+
number = {3},
19+
pages = {306--307},
20+
year = {2010}
21+
}
22+
@article{Lindsten2013Backward,
23+
title={{Backward simulation methods for Monte Carlo statistical inference}},
24+
author={Lindsten, Fredrik and Sch{\"o}n, Thomas B.},
25+
journal={Foundations and Trends{\textregistered} in Machine Learning},
26+
volume={6},
27+
number={1},
28+
pages={1--143},
29+
year={2013},
30+
publisher={Now Publishers, Inc.}
31+
}

man/compute_sequentially.Rd

Lines changed: 5 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

man/set_smc_options.Rd

Lines changed: 4 additions & 5 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)