R interface to the wdm C++ library, which provides efficient implementations of weighted dependence measures and related independence tests:
All measures are computed in O(n log n) time, where n is the number of observations.
For a detailed description of the functionality, see the API documentation.
install.packages("wdm")
# install.packages("devtools")
<- function(x, ...) {
install_submodule_git <- tempfile()
install_dir system(paste("git clone --recursive", shQuote(x), shQuote(install_dir)))
::install(install_dir, ...)
devtools
}install_submodule_git("https://github.com/tnagler/wdm-r")
This repo contains wdm as a submodule. For a full clone use
git clone --recurse-submodules <repo-address>
library(wdm)
<- rnorm(100)
x <- rpois(100, 1) # all but Hoeffding's D can handle ties
y <- runif(100)
w wdm(x, y, method = "kendall") # unweighted
#> [1] -0.03093257
wdm(x, y, method = "kendall", weights = w) # weighted
#> [1] 0.04835766
<- matrix(rnorm(100 * 3), 100, 3)
x wdm(x, method = "spearman") # unweighted
#> [,1] [,2] [,3]
#> [1,] 1.00000000 0.2194659 -0.05435344
#> [2,] 0.21946595 1.0000000 0.11401140
#> [3,] -0.05435344 0.1140114 1.00000000
wdm(x, method = "spearman", weights = w) # weighted
#> [,1] [,2] [,3]
#> [1,] 1.0000000 0.2575236 -0.1689466
#> [2,] 0.2575236 1.0000000 0.1197442
#> [3,] -0.1689466 0.1197442 1.0000000
<- rnorm(100)
x <- rpois(100, 1) # all but Hoeffding's D can handle ties
y <- runif(100)
w indep_test(x, y, method = "kendall") # unweighted
#> estimate statistic p_value n_eff method alternative
#> 1 0.1278922 1.532215 0.1254693 100 kendall two-sided
indep_test(x, y, method = "kendall", weights = w) # weighted
#> estimate statistic p_value n_eff method alternative
#> 1 0.1704296 1.779486 0.07516007 79.6939 kendall two-sided