Learn R Programming

ConsRank (version 3.0)

combinpmatr: Combined input matrix with C++ optimization

Description

Compute the Combined input matrix of a data set as defined by Emond and Mason (2002). This version uses C++ for improved performance.

Usage

combinpmatr(X, Wk = NULL, use_cpp = TRUE)

Value

The M by M combined input matrix

Arguments

X

A data matrix N by M, in which there are N judges and M objects to be judged. Each row is a ranking of the objects which are represented by the columns. Alternatively X can contain the rankings observed only once. In this case the argument Wk must be used

Wk

Optional: the frequency of each ranking in the data

use_cpp

Logical. If TRUE (default), use the optimized C++ implementation. If FALSE, use the original R implementation.

Author

Antonio D'Ambrosio antdambr@unina.it

Details

This function now uses an optimized C++ implementation (combinpmatr_impl) for improved performance. The original R implementation is preserved for reference and can be accessed by setting use_cpp = FALSE.

The C++ implementation provides significant speedup (typically 10-100x) compared to the R implementation, especially for large datasets with many judges and objects.

References

Emond, E. J., and Mason, D. W. (2002). A new rank correlation coefficient with application to the consensus ranking problem. Journal of Multi-Criteria Decision Analysis, 11(1), 17-28.

See Also

tabulaterows frequency distribution of a ranking data.

Examples

Run this code
# Simple example
X <- matrix(c(1,2,3,4, 2,1,4,3, 1,3,2,4), nrow=3, byrow=TRUE)
CI <- combinpmatr(X)

# With weights
CI_weighted <- combinpmatr(X, Wk=c(2, 1, 3))

# Compare implementations
if (FALSE) {
data(APAred) 
system.time(CI1 <- combinpmatr(APAred, use_cpp=TRUE))
system.time(CI2 <- combinpmatr(APAred, use_cpp=FALSE))
all.equal(CI1, CI2)  # Should be TRUE
}

Run the code above in your browser using DataLab