Kendallknight: an R package for Kendall’s correlation coefficient

R
C++
Statistics
A solution that took me hours of ‘averaging’ Google search results and using my brain.
Author

Mauricio “Pachá” Vargas S.

Published

August 16, 2024

Motivation

Existing R packages, such as pcaPP, provide efficient implementations of the Kendall correlation coefficient. However, I wanted to create my own package exclusively for this purpose, without additional functions, and that it also allows to test hypothesis about the correlation coefficient.

Installation

You can install the development version from GitHub with:

remotes::install_github("pachadotdev/Kendallknight")

Usage

library(kendallknight)

x <- c(1, 2, 3, 4, 5)
y <- c(5, 4, 3, 2, 1)

kendall_cor(x, y)
kendall_cor_test(x, y, "two.sided")
> kendall_cor(x, y)
[1] -1

> kendall_cor_test(x, y, "two.sided")
$statistic
[1] -1

$p_value
[1] 0.01666667

$alternative
[1] "alternative hypothesis: true tau is not equal to 0"

Details

The package is mostly implemented in C++ using cpp11 to export the functions to R.

See more