Generate Constraint Set from Pairwise Comparisons
This function is relevant when compute_mallows
is called
repeatedly with the same data, e.g., when determining the
number of clusters. It precomputes a list of constraints used
internally by the MCMC algorithm, which otherwise would be
recomputed each time compute_mallows
is called.
generate_constraints(preferences, n_items, cl = NULL)
preferences |
Data frame of preferences. For the case of consistent
rankings, |
n_items |
Integer specifying the number of items. |
cl |
Optional computing cluster used for parallelization, returned
from |
A list which is used internally by the MCMC algorithm.
Crispino M, Arjas E, Vitelli V, Barrett N, Frigessi A (2019). “A Bayesian Mallows approach to nontransitive pair comparison data: How human are sounds?” The Annals of Applied Statistics, 13(1), 492–519. doi: 10.1214/18-aoas1203, https://doi.org/10.1214/18-aoas1203.
# Here is an example with the beach preference data. # First, generate the transitive closure. beach_tc <- generate_transitive_closure(beach_preferences) # Next, generate an initial ranking. beach_init_rank <- generate_initial_ranking(beach_tc) # Then generate the constrain set used intervally by compute_mallows constr <- generate_constraints(beach_tc, n_items = 15) # Provide all these elements to compute_mallows model_fit <- compute_mallows(rankings = beach_init_rank, preferences = beach_tc, constraints = constr) ## Not run: # The constraints can also be generated in parallel library(parallel) cl <- makeCluster(detectCores() - 1) constr <- generate_constraints(beach_tc, n_items = 15, cl = cl) stopCluster(cl) ## End(Not run)
Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.