R/sampleCorrelation.R

# Obtain average pairwise correlation between the (i,j)th and (j,i)th
# entries of the matrix A.
# Input:
# - A: square matrix; its diagonal does not matter
# Output:
# - The sample correlation
sampleCorrelation <- function(A) {
    x <- A[upper.tri(A)]
    B <- t(A)
    y <- B[upper.tri(B)]
    return(cor(x, y))
}
esander91/LizUtilities documentation built on May 16, 2019, 8:51 a.m.