Calculate permutation based p-value for Pearson's correlation coefficient.

PermutationCorr(x, y, R = 999, seed = 1, return.permutation = FALSE)

Arguments

x

A numerical vector with the first variable.

y

A numerical vector with the second variable.

R

The number of permutations to be conducted, set to 999 by default.

seed

Random seed used. Default is 1.

return.permutation

Return permutations. Default is FALSE.

Value

A list containing the following:

  • correlation, Pearson's correlation coefficient.

  • p.val, permutation based p-value.

  • return.permutation, permutation used if returned.

Details

It's adapted from permcor function in Rfast with corrections in calculating the number of permutations and the p-values.

Examples

{
x <- iris[, 1]
y <- iris[, 2]
res <- PermutationCorr(x, y, R = 9999)
}