Learn R Programming

ccaPP (version 0.3.4)

permTest: (Robust) permutation test for no association

Description

Test whether or not there is association betwenn two data sets, with a focus on robust and nonparametric correlation measures.

Usage

permTest(
  x,
  y,
  R = 1000,
  fun = maxCorGrid,
  permutations = NULL,
  nCores = 1,
  cl = NULL,
  seed = NULL,
  ...
)

Value

An object of class "permTest" with the following components:

pValue

the \(p\)-value for the test.

cor0

the value of the test statistic.

cor

the values of the test statistic for each of the permutated data sets.

R

the number of random permutations.

seed

the seed of the random number generator.

call

the matched function call.

Arguments

x, y

each can be a numeric vector, matrix or data frame.

R

an integer giving the number of random permutations to be used.

fun

a function to compute a maximum correlation measure between two data sets, e.g., maxCorGrid (the default) or maxCorProj. It should expect the data to be passed as the first and second argument, and must return an object of class "maxCor".

permutations

an integer matrix in which each column contains the indices of a permutation. If supplied, this is preferred over R.

nCores

a positive integer giving the number of processor cores to be used for parallel computing (the default is 1 for no parallelization). If this is set to NA, all available processor cores are used.

cl

a parallel cluster for parallel computing as generated by makeCluster. If supplied, this is preferred over nCores.

seed

optional integer giving the initial seed for the random number generator (see .Random.seed). For parallel computing, random number streams are used rather than the standard random number generator and the seed is set via clusterSetRNGStream.

...

additional arguments to be passed to fun.

Author

Andreas Alfons

Details

The test generates R data sets by randomly permuting the observations of x, while keeping the observations of y fixed. In each replication, a function to compute a maximum correlation measure is applied to the permuted data sets. The \(p\)-value of the test is then given by the percentage of replicates of the maximum correlation measure that are larger than the maximum correlation measure computed from the original data.

References

A. Alfons, C. Croux and P. Filzmoser (2016) Robust maximum association between data sets: The R Package ccaPP. Austrian Journal of Statistics, 45(1), 71--79.

See Also

maxCorGrid, maxCorProj

Examples

Run this code
data("diabetes")
x <- diabetes$x
y <- diabetes$y

## Spearman correlation
permTest(x, y, R = 100, method = "spearman")
permTest(x, y, R = 100, method = "spearman", consistent = TRUE)

## Pearson correlation
permTest(x, y, R = 100, method = "pearson")

Run the code above in your browser using DataLab