Skip to contents

Perform an exact correlation permutation test. Computes correlation value for every row of matrix X against all distinct permutations of vector y.

Usage

exact_cor_test(
  X,
  y,
  method = c("pearson", "spearman"),
  alternative = c("two.sided", "greater", "less")
)

Arguments

X

numeric matrix or data.frame that can be converted to a numeric matrix

y

numeric vector of data to correlate

method

character. One of "pearson" (default) or "spearman"

alternative

character. One of "two.sided" (default), "greater" or "less"

Value

data.frame containing the original values in X along with columns containing the correlation of Xi and Y, the exact permutation p-value, and the FDR corrected p-value

Examples

set.seed(123)
X <- matrix(rnorm(50), nrow = 10)
y <- 1:5
exact_cor_test(X, y)
#>             V1         V2         V3          V4          V5        cor
#> 1  -0.56047565  1.2240818 -1.0678237  0.42646422 -0.69470698 -0.1795143
#> 2  -0.23017749  0.3598138 -0.2179749 -0.29507148 -0.20791728 -0.3582186
#> 3   1.55870831  0.4007715 -1.0260044  0.89512566 -1.26539635 -0.6663650
#> 4   0.07050839  0.1106827 -0.7288912  0.87813349  2.16895597  0.7184448
#> 5   0.12928774 -0.5558411 -0.6250393  0.82158108  1.20796200  0.6854607
#> 6   1.71506499  1.7869131 -1.6866933  0.68864025 -1.12310858 -0.6664335
#> 7   0.46091621  0.4978505  0.8377870  0.55391765 -0.40288484 -0.5658234
#> 8  -1.26506123 -1.9666172  0.1533731 -0.06191171 -0.46665535  0.6277600
#> 9  -0.68685285  0.7013559 -1.1381369 -0.30596266  0.77996512  0.3591615
#> 10 -0.44566197 -0.4727914  1.2538149 -0.38047100 -0.08336907  0.1764823
#>    empirical.p       FDR
#> 1    0.8166667 0.8333333
#> 2    0.6166667 0.7708333
#> 3    0.2500000 0.5277778
#> 4    0.2000000 0.5277778
#> 5    0.2166667 0.5277778
#> 6    0.2666667 0.5277778
#> 7    0.3166667 0.5277778
#> 8    0.2500000 0.5277778
#> 9    0.5333333 0.7619048
#> 10   0.8333333 0.8333333