# KendallTau: Kendall's tau correlation In mixedCCA: Sparse Canonical Correlation Analysis for High-Dimensional Mixed Data

## Description

Calculate Kendall's tau correlation.

\hat{τ}_{jk} = \frac{2}{n(n-1)}∑_{1≤ i<i'≤ n} sign(X_{ji}-X_{ji'}) sign(X_{ki}-X_{ki'})

The function KendallTau calculates Kendall's tau correlation between two variables, returning a single correlation value. The function Kendall_matrix returns a correlation matrix.

## Usage

 1 2 3 KendallTau(x, y) Kendall_matrix(X, Y = NULL) 

## Arguments

 x A numeric vector. y A numeric vector. X A numeric matrix (n by p1). Y A numeric matrix (n by p2).

## Value

KendallTau(x, y) returns one Kendall's tau correlation value between two vectors, x and y.

Kendall_matrix(X) returns a p1 by p1 matrix of Kendall's tau correlation coefficients. Kendall_matrix(X, Y) returns a p1 by p2 matrix of Kendall's tau correlation coefficients.

## Examples

  1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 n <- 100 # sample size r <- 0.8 # true correlation ### vector input # Data generation (X1: truncated continuous, X2: continuous) Z <- mvrnorm(n, mu = c(0, 0), Sigma = matrix(c(1, r, r, 1), nrow = 2)) X1 <- Z[,1] X1[Z[,1] < 1] <- 0 X2 <- Z[,2] KendallTau(X1, X2) Kendall_matrix(X1, X2) ### matrix data input p1 <- 3; p2 <- 4 # dimension of X1 and X2 JSigma <- matrix(r, nrow = p1+p2, ncol = p1+p2); diag(JSigma) <- 1 Z <- mvrnorm(n, mu = rep(0, p1+p2), Sigma = JSigma) X1 <- Z[,1:p1] X1[Z[,1:p1] < 0] <- 0 X2 <- Z[,(p1+1):(p1+p2)] Kendall_matrix(X1, X2) 

mixedCCA documentation built on March 21, 2021, 1:07 a.m.