A S4 class to represent ranking data
It is well understood that the ranking representation and ordering representation of ranking data can easily get confused. I thus use a S4 class to store all the information about the ranking data. This can avoid unnecessary confusions.
It is possible to store both complete and top-q rankings in the same RankData object. Three slots
q_ind are introduced for this purpose. Note that there is generally no need to specify these slots if your data set only contains
a single "q" level (for example all data are top-10 rankings). The "q" level for complete ranking should be
Moreover, if the rankings are organized in chunks of increasing "q" levels (for
example, top-2 rankings followed by top-3 rankings followed by top-5 rankings etc.), then slots
q_ind can also be inferred
correctly by the initializer. Therefore it is highly recommender that you organise the ranking matrix in this way and utilize the initializer.
an number to store number of ranked objects. If not provided, it will be inferred as the maximum ranking in the data set. As a result, it must be provided if the data is top-q ranking.
the number of observations. No need to be provided during initialization since it must be equal to sum of slot
the number of distinct rankings. No need to be provided during initialization since it must be equal to the number of rows of slot
a matrix that stores the ranking representation of distinct rankings. Each row contains one ranking. For top-q ranking, all unobserved objects have ranking
the number of observations for each distinct ranking corresponding to each row of
a numeric vector to store top-q ranking information. More information in details section.
a numeric vector to store number of observations for each chunk of top-q rankings.
a numeric vector to store the beginning and ending of each chunk of top-q rankings. The last element has to be
1 2 3 4 5 6 7 8 9 10
# creating a data set with only complete rankings rankmat <- replicate(10,sample(1:52,52), simplify = "array") countvec <- sample(1:52,52,replace=TRUE) rankdat <- new("RankData",ranking=rankmat,count=countvec) # creating a data set with both complete and top-10 rankings rankmat_in <- replicate(10,sample(1:52,52), simplify = "array") rankmat_in[rankmat_in>11] <- 11 rankmat_total <- cbind(rankmat_in, rankmat) countvec_total <- c(countvec,countvec) rankdat2 <- new("RankData",ranking=rankmat_total,count=countvec_total, nobj=52, topq=c(10,51))
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.