Computes a (possibly weighted) dependence measure between
these are vectors. If
y are matrices then the measure between the
x and the columns of
y are computed.
indep_test( x, y, method = "pearson", weights = NULL, remove_missing = TRUE, alternative = "two-sided" )
numeric vectors of data values.
the dependence measure; see Details for possible values.
an optional vector of weights for the observations.
indicates the alternative hypothesis and must be one of
"pearson": Pearson correlation
"spearman": Spearman's \(\rho\)
"kendall": Kendall's \(\tau\)
"blomqvist": Blomqvist's \(\beta\)
"hoeffding": Hoeffding's \(D\)
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#> estimate statistic p_value n_eff method alternative #> 1 -0.01762804 -0.2129434 0.8313711 100 kendall two-sidedindep_test(x, y, method = "kendall", weights = w) # weighted#> estimate statistic p_value n_eff method alternative #> 1 0.01242062 0.1281651 0.8980183 74.08639 kendall two-sided