Learn R Programming

BayesMallows (version 1.4.0)

get_exponent_sum: Get exponent in Mallows log-likelihood

Description

Calculates the exponent Mallows log-likelihood given a set of rankings and a given rank sequence.

Usage

get_exponent_sum(alpha, rho, n_items, rankings, metric = "footrule")

Value

Exponent in the Mallows log likelihood. Note that it does not include the partition function, and since the partition function depends on alpha, this is not a likelihood per se.

Arguments

alpha

Numeric value of the scale parameter

rho

A ranking sequence

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.

metric

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

Author

Anja Stein

Examples

Run this code
set.seed(101)
rho <- t(c(1, 2, 3, 4, 5, 6))
alpha <- 2
metric <- "footrule"
n_items <- 6
get_exponent_sum(
  alpha = alpha, rho = rho, n_items = length(rho), rankings = rho,
  metric = metric
)

# return 0 because you are comparing the consensus ranking with itself
# if you change alpha or metric, then the result shall remain as 0

rankings <- sample_mallows(
  rho0 = rho, alpha0 = alpha, n_samples = 10, burnin = 1000, thinning = 500
)

# depending on your seed, you will get a different collection of rankings in R and C++

get_exponent_sum(
  alpha = alpha, rho = rho,  n_items = n_items, rankings = rankings ,
  metric = metric
)

Run the code above in your browser using DataLab