# [R] test for difference between non-independent correlations

Jonathan Baron baron at psych.upenn.edu
Tue Jul 27 15:05:33 CEST 2004

```On 07/27/04 13:35, Avril Coghlan wrote:
>Hello,
>
>  I am wondering whether there is a way to
>test whether two non-independent correlation
>coefficients are significantly different, in R?

About 20 years ago I asked the same question (without the "R"),
found Steiger's paper (below) and wrote this BASIC program to do
it.  (If you try to type it in each time you're bound to make a
mistake.  This has been checked repeatedly.)  It is trivial to
write this as an R script, of course.

I and my colleagues have been using this for about 20 years, and
it seems to be OK as judged by comparing it to the jackknife.
(Remember, when we did this, the "bootstrap" was a newfangled
idea that we didn't quite trust.)  My hunch is that something
better has come along, and I'd be interested to see how others
respond.  Hence I haven't bothered to translate this into R.  Or
maybe everyone who has this problem just uses the bootstrap now.
That is certainly easy enough.  (I will eventually add this to
our "Notes on R for psychology...," since it is a very common
problem in psychology research.)

10 print "looks for difference between r12 and r13, given r23"
12 print "(input r12>1 to quit)"
20 input "r12 "; r12
22 if r12>1 then end
30 input "r13 "; r13
40 input "r23 "; r23
50 input "N "; n
52 let rd=1-r12*r12-r13*r13-r23*r23+2*r12*r13*r23
54 let rb=(r12+r13)/2
56 let cube=(1-r23)*(1-r23)*(1-r23)
60 let t2=(r12-r13)*sqrt((n-1)*(1+r23)/(2*rd*(n-1)/(n-3)+rb*rb*cube))
70 print "t (";n-3;") = ";t2
80 print "Steiger, J.H. (1980). Tests for comparing elements of a
82 print "correlation matrix.  Psychological Bulletin, 87, 245-251."
100 goto 12

--
Jonathan Baron, Professor of Psychology, University of Pennsylvania