# Test in R of whether three or more correlations from independent samples are equal

• Is there an R implementation of a significance test for testing whether three or more correlations drawn from independent samples are equal?

I found this formula which wouldn't be too difficult to implement, but I was curious whether there was an existing implementation either based on the linked formula or on some other method.

-
 (+1) for the link. – Dmitrij Celov Jul 5 '11 at 11:55

This is a meta-analytical approach. The formula you provided looks like the standard Q-test (test of heterogeneity; see p. 11f) which tests for $H_0: \theta_1=\theta_2=\ldots=\theta_k$ (with $k$ being the number of studies or independent correlation coefficients).

Most meta-analysis packages in R can do this test, for instance, meta or metafor. I will provide an example for the meta package (differences are due to rounding errors):

library(meta)
library(psychometric)
dfr <- data.frame(r=c(0.2, 0.5, 0.6), n=c(200, 150, 75))
dfr$z <- r2z(dfr$r)    ## Fisher's z transformation
dfr$z.se <- SEz(dfr$n) ## SEs for Fisher's z

## recommended approach
metacor(cor=r, n=n, sm="ZCOR", data=dfr)

## replicating the results from your "Correlation" webpage
metagen(TE=z, seTE=z.se, data=dfr)

>     metagen(TE=z, seTE=z.se, data=dfr)
95%-CI %W(fixed) %W(random)
1 0.2027  [0.0631; 0.3424]     47.36      35.07
2 0.5493  [0.3877; 0.7110]     35.34      34.14
3 0.6931  [0.4622; 0.9241]     17.31      30.79

Number of trials combined: 3

95%-CI      z  p.value
Fixed effect model   0.4101  [0.3140; 0.5062] 8.3640 < 0.0001
Random effects model 0.4721  [0.1796; 0.7645] 3.1637   0.0016

Quantifying heterogeneity:
tau^2 = 0.0584; H = 2.92 [1.75; 4.87]; I^2 = 88.3% [67.5%; 95.8%]

Test of heterogeneity:
Q d.f.  p.value
17.09    2   0.0002

Method: Inverse variance method

-
 Thanks. I hadn't thought of looking in the meta-analytic R packages. – Jeromy Anglim Jul 6 '11 at 1:04