View source: R/get_mallows_loglik.R
get_mallows_loglik | R Documentation |
Compute either the likelihood or the log-likelihood value of the Mallows mixture model parameters for a dataset of complete rankings.
get_mallows_loglik(
rho,
alpha,
weights,
metric = c("footrule", "spearman", "cayley", "hamming", "kendall", "ulam"),
rankings,
observation_frequency = NULL,
log = TRUE
)
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 |
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.
Other rank functions:
compute_expected_distance()
,
compute_observation_frequency()
,
compute_rank_distance()
,
create_ranking()
,
sample_mallows()
# 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
)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.