multivariance {multivariance}R Documentation

distance multivariance

Description

Computes the distance multivariance, either for given data or a given list of doubly centered distance matrices.

Usage

multivariance(
  x,
  vec = NA,
  Nscale = TRUE,
  correlation = FALSE,
  squared = TRUE,
  ...
)

Arguments

x

either a data matrix or a list of doubly centered distance matrices

vec

if x is a matrix, then this indicates which columns are treated together as one sample; if x is a list, these are the indexes for which the multivariance is calculated. The default is all columns and all indexes, respectively.

Nscale

if TRUE the multivariance is scaled up by the sample size (and thus it is exactly as required for the test of independence)

correlation

depreciated, please use the function multicorrelation instead.

squared

if FALSE it returns the actual multivariance, otherwise the squared multivariance (less computation)

...

these are passed to cdms (which is only invoked if x is a matrix)

Details

If x is a matrix and vec is not given, then each column is treated as a separate sample. Otherwise vec has to have as many elements as x has columns and values starting from 1 up to the number of 'variables', e.g. if x is an N by 5 matrix and vec = c(1,2,1,3,1) then the multivariance of the 1-dimensional variables represented by column 2 and 4 and the 3-dimensional variable represented by the columns 1,3,5 is computed.

As default it computes the normalized Nscaled squared multivariance, for a multivariance without normalization the argument normalize = FALSE has to be passed to cdms.

correlation = TRUE yields values between 0 and 1. These can be interpreted similarly to classical correlations, see also multicorrelation.

As a rough guide to interpret the value of distance multivariance note:

Finally note, that due to numerical (in)precision the value of multivariance might become negative. In these cases it is set to 0. A warning is issued, if the value is negative and further than the usual (used by all.equal) tolerance away from 0.

References

For the theoretic background see the references given on the main help page of this package: multivariance-package.

Examples

multivariance(matrix(rnorm(100*3),ncol = 3)) #independent sample
multivariance(coins(100)) #dependent sample which is 2-independent

x = matrix(rnorm(100*2),ncol = 2)
x = cbind(x,x[,2])
multivariance(x) #dependent sample which is not 2-independent (thus small values are meaningless!)
multivariance(x[,1:2]) #these are independent
multivariance(x[,2:3]) #these are dependent

multivariance(x[,2:3],correlation = TRUE)


[Package multivariance version 2.4.1 Index]