Learn R Programming

evolqg (version 0.2-2)

KrzCor: Compare matrices via Krzanowski Correlation

Description

Calculates covariance matrix correlation via Krzanowski Correlation

Usage

KrzCor(cov.x, cov.y, ...)

## S3 method for class 'default': KrzCor(cov.x, cov.y, ret.dim = NULL, ...)

## S3 method for class 'list': KrzCor(cov.x, cov.y = NULL, ret.dim = NULL, repeat.vector = NULL, parallel = FALSE, ...)

Arguments

cov.x
Single covariance matrix or list of covariance matrices. If single matrix is suplied, it is compared to cov.y. If list is suplied and no cov.y is suplied, all matrices are compared to each other. If cov.y is suplied, all matrices in list are compared to i
cov.y
First argument is compared to cov.y. Optional if cov.x is a list.
...
aditional arguments passed to other methods
ret.dim
number of retained dimensions in the comparison, default for nxn matrix is n/2-1
repeat.vector
Vector of repeatabilities for correlation correction.
parallel
if TRUE and a list is passed, computations are done in parallel. Some foreach backend must be registered, like doParallel or doMC.

Value

  • If cov.x and cov.y are passed, returns Kzranowski correlation

    If cov.x is a list and cov.y is passed, same as above, but for all matrices in cov.x.

    If only a list is passed to cov.x, a matrix of Kzranowski correlation values. If repeat.vector is passed, comparison matrix is corrected above diagonal and repeatabilities returned in diagonal.

References

Krzanowski, W. J. (1979). Between-Groups Comparison of Principal Components. Journal of the American Statistical Association, 74(367), 703. doi:10.2307/2286995

See Also

RandomSkewers,KrzProjection,MantelCor

Examples

Run this code
c1 <- RandomMatrix(10)
c2 <- RandomMatrix(10)
c3 <- RandomMatrix(10)
KrzCor(c1, c2)

KrzCor(list(c1, c2, c3))

reps <- unlist(lapply(list(c1, c2, c3), MonteCarloRep, 10, KrzCor, iterations = 10))
KrzCor(list(c1, c2, c3), repeat.vector = reps)

c4 <- RandomMatrix(10)
KrzCor(list(c1, c2, c3), c4)

#Multiple threads can be used with some foreach backend library, like doMC or doParallel
#library(doParallel)
##Windows:
#cl <- makeCluster(2)
#registerDoParallel(cl)
##Mac and Linux:
#registerDoParallel(cores = 2)
#KrzCor(list(c1, c2, c3), parallel = TRUE)

Run the code above in your browser using DataLab