For the given data matrix, the permutation test of correlation is calculated for every pair of variables.

cor_permutationTest(
  data,
  n_repetitions = 100,
  alternative = "two_sided",
  zero_precisionC = 1e-06
)

Arguments

data

Data matrix or data frame with samples in rows and variables in columns.

n_repetitions

Number of repetitions of subsampling. For large `data` matrices, large number of repetitions can take a long time.

alternative

Alternative hypothesis for the permutation test. Takes one of the values: `"less"`, `"greater"`, `"two_sided"` or `"two_sided_signed"`. See details.

zero_precisionC

The zero precision passed to the C++ function. All numbers with absolute value smaller than `zero_precisionC` will be set to zero. Defaults to 10^(-6).

Value

A data frame with names of variables in first two columns and p-value of correlation test between the two variables in the third column. In the rows, all pairwise correlations are listed.

Details

For every pair of variables, for `n_repetitions` times, a permutation of the samples is randomly chosen and the correlation between the original samples for variable i and permuted samples for variable j is calculated and compared to the true correlation coefficient. The p-value is obtained as percentage of times when the "permuted" correlation was more significant that the "true" correlation. Significance is determined based on the `alternative` parameter. If the `alternative` is

  • `"less"`: we count number of times "permuted" correlation is smaller than the "true" correlation.

  • `"greater"`: we count number of times "permuted" correlation is greater than the "true" correlation.

  • `"two_sided"`: we count number of times absolute value of "permuted" correlation is greater than the absolute value of the "true" correlation.

  • `"two_sided_signed"`: we count when "permuted" correlation is greater than the "true" correlation for positive "true" correlation or when "permuted" correlation is smaller than the "true" correlation for negative "true" correlation.