View source: R/compute_observation_frequency.R
compute_observation_frequency | R Documentation |
Construct the frequency distribution of the distinct ranking
sequences from the dataset of the individual rankings. This can be of
interest in itself, but also used to speed up computation by providing
the observation_frequency
argument to compute_mallows()
.
compute_observation_frequency(rankings)
rankings |
A matrix with the individual rankings in each row. |
Numeric matrix with the distinct rankings in each row and the
corresponding frequencies indicated in the last (n_items+1)
-th
column.
Other rank functions:
compute_expected_distance()
,
compute_rank_distance()
,
create_ranking()
,
get_mallows_loglik()
,
sample_mallows()
# Create example data. We set the burn-in and thinning very low
# for the sampling to go fast
data0 <- sample_mallows(rho0 = 1:5, alpha = 10, n_samples = 1000,
burnin = 10, thinning = 1)
# Find the frequency distribution
compute_observation_frequency(rankings = data0)
# The function also works when the data have missing values
rankings <- matrix(c(1, 2, 3, 4,
1, 2, 4, NA,
1, 2, 4, NA,
3, 2, 1, 4,
NA, NA, 2, 1,
NA, NA, 2, 1,
NA, NA, 2, 1,
2, NA, 1, NA), ncol = 4, byrow = TRUE)
compute_observation_frequency(rankings)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.