Become an expert in R — Interactive courses, Cheat Sheets, certificates and more!
Get Started for Free

lik_db_mix

Likelihood and log-likelihood evaluation for a Mallows mixture model


Description

Compute either the likelihood or the log-likelihood value of the Mallows mixture model parameters for a dataset of complete rankings.

Usage

lik_db_mix(rho, alpha, weights, metric, rankings, obs_freq = NULL, log = FALSE)

Arguments

rho

A matrix of size n_clusters x n_items whose rows are permutations of the first n_items integers corresponding to the modal rankings of the Mallows mixture components.

alpha

A vector of n_clusters non-negative scalar specifying the scale (precision) parameters of the Mallows mixture components.

weights

A vector of n_clusters non-negative scalars specifying the mixture weights.

metric

Character string specifying the distance measure to use. Available options are "kendall", "cayley", "hamming", "ulam" for n_items<=95, "footrule" for n_items<=50 and "spearman" for n_items<=14.

rankings

A matrix with observed rankings in each row.

obs_freq

A vector of observation frequencies (weights) to apply to each row in rankings. This can speed up computation if a large number of assessors share the same rank pattern. Defaults to NULL, which means that each row of rankings is multiplied by 1. If provided, obs_freq must have the same number of elements as there are rows in rankings, and rankings cannot be NULL.

log

A logical; if TRUE, the log-likelihood value is returned. Default is FALSE.

Value

The likelihood or the log-likelihood value corresponding to one or more observed complete rankings under the Mallows mixture rank model with distance specified by the metric argument.

Examples

# Simulate a sample from a Mallows model with the Kendall distance

n_items <- 5
mydata <- sample_mallows(
  n_samples = 100,
  rho0 = 1:n_items,
  alpha0 = 10,
  metric="kendall")

# Compute the likelihood and log-likelihood values under the true model...
lik_db_mix(
  rho = rbind(1:n_items,1:n_items),
  alpha = c(10, 10),
  weights = c(0.5,0.5),
  metric = "kendall",
  rankings = mydata
  )

lik_db_mix(
  rho = rbind(1:n_items, 1:n_items),
  alpha = c(10, 10),
  weights = c(0.5, 0.5),
  metric = "kendall",
  rankings = mydata,
  log = TRUE
  )

# or equivalently, by using the frequency distribution
freq_distr <- rank_freq_distr(mydata)
lik_db_mix(
  rho = rbind(1:n_items,1:n_items),
  alpha = c(10, 10),
  weights = c(0.5, 0.5),
  metric = "kendall",
  rankings = freq_distr[, 1:n_items],
  obs_freq = freq_distr[,n_items+1]
  )

lik_db_mix(
  rho = rbind(1:n_items, 1:n_items),
  alpha = c(10, 10),
  weights=c(0.5, 0.5),
  metric = "kendall",
  rankings = freq_distr[, 1:n_items],
  obs_freq = freq_distr[, n_items+1],
  log=TRUE
  )

BayesMallows

Bayesian Preference Learning with the Mallows Rank Model

v1.0.1
GPL-3
Authors
Oystein Sorensen [aut, cre] (<https://orcid.org/0000-0003-0724-3542>), Valeria Vitelli [aut] (<https://orcid.org/0000-0002-6746-0453>), Marta Crispino [aut], Qinghua Liu [aut], Cristina Mollica [aut], Luca Tardella [aut]
Initial release

We don't support your browser anymore

Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.