Title: | Weighted Dependence Measures |
Version: | 0.2.6 |
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). |
Depends: | R (≥ 3.2.0) |
License: | MIT + file LICENSE |
Encoding: | UTF-8 |
LinkingTo: | Rcpp |
Imports: | Rcpp |
RoxygenNote: | 7.3.2 |
URL: | https://github.com/tnagler/wdm-r |
BugReports: | https://github.com/tnagler/wdm-r/issues |
Suggests: | testthat, Hmisc, copula, covr |
NeedsCompilation: | yes |
Packaged: | 2025-01-07 19:24:12 UTC; n5 |
Author: | Thomas Nagler [aut, cre] |
Maintainer: | Thomas Nagler <mail@tnagler.com> |
Repository: | CRAN |
Date/Publication: | 2025-01-07 20:10:01 UTC |
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).
Details
The DESCRIPTION file:
This package was not yet installed at build time.
Author(s)
Maintainer: Thomas Nagler mail@tnagler.com
See Also
Useful links:
Independence Tests for Weighted Dependence Measures
Description
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.
Usage
indep_test(
x,
y,
method = "pearson",
weights = NULL,
remove_missing = TRUE,
alternative = "two-sided"
)
Arguments
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
|
Details
Available methods:
-
"pearson"
: Pearson correlation -
"spearman"
: Spearman's\rho
-
"kendall"
: Kendall's\tau
-
"blomqvist"
: Blomqvist's\beta
-
"hoeffding"
: Hoeffding'sD
Partial matching of method names is enabled.
All methods except "hoeffding"
work with discrete variables.
Examples
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) # weighted
Computing weighted ranks
Description
The weighted rank of X_i
among X_1, \dots, X_n
with weights
w_1, \dots, w_n
is defined as
\frac 1 n \sum_{j = 1}^n w_i 1[X_j \le X_i].
Usage
rank_wtd(x, weights = numeric(), ties_method = "average")
Arguments
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. |
Value
a vector of ranks.
Examples
x <- rnorm(100)
w <- rexp(100)
rank(x)
rank_wtd(x, w)
Weighted Dependence Measures
Description
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.
Usage
wdm(x, y = NULL, method = "pearson", weights = NULL, remove_missing = TRUE)
Arguments
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 |
Details
Available methods:
-
"pearson"
: Pearson correlation -
"spearman"
: Spearman's\rho
-
"kendall"
: Kendall's\tau
-
"blomqvist"
: Blomqvist's\beta
-
"hoeffding"
: Hoeffding'sD
Partial matching of method names is enabled.
Spearman's \rho
and Kendall's \tau
are corrected for ties if
there are any.
Examples
## 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