This package provides a C++ implementation of Projection Correlation (PCOR) computations, leveraging Rcpp, Armadillo and OPENMP for performance optimization. An R implementation is available at PCOR.
remotes::install_github("chia202/PCORcpp")pcov(): Compute projection covariance between two random vectorspcor(): Compute projection correlation coefficient between two random vectorspcov.test(): Perform projection covariance independence testpcor.test(): Perform projection correlation independence test
library(PCORcpp)
set.seed(123)
X <- matrix(rnorm(100 * 5), 100, 5)
Y <- matrix(rnorm(100 * 3), 100, 3)
# Compute projection covariance
result <- pcov(X, Y, n.threads = 4)
print(result)
# Compute projection correlation coefficient
result <- pcor(X, Y, estimation.method = "u", n.threads = 4)
print(result)
# Perform independence test
pcov.test_result <- pcov.test(X, Y, times = 199, n.threads = 4)
print(pcov.test_result)
pcor.test_result <- pcor.test(X, Y, times = 199, n.threads = 4)
print(pcor.test_result)estimation.method: Estimation method, "u" for U-statistic, "v" for V-statistictimes: Number of permutations for permutation testn.threads: Number of threads for parallel computation
- L. Zhu, K. Xu, R. Li, W. Zhong (2017). Projection correlation between two random vectors. Biometrika, 104, 829-843.