Skip to content

tnagler/wdm-r

main
Switch branches/tags
Code

Latest commit

 

Git stats

Files

Permalink
Failed to load latest commit information.
Type
Name
Latest commit message
Commit time
R
 
 
 
 
man
 
 
 
 
src
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

wdm

R-CMD-check Coverage status CRAN status

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

  • Pearsons’s rho
  • Spearmans’s rho
  • Kendall’s tau
  • Blomqvist’s beta
  • Hoeffding’s D

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)  # all but Hoeffding's D can handle ties
w <- runif(100)
wdm(x, y, method = "kendall")               # unweighted
#> [1] -0.01835054
wdm(x, y, method = "kendall", weights = w)  # weighted
#> [1] -0.02273855
Dependence in a matrix
x <- matrix(rnorm(100 * 3), 100, 3)
wdm(x, method = "spearman")               # unweighted
#>            [,1]       [,2]       [,3]
#> [1,] 1.00000000 0.02384638 0.04360036
#> [2,] 0.02384638 1.00000000 0.09418542
#> [3,] 0.04360036 0.09418542 1.00000000
wdm(x, method = "spearman", weights = w)  # weighted
#>            [,1]       [,2]       [,3]
#> [1,] 1.00000000 0.09307647 0.08380492
#> [2,] 0.09307647 1.00000000 0.14823843
#> [3,] 0.08380492 0.14823843 1.00000000
Independence test
x <- rnorm(100)
y <- rpois(100, 1)  # all but Hoeffding's D can handle ties
w <- runif(100)
indep_test(x, y, method = "kendall")               # unweighted
#>      estimate  statistic   p_value n_eff  method alternative
#> 1 -0.07862879 -0.9162974 0.3595109   100 kendall   two-sided
indep_test(x, y, method = "kendall", weights = w)  # weighted
#>      estimate  statistic   p_value   n_eff  method alternative
#> 1 -0.06030227 -0.6043739 0.5455951 76.3268 kendall   two-sided

About

Weighted Dependence Measures

Topics

Resources

License

Unknown, MIT licenses found

Licenses found

Unknown
LICENSE
MIT
LICENSE.md

Stars

Watchers

Forks

Packages

No packages published