# NOT RUN {
# 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
)
# }
Run the code above in your browser using DataLab