Fits the Bayesian Mallows model to sequentially arriving ranking or preference data using the SMC2 (Sequential Monte Carlo Squared) algorithm. This function can handle complete rankings, partial rankings, and pairwise preference data, and supports mixture models with multiple clusters.
compute_sequentially(
data,
hyperparameters = set_hyperparameters(),
smc_options = set_smc_options(),
topological_sorts = NULL
)An object of class BayesMallowsSMC2, which is a list containing:
A matrix of dispersion parameter values with dimensions
[n_clusters, n_particles]. Each column represents one particle, and
each row represents one cluster.
A 3-dimensional array of latent ranking values with dimensions
[n_items, n_clusters, n_particles]. Entry [i, k, j] gives the rank
of item i in cluster k for particle j.
A matrix of precision parameter values (for mixture models) with
dimensions [n_clusters, n_particles]. Each column represents one particle.
A 3-dimensional array of cluster assignment
probabilities (for mixture models) with dimensions
[n_particles, n_users, n_clusters]. Only present when n_clusters > 1.
A numeric vector of length n_particles containing
the normalized importance weights for each particle.
A numeric vector of length n_timepoints containing the effective
sample size at each timepoint.
An integer vector of length n_timepoints indicating whether
resampling occurred at each timepoint (1 = yes, 0 = no).
An integer vector of length n_timepoints showing
the number of particle filters used at each timepoint.
A numeric value giving the estimated log marginal likelihood of the data.
A list of parameter traces (only if trace = TRUE in
set_smc_options()). Each element contains alpha values at one timepoint.
A list of parameter traces (only if trace = TRUE in
set_smc_options()). Each element contains tau values at one timepoint.
A list of parameter traces (only if trace = TRUE in
set_smc_options()). Each element contains rho values at one timepoint.
A list of importance weight traces
(only if trace = TRUE in set_smc_options()).
A list of latent ranking traces (only if
trace_latent = TRUE in set_smc_options()).
A dataframe containing partial rankings or pairwise preferences.
If data contains complete or partial rankings, it must have the following
columns:
timepoint: a numeric vector denoting the timepoint, starting at 1.
user: a vector identifying the user.
item1: ranking of item 1.
item2: ranking of item 2.
etc.
If data contains pairwise preferences, it must have the following structure:
timepoint: a numeric vector denoting the timepoint, starting at 1.
user: a vector identifying the user.
top_item: identifier for the preferred item.
bottom_item: identifier for the dispreferred item.
A list returned from set_hyperparameters().
A list returned from set_smc_options()
A list returned from
precompute_topological_sorts(). Only used with preference data, and
defaults to NULL.
The function implements the SMC2 algorithm for sequential Bayesian inference in the Mallows model. At each timepoint, it updates the particle approximation to the posterior distribution as new ranking or preference data arrives. The algorithm automatically performs resampling and rejuvenation steps when the effective sample size drops below the specified threshold.
The returned object has S3 methods for printing (print.BayesMallowsSMC2),
summarizing (summary.BayesMallowsSMC2), and plotting (plot.BayesMallowsSMC2).
For visualization of parameter evolution over time, see trace_plot().
10.1214/25-BA1564BayesMallowsSMC2
# Compute the model sequentially with complete rankings
mod <- compute_sequentially(
complete_rankings,
hyperparameters = set_hyperparameters(n_items = 5),
smc_options = set_smc_options(n_particles = 100, n_particle_filters = 1)
)
# Print the model summary
mod
# Plot posterior distribution of alpha
plot(mod, parameter = "alpha")
Run the code above in your browser using DataLab