Calculates distance covariance and distance correlation matrices
dcmatrix(
X,
Y = NULL,
calc.dcov = TRUE,
calc.dcor = TRUE,
calc.cor = "none",
calc.pvalue.cor = FALSE,
return.data = TRUE,
test = "none",
adjustp = "none",
b = 499,
affine = FALSE,
standardize = FALSE,
bias.corr = FALSE,
group.X = NULL,
group.Y = NULL,
metr.X = "euclidean",
metr.Y = "euclidean",
use = "all",
algorithm = "auto",
fc.discrete = FALSE,
calc.dcor.pw = FALSE,
calc.dcov.pw = FALSE,
test.pw = "none",
metr.pw.X = "euclidean",
metr.pw.Y = "euclidean"
)S3 object of class "dcmatrix" with the following components
description original data (if return.data = TRUE).
distance covariance/correlation matrices between the groups specified in group.X/group.Y (if calc.dcov/calc.dcor = TRUE).
correlation matrix between the univariate observations/columns (if cal.cor is "pearson", "spearman" or "kendall").
matrix of p-values based on a corresponding distance covariance test based on the entries in dcov (if argument test is not "none").
matrix of p-values adjusted for multiple comparisons using the method specified in argument adjustp.
matrix of pvalues based on "pearson"/"spearman" correlation (if calc.cor is "pearson" or "spearman" and calc.pvalue.cor = TRUE).
distance covariance/correlation matrices between the univariate observations (if calc.dcov.pw/calc.dcor.pw = TRUE.)
matrix of p-values based on a corresponding distance covariance test based on the entries in dcov.pw (if argument test is not "none").
A data.frame or matrix.
Either NULL or a data.frame or a matrix with the same number of rows as X. If only X is provided, distance covariances/correlations are calculated between all groups in X. If X and Y are provided, distance covariances/correlations are calculated between all groups in X and all groups of Y.
logical; specifies if the distance covariance matrix is calculated.
logical; specifies if the distance correlation matrix is calculated.
If set as "pearson", "spearman" or "kendall", a corresponding correlation matrix is additionally calculated.
logical; IF TRUE, a p-value based on the Pearson or Spearman correlation matrix is calculated (not implemented for calc.cor ="kendall") using Hmisc::rcorr.
logical; specifies if the dcmatrix object should contain the original data.
specifies the type of test that is performed, "permutation" performs a Monte Carlo Permutation test. "gamma" performs a test based on a gamma approximation of the test statistic under the null. "conservative" performs a conservative two-moment approximation. "bb3" performs a quite precise three-moment approximation and is recommended when computation time is not an issue.
If setting this parameter to "holm", "hochberg", "hommel", "bonferroni", "BH", "BY" or "fdr", corresponding adjusted p-values are additionally returned for the distance covariance test.
specifies the number of random permutations used for the permutation test. Ignored for all other tests.
logical; indicates if the affinely transformed distance covariance should be calculated or not.
specifies if data should be standardized dividing each component by its standard deviations. No effect when affine = TRUE.
logical; specifies if the bias corrected version of the sample distance covariance huo2016fastdcortools should be calculated.
A vector, each entry specifying the group membership of the respective column in X. Each group is handled as one sample for calculating the distance covariance/correlation matrices. If NULL, every sample is handled as an individual group.
A vector, each entry specifying the group membership of the respective column in Y. Each group is handled as one sample for calculating the distance covariance/correlation matrices. If NULL, every sample is handled as an individual group.
Either a single metric or a list providing a metric for each group in X (see examples).
see metr.X.
"all" uses all observations, "complete.obs" excludes NAs, "pairwise.complete.obs" uses pairwise complete observations for each comparison.
specifies the algorithm used for calculating the distance covariance.
"fast" uses an O(n log n) algorithm if the observations are one-dimensional and metr.X and metr.Y are either "euclidean" or "discrete", see also huo2016fast;textualdcortools.
"memsave" uses a memory saving version of the standard algorithm with computational complexity O(n^2) but requiring only O(n) memory.
"standard" uses the classical algorithm. User-specified metrics always use the classical algorithm.
"auto" chooses the best algorithm for the specific setting using a rule of thumb.
"memsave" is typically very inefficient for dcmatrix and should only be applied in exceptional cases.
logical; If TRUE, "discrete" metric is applied automatically on samples of type "factor" or "character".
logical; If TRUE, a distance correlation matrix between the univariate observations/columns is additionally calculated. Not meaningful if group.X and group.Y are not specified.
logical; If TRUE, a distance covariance matrix between the univariate observations/columns is additionally calculated. Not meaningful if group.X and group.Y are not specified.
specifies a test (see argument "test") that is performed between all single observations.
Either a single metric or a list providing a metric for each single observation/column in X (see metr.X).
See metr.pw.Y.
berschneider2018complexdcortools
bottcher2017detectingdcortools
dueck2014affinelydcortools
huang2017statisticallydcortools
huo2016fastdcortools
lyons2013distancedcortools
sejdinovic2013equivalencedcortools
szekely2007dcortools
szekely2009browniandcortools
X <- matrix(rnorm(1000), ncol = 10)
dcm <- dcmatrix(X, test="bb3",calc.cor = "pearson",
calc.pvalue.cor = TRUE, adjustp = "BH")
dcm <- dcmatrix(X, test="bb3",calc.cor = "pearson",
calc.pvalue.cor = TRUE, adjustp = "BH",
group.X = c(rep(1, 5), rep(2, 5)),
calc.dcor.pw = TRUE, test.pw = "bb3")
Y <- matrix(rnorm(600), ncol = 6)
Y[,6] <- rbinom(100, 4, 0.3)
dcm <- dcmatrix(X, Y, test="bb3",calc.cor = "pearson",
calc.pvalue.cor = TRUE, adjustp = "BH")
dcm <- dcmatrix(X, Y, test="bb3",calc.cor = "pearson",
calc.pvalue.cor = TRUE, adjustp = "BH",
group.X = c(rep("group1", 5), rep("group2", 5)),
group.Y = c(rep("group1", 5), "group2"),
metr.X = "gaussauto",
metr.Y = list("group1" = "gaussauto", "group2" = "discrete"))
Run the code above in your browser using DataLab