get_mallows_loglik {BayesMallows} | R Documentation |
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
get_mallows_loglik(
rho,
alpha,
weights,
metric = c("footrule", "spearman", "cayley", "hamming", "kendall", "ulam"),
rankings,
observation_frequency = NULL,
log = TRUE
)
Arguments
rho |
A matrix of size |
alpha |
A vector of |
weights |
A vector of |
metric |
Character string specifying the distance measure to use.
Available options are |
rankings |
A matrix with observed rankings in each row. |
observation_frequency |
A vector of observation frequencies (weights) to apply to
each row in |
log |
A logical; if TRUE, the log-likelihood value is returned,
otherwise its exponential. Default is |
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.
See Also
Other rank functions:
compute_expected_distance()
,
compute_observation_frequency()
,
compute_rank_distance()
,
create_ranking()
,
sample_mallows()
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...
get_mallows_loglik(
rho = rbind(1:n_items, 1:n_items),
alpha = c(10, 10),
weights = c(0.5, 0.5),
metric = "kendall",
rankings = mydata,
log = FALSE
)
get_mallows_loglik(
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 <- compute_observation_frequency(mydata)
get_mallows_loglik(
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],
observation_frequency = freq_distr[, n_items + 1],
log = FALSE
)
get_mallows_loglik(
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],
observation_frequency = freq_distr[, n_items + 1],
log = TRUE
)