Learn R Programming

BayesMallows (version 1.4.0)

metropolis_hastings_rho: Metropolis-Hastings Rho

Description

Function to perform Metropolis-Hastings for new rho under the Mallows model with footrule distance metric!

Usage

metropolis_hastings_rho(
  alpha,
  n_items,
  rankings,
  rho,
  metric = "footnote",
  leap_size = 1L
)

Arguments

alpha

Numeric value of the scale parameter

n_items

Integer is the number of items in a ranking A matrix of size \(N \)\(\times\)\( n_items\) of rankings in each row. Alternatively, if \(N\) equals 1, rankings can be a vector.

rankings

A matrix of size \(N \)\(\times\)\( n_items\) of rankings in each row. Alternatively, if \(N\) equals 1, rankings can be a vector.

rho

A ranking sequence

metric

Character string specifying the distance measure to use. Available options are "kendall", "cayley", "hamming", "ulam", "footrule" and "spearman".

leap_size

Integer specifying the step size of the leap-and-shift proposal distribution.

Author

Anja Stein

Examples

Run this code
rho <- t(c(1,2,3,4,5,6))
alpha <- 2
metric <- "footrule"
n_items <- 6

metropolis_hastings_rho(
	alpha = alpha, n_items = n_items, rankings = rho, metric = metric,
	rho = rho, leap_size = 1
)

metropolis_hastings_rho(
	alpha = alpha, n_items = n_items, rankings = rho, metric = metric,
	rho = rho, leap_size = 2
)

metropolis_hastings_rho(
	alpha = alpha, n_items = n_items, rankings = rho, metric = metric,
	rho = rho, leap_size = 3
)

rankings <- sample_mallows(
 rho0 = rho, alpha0 = alpha, n_samples = 10, burnin = 1000, thinning = 500
)
metropolis_hastings_rho(
	alpha = alpha, n_items = n_items, rankings = rankings, metric = metric,
	rho = rho, leap_size = 1
)

Run the code above in your browser using DataLab