Efficient Implementation of Kendall's Correlation Coefficient Computation

The computational complexity of the implemented algorithm for Kendall's correlation is O(n log(n)), which is faster than the base R implementation with a computational complexity of O(n^2). For small vectors (i.e., less than 100 observations), the time difference is negligible. However, for larger vectors, the speed difference can be substantial and the numerical difference is minimal. The references are Knight (1966) , Abrevaya (1999) , Christensen (2005) and Emara (2024) < https://learningcpp.org/>. This implementation is described in Vargas Sepulveda (2025) .


kendallknight

Lifecycle:stable R-CMD-check CRANstatus Testcoverage BuyMeACoffee

About

Please read my article for the full details of this project (Open Access):

Vargas Sepulveda, Mauricio. 2025. ‘Kendallknight: An R package for efficient implementation of Kendall’s correlation coefficient computation’. PLOS ONE 20 (6): e0326090. https://doi.org/10.1371/journal.pone.0326090.

This package implements a different algorithm from the one implemented in base R, and it reduces the complexity of the Kendall’s correlation coefficient from O(n^2) to O(n log n) resulting in a runtime of nano seconds or minutes instead of minutes or hours. This package is written in C++ and uses cpp11 to export the functions to R. See the vignette for the mathematical details.

If this software is useful to you, please consider donating on Buy Me A Coffee. All donations will be used to continue improving kendallknight.

Installation

You can install the released version of kendallknight from CRAN with:

install.packages("kendallknight")

You can install the development version of kendallknight like so:

remotes::install_github("pachadotdev/kendallknight")

Examples

See the documentation and vignette: https://pacha.dev/kendallknight/.

Code of Conduct

Please note that the kendallknight project is released with a Contributor Code of Conduct. By contributing to this project, you agree to abide by its terms.

Reference manual

It appears you don't have a PDF plugin for this browser. You can click here to download the reference manual.

install.packages("kendallknight")

1.0.1 by Mauricio Vargas Sepulveda, 10 months ago


https://pacha.dev/kendallknight/, https://github.com/pachadotdev/kendallknight


Report a bug at https://github.com/pachadotdev/kendallknight/issues


Browse source code at https://github.com/cran/kendallknight


Authors: Mauricio Vargas Sepulveda [aut, cre] (ORCID: , Loader Catherine [ctb] (original stirlerr implementations in C (2000)) , Ross Ihaka [ctb] (original chebyshev_eval , gammafn and lgammacor implementations in C (1998))


Documentation:   PDF Manual  


Apache License (>= 2) license


Imports stats

Suggests knitr, rmarkdown, spelling, testthat

Linking to cpp4r


See at CRAN