dcor.matrix: Computes distance correlation for give matrix

Description Usage Arguments Details Value Note Author(s) References See Also Examples

View source: R/dcor.matrix.R

Description

This function computes the distance correlation between every pair of columns of the input data matrix.

Usage

1

Arguments

Data

A matrix containing the data

Details

Using for loops, all pairs of columns are passed to link[energy]{dcor} function from link[energy]{energy-package}.

Value

A numeric square matrix. The number of rows and columns is equal to the number of columns of Data and they are named accordingly.

Note

This function uses for loops, which are not efficient for an input matrix with too many columns.

Author(s)

Habil Zare

References

Szekely, G.J., Rizzo, M.L., and Bakirov, N.K. (2007), Measuring and Testing Dependence by Correlation of Distances, _Annals of Statistics_, Vol. 35 No. 6, pp. 2769-2794.

<URL: http://dx.doi.org/10.1214/009053607000000505>

Szekely, G.J. and Rizzo, M.L. (2009), Brownian Distance Covariance, _Annals of Applied Statistics_, Vol. 3, No. 4, 1236-1265.

<URL: http://dx.doi.org/10.1214/09-AOAS312>

Szekely, G.J. and Rizzo, M.L. (2009), Rejoinder: Brownian Distance Covariance, _Annals of Applied Statistics_, Vol. 3, No. 4, 1303-1308.

See Also

link[energy]{dcor}

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
## Data:
data(aml)
dcor1 <- dcor.matrix(Data=aml[,1:5])
dcor1

## Comparison with Pearson:
cor1 <- abs(cor(aml[,1:5]))
## With 202 samples, distance and Pearson correlations do not differ much:
dcor1-cor1 
dcor2 <- dcor.matrix(Data=aml[1:20,1:5])
cor2 <- abs(cor(aml[1:20,1:5]))
## Distance correlation is more robust if fewer samples are available:
dcor2-cor2
plot(dcor2-cor1,cor1-cor2,xlim=c(-0.5,0.5),ylim=c(-0.5,0.5))

Example output

Loading required package: graph
Loading required package: BiocGenerics
Loading required package: parallel

Attaching package: 'BiocGenerics'

The following objects are masked from 'package:parallel':

    clusterApply, clusterApplyLB, clusterCall, clusterEvalQ,
    clusterExport, clusterMap, parApply, parCapply, parLapply,
    parLapplyLB, parRapply, parSapply, parSapplyLB

The following objects are masked from 'package:stats':

    IQR, mad, sd, var, xtabs

The following objects are masked from 'package:base':

    Filter, Find, Map, Position, Reduce, anyDuplicated, append,
    as.data.frame, basename, cbind, colMeans, colSums, colnames,
    dirname, do.call, duplicated, eval, evalq, get, grep, grepl,
    intersect, is.unsorted, lapply, lengths, mapply, match, mget,
    order, paste, pmax, pmax.int, pmin, pmin.int, rank, rbind,
    rowMeans, rowSums, rownames, sapply, setdiff, sort, table, tapply,
    union, unique, unsplit, which, which.max, which.min


Loading required package: energy
           7180_at    272_at   2769_at   4267_at  79183_at
7180_at  1.0000000 0.4584777 0.2736519 0.2514875 0.3069972
272_at   0.4584777 1.0000000 0.4053482 0.3518125 0.4546532
2769_at  0.2736519 0.4053482 1.0000000 0.4762997 0.2476616
4267_at  0.2514875 0.3518125 0.4762997 1.0000000 0.3024571
79183_at 0.3069972 0.4546532 0.2476616 0.3024571 1.0000000
             7180_at       272_at     2769_at     4267_at     79183_at
7180_at   0.00000000 -0.025513852 -0.04091352  0.02042267  0.030629233
272_at   -0.02551385  0.000000000 -0.02544705 -0.01264602 -0.006530137
2769_at  -0.04091352 -0.025447053  0.00000000 -0.02538237  0.022567588
4267_at   0.02042267 -0.012646020 -0.02538237  0.00000000  0.034186756
79183_at  0.03062923 -0.006530137  0.02256759  0.03418676  0.000000000
            7180_at      272_at      2769_at     4267_at    79183_at
7180_at  0.00000000  0.08104044  0.248990015 0.256060600  0.05784615
272_at   0.08104044  0.00000000  0.137269242 0.386519574 -0.02561272
2769_at  0.24899001  0.13726924  0.000000000 0.009810655 -0.03975300
4267_at  0.25606060  0.38651957  0.009810655 0.000000000  0.13708974
79183_at 0.05784615 -0.02561272 -0.039753000 0.137089742  0.00000000

Pigengene documentation built on Nov. 8, 2020, 6:47 p.m.