Skip to content

Feature/crispino nontransitive - #83

Merged
osorensen merged 4 commits into
mainfrom
feature/crispino-nontransitive
May 8, 2026
Merged

Feature/crispino nontransitive#83
osorensen merged 4 commits into
mainfrom
feature/crispino-nontransitive

Conversation

@osorensen

Copy link
Copy Markdown
Owner

No description provided.

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR adds support for a Bernoulli error model for pairwise-preference data (to handle non-transitive comparisons), introduces a Beta prior for the error probability epsilon, and returns/traces epsilon from the SMC run.

Changes:

  • Add error_model option ("none"/"bernoulli") and thread it through the C++ SMC pipeline.
  • Introduce epsilon as a static parameter with Beta prior hyperparameters kappa_1/kappa_2, and surface epsilon + epsilon_traces in the results.
  • Add a test for non-transitive pairwise preferences under the Bernoulli error model, plus NEWS/docs/version bumps.

Reviewed changes

Copilot reviewed 20 out of 20 changed files in this pull request and generated 7 comments.

Show a summary per file
File Description
tests/testthat/test-compute_sequentially_bernoulli.R Adds a test for Bernoulli error model on non-transitive pairwise preferences.
src/sample_latent_rankings.h Extends latent ranking proposal API with error_model.
src/sample_latent_rankings.cpp Implements Bernoulli-path latent ranking proposals for pairwise data.
src/run_smc.cpp Returns epsilon and epsilon_traces in the model output.
src/rejuvenate.cpp Updates rejuvenation to carry epsilon and includes a Gibbs-style epsilon update.
src/prior.h Adds kappa_1/kappa_2 to the prior struct.
src/prior.cpp Reads kappa_1/kappa_2 from the R prior list.
src/particle.h Adds epsilon to StaticParameters and updates constructors.
src/particle.cpp Initializes epsilon, passes error_model to proposals, and adds Bernoulli likelihood contribution for pairwise data.
src/parameter_tracer.h Adds epsilon_traces.
src/parameter_tracer.cpp Records epsilon over time when tracing is enabled.
src/options.h Adds error_model option field.
src/options.cpp Reads error_model from R options list.
R/set_smc_options.R Adds error_model argument and docs.
R/set_hyperparameters.R Adds kappa_1/kappa_2 hyperparameters and docs.
NEWS.md Documents the new Bernoulli error model and epsilon tracking.
man/set_smc_options.Rd Updates Rd for new error_model option.
man/set_hyperparameters.Rd Updates Rd for kappa_1/kappa_2.
DESCRIPTION Bumps package version to development version 0.3.0.9000.
CRAN-SUBMISSION Adds CRAN submission metadata file.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread src/prior.cpp Outdated
Comment on lines +9 to +10
kappa_1 { input_prior["kappa_1"] },
kappa_2 { input_prior["kappa_2"] } {}
Comment thread src/particle.cpp Outdated
Comment on lines +19 to +22
epsilon = Rcpp::rbeta(1, prior.kappa_1, prior.kappa_2)[0];
if (epsilon >= 0.5) {
epsilon = 0.4999; // Simple way to handle the truncation for the initial value
}
Comment thread src/rejuvenate.cpp Outdated
Comment on lines +164 to +167
double epsilon_prime = 1.0;
while (epsilon_prime >= 0.5) {
epsilon_prime = Rcpp::rbeta(1, prior.kappa_1 + total_a, prior.kappa_2 + total_b)[0];
}
Comment thread src/rejuvenate.cpp Outdated
Comment on lines +148 to +151
pairwise_tp new_data = pp->timeseries[t];
for (auto ndit = new_data.begin(); ndit != new_data.end(); ++ndit) {
total_p += ndit->second.size();
for (auto pair : ndit->second) {
Comment on lines +138 to +144
umat sort_matrix = new_sort_matrices[ndit->first];
int random_index = Rcpp::sample(sort_matrix.n_cols, 1, false)[0] - 1;

proposal.proposal.col(proposal_index++) = sort_matrix.col(random_index);
proposal.log_probability = join_vert(
proposal.log_probability, vec{-log(new_sort_counts[ndit->first])}
);
proposal.proposal.col(proposal_index++) = sort_matrix.col(random_index);
proposal.log_probability = join_vert(
proposal.log_probability, vec{-log(new_sort_counts[ndit->first])}
);
Comment on lines +22 to +38
# Run compute_sequentially
mod <- compute_sequentially(
df,
topological_sorts = top_sorts,
smc_options = set_smc_options(
n_particles = 100,
n_particle_filters = 5,
error_model = "bernoulli",
use_backward_simulation = TRUE
),
hyperparameters = set_hyperparameters(n_items = 3)
)

# Assertions
expect_true(!is.null(mod$epsilon))
expect_true(mean(mod$epsilon) > 0)
expect_true(mean(mod$epsilon) < 0.5)
Comment thread CRAN-SUBMISSION Outdated
@@ -0,0 +1,3 @@
Version: 0.3.0
…, fixed ranking conversion bug, and test fixes
@osorensen

Copy link
Copy Markdown
Owner Author

@copilot can you tell me if the updated commit passes your review?

Copilot AI commented May 8, 2026

Copy link
Copy Markdown
Contributor

@copilot can you tell me if the updated commit passes your review?

2aa3074 addresses the specific review comments I raised earlier, but I wouldn’t mark it as fully passing yet because the current R-CMD-check run is failing on ubuntu-latest (release) and ubuntu-latest (oldrel-1). Both failures are in tests/testthat/test-compute_sequentially_preferences.R (the expectations at lines 27 and 58), so the PR still needs follow-up before I’d call it clean.

@osorensen
osorensen merged commit 5228a57 into main May 8, 2026
5 checks passed
@osorensen
osorensen deleted the feature/crispino-nontransitive branch May 8, 2026 08:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants