test.diff.cor: Test for difference in correlation In AEBilgrau/correlateR: Fast correlations and covariances

Description

This functions tests the hypothesis of no difference in correlations. It uses the Fisher Z transform (`atanh`) to test the null hypothesis of no difference in correlations. See details.

Usage

 ```1 2 3 4``` ```## S3 method for class 'diff.cor' test(X1, X2, cor1 = cor(X1), cor2 = cor(X2), n1 = nrow(X1), n2 = nrow(X2), alternative = c("two.sided", "less", "greater"), conf.level = 0.95, null = 0) ```

Arguments

 `X1` A `numeric` `matrix` of observations. `X2` A `numeric` `matrix` of observations. `cor1` A `numeric` `matrix` of correlation coefficients in the first group. May be omitted if `X1` is provided. `cor2` A `numeric` `matrix` of correlation coefficients in the second group. May be omitted if `X2` is provided. `n1` `integer` of length 1. The number of samples in group 1. `n2` `integer` of length 1. The number of samples in group 2. `alternative` The alternative hypothesis. `conf.level` The confidence level used in the computed confidence intervals. `null` A matrix of number giving the difference in correlation under the null hypothesis.

Details

The function uses the Fisher Z transform (`atanh`) of correlations to test that the hypotheses of no difference in correlation. The computed Z-score is

(Z_1 - Z_2)/ sqrt(1/(n_1 - 3) + 1/(n_2 - 3))

where Z_1 and Z_2 are the Fisher transformed correlations. It performs the test for all correlations in the correlation matrix.

Value

A list of matrices or vector containing:

 `LCL` The lower confidence interval limit. `UCL` The upper confidence interval limit. `z` A numeric matrix of Z-scores for the hypothesis. `p.val` A numeric matrix of the P-values.

with an attribute giving the alternative hypothesis.

Author(s)

Anders Ellern Bilgrau <anders.ellern.bilgrau (at) gmail.com>

References

Similar usage to `cor.test` (but NOT the same thing).
This is a vectorised version of `test.diff.cor.single`.
 ``` 1 2 3 4 5 6 7 8 9 10 11 12 13 14``` ```n1 <- 8 n2 <- 10 X1 <- createData(n = n1, m = 5) X2 <- createData(n = n2, m = 5) print(cor1 <- cor(X1)) print(cor2 <- cor(X2)) test.diff.cor(X1, X2) # Directly supplied correlation matrices test.diff.cor(cor1 = cor1, cor2 = cor2, n1 = n1, n2 = n2) test.diff.cor(X1, X2, alternative = "less") ```