| Title: | Weighted Dependence Measures |
|---|---|
| Description: | 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, and Hoeffding's D; see, e.g., Nelsen (2006) <doi:10.1007/0-387-28678-0> and Hollander et al. (2015, ISBN:9780470387375). |
| Authors: | Thomas Nagler [aut, cre] |
| Maintainer: | Thomas Nagler <[email protected]> |
| License: | MIT + file LICENSE |
| Version: | 0.2.6 |
| Built: | 2026-06-01 08:14:56 UTC |
| Source: | https://github.com/tnagler/wdm-r |
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, and Hoeffding's D; see, e.g., Nelsen (2006) <doi:10.1007/0-387-28678-0> and Hollander et al. (2015, ISBN:9780470387375).
The DESCRIPTION file:
This package was not yet installed at build time.
Maintainer: Thomas Nagler [email protected]
Useful links:
Computes a (possibly weighted) dependence measure between x and y if
these are vectors. If x and y are matrices then the measure between the
columns of x and the columns of y are computed.
indep_test( x, y, method = "pearson", weights = NULL, remove_missing = TRUE, alternative = "two-sided" )indep_test( x, y, method = "pearson", weights = NULL, remove_missing = TRUE, alternative = "two-sided" )
x, y
|
numeric vectors of data values. |
method |
the dependence measure; see Details for possible values. |
weights |
an optional vector of weights for the observations. |
remove_missing |
if |
alternative |
indicates the alternative hypothesis and must be one of
|
Available methods:
"pearson": Pearson correlation
"spearman": Spearman's
"kendall": Kendall's
"blomqvist": Blomqvist's
"hoeffding": Hoeffding's
Partial matching of method names is enabled.
All methods except "hoeffding" work with discrete variables.
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 indep_test(x, y, method = "kendall", weights = w) # weightedx <- rnorm(100) y <- rpois(100, 1) # all but Hoeffding's D can handle ties w <- runif(100) indep_test(x, y, method = "kendall") # unweighted indep_test(x, y, method = "kendall", weights = w) # weighted
The weighted rank of among with weights
is defined as
rank_wtd(x, weights = numeric(), ties_method = "average")rank_wtd(x, weights = numeric(), ties_method = "average")
x |
a numeric vector. |
weights |
a vector of weights (same length as |
ties_method |
Indicates how to treat ties; same as in R, see https://stat.ethz.ch/R-manual/R-devel/library/base/html/rank.html. |
a vector of ranks.
x <- rnorm(100) w <- rexp(100) rank(x) rank_wtd(x, w)x <- rnorm(100) w <- rexp(100) rank(x) rank_wtd(x, w)
Computes a (possibly weighted) dependence measure between x and y if
these are vectors. If x and y are matrices then the measure between the
columns of x and the columns of y are computed.
wdm(x, y = NULL, method = "pearson", weights = NULL, remove_missing = TRUE)wdm(x, y = NULL, method = "pearson", weights = NULL, remove_missing = TRUE)
x |
a numeric vector, matrix or data frame. |
y |
|
method |
the dependence measure; see Details for possible values. |
weights |
an optional vector of weights for the observations. |
remove_missing |
if |
Available methods:
"pearson": Pearson correlation
"spearman": Spearman's
"kendall": Kendall's
"blomqvist": Blomqvist's
"hoeffding": Hoeffding's
Partial matching of method names is enabled.
Spearman's and Kendall's are corrected for ties if
there are any.
## 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 wdm(x, y, method = "kendall", weights = w) # weighted ## dependence in a matrix x <- matrix(rnorm(100 * 3), 100, 3) wdm(x, method = "spearman") # unweighted wdm(x, method = "spearman", weights = w) # weighted ## dependence between columns of two matrices y <- matrix(rnorm(100 * 2), 100, 2) wdm(x, y, method = "hoeffding") # unweighted wdm(x, y, method = "hoeffding", weights = w) # weighted## 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 wdm(x, y, method = "kendall", weights = w) # weighted ## dependence in a matrix x <- matrix(rnorm(100 * 3), 100, 3) wdm(x, method = "spearman") # unweighted wdm(x, method = "spearman", weights = w) # weighted ## dependence between columns of two matrices y <- matrix(rnorm(100 * 2), 100, 2) wdm(x, y, method = "hoeffding") # unweighted wdm(x, y, method = "hoeffding", weights = w) # weighted