indep_test: Independence Tests for Weighted Dependence Measures

Description Usage Arguments Details Examples

View source: R/indep_test.R

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

1
2
3
4
5
6
7
8
indep_test(
  x,
  y,
  method = "pearson",
  weights = NULL,
  remove_missing = TRUE,
  alternative = "two-sided"
)

Arguments

x, y

numeric vectors of data values. x and y must have the same length.

method

the dependence measure; see Details for possible values.

weights

an optional vector of weights for the observations.

remove_missing

if TRUE, all (pairswise) incomplete observations are removed; if FALSE, the function throws an error if there are incomplete observations.

alternative

indicates the alternative hypothesis and must be one of "two-sided", "greater" or "less". You can specify just the initial letter. "greater" corresponds to positive association, "less" to negative association.

Details

Available methods:

Partial matching of method names is enabled. All methods except "hoeffding" work with discrete variables.

Examples

1
2
3
4
5
6
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

wdm documentation built on Aug. 2, 2020, 5:06 p.m.