Learn R Programming

BayesMallows (version 1.5.0)

run_mcmc: Worker function for computing the posterior distribution.

Description

Worker function for computing the posterior distribution.

Usage

run_mcmc(
  rankings,
  obs_freq,
  nmc,
  constraints,
  cardinalities,
  logz_estimate,
  rho_init,
  metric = "footrule",
  error_model = "none",
  Lswap = 1L,
  n_clusters = 1L,
  include_wcd = FALSE,
  leap_size = 1L,
  alpha_prop_sd = 0.5,
  alpha_init = 5,
  alpha_jump = 1L,
  lambda = 0.1,
  alpha_max = 1e+06,
  psi = 10L,
  rho_thinning = 1L,
  aug_thinning = 1L,
  clus_thin = 1L,
  save_aug = FALSE,
  verbose = FALSE,
  kappa_1 = 1,
  kappa_2 = 1,
  save_ind_clus = FALSE
)

Arguments

rankings

A set of complete rankings, with one sample per column. With n_assessors samples and n_items items, rankings is n_items x n_assessors.

obs_freq

A vector of observation frequencies (weights) to apply to the rankings.

nmc

Number of Monte Carlo samples.

constraints

List of lists of lists, returned from `generate_constraints`.

cardinalities

Used when metric equals "footrule" or "spearman" for computing the partition function. Defaults to R_NilValue.

logz_estimate

Estimate of the log partition function.

metric

The distance metric to use. One of "spearman", "footrule", "kendall", "cayley", or "hamming".

error_model

Error model to use.

Lswap

Swap parameter used by Swap proposal for proposing rank augmentations in the case of non-transitive pairwise comparisons.

n_clusters

Number of clusters. Defaults to 1.

include_wcd

Boolean defining whether or not to store the within-cluster distance.

leap_size

Leap-and-shift step size.

alpha_prop_sd

Standard deviation of proposal distribution for alpha.

alpha_init

Initial value of alpha.

alpha_jump

How many times should we sample rho between each time we sample alpha. Setting alpha_jump to a high number can significantly speed up computation time, since we then do not have to do expensive computation of the partition function.

lambda

Parameter of the prior distribution.

alpha_max

Maximum value of alpha, used for truncating the exponential prior distribution.

psi

Hyperparameter for the Dirichlet prior distribution used in clustering.

rho_thinning

Thinning parameter. Keep only every rho_thinning rank sample from the posterior distribution.

aug_thinning

Integer specifying the thinning for data augmentation.

clus_thin

Integer specifying the thinning for saving cluster assignments.

save_aug

Whether or not to save the augmented data every aug_thinningth iteration.

verbose

Logical specifying whether to print out the progress of the Metropolis-Hastings algorithm. If TRUE, a notification is printed every 1000th iteration.

kappa_1

Hyperparameter for \(theta\) in the Bernoulli error model. Defaults to 1.0.

kappa_2

Hyperparameter for \(theta\) in the Bernoulli error model. Defaults to 1.0.

save_ind_clus

Whether or not to save the individual cluster probabilities in each step, thinned as specified in argument clus_thin. This results in csv files cluster_probs1.csv, cluster_probs2.csv, ..., being saved in the calling directory. This option may slow down the code considerably, but is necessary for detecting label switching using Stephen's algorithm.