View source: R/kemenydesign_cpp.R
| kemenydesign_cpp | R Documentation |
Compute the design matrix for Kemeny distance calculation. This function uses an optimized C++ implementation for better performance.
kemenydesign_cpp(X)
X |
A N by M numeric matrix or vector, where each row represents a ranking of M objects. If X is a vector, it will be converted to a single-row matrix. |
This is a C++ reimplementation of the original kemenydesign
function for improved computational efficiency. The function processes all
pairwise comparisons between M objects, generating M*(M-1)/2 binary features
that encode the ranking structure.
The optimization provides significant speedup (typically 20-50x) compared to the R implementation, especially for large matrices.
A numeric matrix with N rows and M*(M-1)/2 columns. Each column represents a pairwise comparison between objects:
1: first object ranked lower (better) than second
-1: first object ranked higher (worse) than second
0: objects tied
Antonio D'Ambrosio antdambr@unina.it
D'Ambrosio, A. (2008). Tree based methods for data editing and preference rankings. Unpublished PhD Thesis. Universita' degli Studi di Napoli Federico II.
kemenydesign for the wrapper function
kemenyd for computing Kemeny distance using this design matrix
# Single ranking
x <- c(1, 3, 2, 4)
kemenydesign_cpp(x)
# Multiple rankings
X <- matrix(c(1,2,3,4,
4,3,2,1,
1,1,2,2), nrow=3, byrow=TRUE)
kemenydesign_cpp(X)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.