Weighted Dependence Measures

Provides efficient implementations of weighted dependence measures and related asymptotic tests for independence. Implemented measures are the Pearson correlation, Spearman's rho, Kendall's tau, Blomqvist's beta, Hoeffding's D, and Chatterjee's xi; see, e.g., Nelsen (2006) , Hollander et al. (2015, ISBN:9780470387375), and Chatterjee (2021) .



output: github_document

wdm

R-CMD-check CRAN status CRAN downloads

R interface to the wdm C++ library, which provides efficient implementations of weighted dependence measures and related independence tests:

  • Pearson's rho
  • Spearman's rho
  • Kendall's tau
  • Blomqvist's beta
  • Hoeffding's D
  • Chatterjee's xi

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.

Installation

  • the stable release from CRAN:
install.packages("wdm")
  • the development version from GitHub with:
# install.packages("devtools")
install_submodule_git <- function(x, ...) {
  install_dir <- tempfile()
  system(paste("git clone --recursive", shQuote(x), shQuote(install_dir)))
  devtools::install(install_dir, ...)
}
install_submodule_git("https://github.com/tnagler/wdm-r")

Cloning

This repo contains wdm as a submodule. For a full clone use

git clone --recurse-submodules <repo-address>

Examples

library(wdm)
Dependence between two vectors
x <- rnorm(100)
y <- rpois(100, 1)
w <- runif(100)
wdm(x, y, method = "kendall")               # unweighted
#> [1] 0.04547414
wdm(x, y, method = "kendall", weights = w)  # weighted
#> [1] 0.07764891
Dependence in a matrix
x <- matrix(rnorm(100 * 3), 100, 3)
wdm(x, method = "spearman")               # unweighted
#>             [,1]        [,2]        [,3]
#> [1,]  1.00000000  0.10045005 -0.03279928
#> [2,]  0.10045005  1.00000000 -0.02744674
#> [3,] -0.03279928 -0.02744674  1.00000000
wdm(x, method = "spearman", weights = w)  # weighted
#>             [,1]       [,2]        [,3]
#> [1,]  1.00000000 0.22080359 -0.05369922
#> [2,]  0.22080359 1.00000000  0.01192067
#> [3,] -0.05369922 0.01192067  1.00000000

Chatterjee's xi measures the dependence of the second argument on the first, so reversing the arguments can change the result:

wdm(x[, 1], x[, 2], method = "chatterjee")
#> [1] 0.01740174
wdm(x[, 2], x[, 1], method = "chatterjee")
#> [1] 0.03510351
Independence test
x <- rnorm(100)
y <- rpois(100, 1)
w <- runif(100)
indep_test(x, y, method = "kendall")               # unweighted
#>     estimate statistic   p_value n_eff  method alternative
#> 1 0.02140979 0.2799245 0.7795354   100 kendall   two-sided
indep_test(x, y, method = "kendall", weights = w)  # weighted
#>     estimate statistic   p_value   n_eff  method alternative
#> 1 0.04616801 0.5015067 0.6160145 71.2503 kendall   two-sided

For Chatterjee's xi, x is the predictor and y is the response. Its natural one-sided alternative is "greater":

indep_test(x, y, method = "chatterjee", alternative = "greater")
#>      estimate statistic   p_value n_eff     method alternative
#> 1 -0.04496517 -0.576012 0.7176965   100 chatterjee     greater

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("wdm")

0.3.0 by Thomas Nagler, 2 months ago


https://tnagler.github.io/wdm-r/, https://github.com/tnagler/wdm-r


Report a bug at https://github.com/tnagler/wdm-r/issues


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


Authors: Thomas Nagler [aut, cre]


Documentation:   PDF Manual  


MIT + file LICENSE license


Imports Rcpp

Suggests testthat, Hmisc, copula, covr

Linking to Rcpp


Imported by CondCopulas, ElliptCopulas, MMDCopula, TSEAL, svines, wdnet.

Suggested by correlation, lcopula.

Linked to by portvine, rvinecopulib, vinereg.


See at CRAN