Learn R Programming

BayesMallows (version 1.1.0)

metropolis_hastings_alpha: Metropolis-Hastings Alpha

Description

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

Usage

metropolis_hastings_alpha(
  alpha,
  n_items,
  rankings,
  metric,
  rho,
  logz_estimate,
  alpha_prop_sd,
  lambda,
  alpha_max
)

Arguments

alpha

Numeric value of the scale parameter

n_items

Integer is the number of items in a ranking

rankings

the observed rankings, i.e, preference data

metric

A character string specifying the distance metric to use in the Bayesian Mallows Model. Available options are "footrule", "spearman", "cayley", "hamming", "kendall", and "ulam".

rho

Numeric vector specifying the current consensus ranking

logz_estimate

Estimate grid of log of partition function, computed with estimate_partition_function in the BayesMallow R package estimate_partition_function.

alpha_prop_sd

Numeric value specifying the standard deviation of the lognormal proposal distribution used for \(\alpha\) in the Metropolis-Hastings algorithm. Defaults to 0.1.

lambda

Strictly positive numeric value specifying the rate parameter of the truncated exponential prior distribution of \(\alpha\). Defaults to 0.1. When n_cluster > 1, each mixture component \(\alpha_{c}\) has the same prior distribution.

alpha_max

Maximum value of alpha in the truncated exponential prior distribution.

Value

alpha or alpha_prime: Numeric value to be used as the proposal of a new alpha

Details

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

Examples

Run this code
# NOT RUN {
rho <- c(1,2,3,4,5,6)
alpha <- 2
metric <- "footrule"
n_items <- 6
rankings <- sample_mallows(
	rho0 = rho, alpha0 = alpha, n_samples = 10, burnin = 1000, thinning = 500
)
alpha_vector <- seq(from = 0, to = 20, by = 0.1)
iter <- 1e2
degree <- 10

# Estimate the logarithm of the partition function of the Mallows rank model
# using the estimate partition function
logz_estimate <- estimate_partition_function(
	method = "importance_sampling", alpha_vector = alpha_vector,
	n_items = n_items, metric = "footrule", nmc = iter, degree = degree
)

metropolis_hastings_alpha(
	alpha, n_items, rankings, metric, rho, logz_estimate, alpha_prop_sd = 0.5,
	lambda = 0.1, alpha_max = 20
)

metropolis_hastings_alpha(
	alpha, n_items, rankings, metric, rho, logz_estimate,
	alpha_prop_sd = 0.15, lambda = 0.1, alpha_max = 20
)

metropolis_hastings_alpha(
	alpha, n_items, rankings, metric, rho, logz_estimate,
	alpha_prop_sd = 0.5, lambda = 0.15, alpha_max = 20
)

metropolis_hastings_alpha(
	alpha, n_items, rankings, metric, rho, logz_estimate,
	alpha_prop_sd = 0.15, lambda = 0.15, alpha_max = 20
)
# }

Run the code above in your browser using DataLab