/*===================================================== File name: 3_two_independent_correlations.txt Written by: Karl L. Wuensch, WuenschK@ECU.edu Date: 10-September-2012. ===================================================== z-test for comparing two independent correlations Confidence intervals for rho1 and rho2 Confidence interval for difference between rho1 and rho2 (Zou (2007) This syntax works only for the case where the null hypothesis specifies that the difference between the population correlations = 0. Use correlation between FHEIGHT and FWEIGHT. Compare one city with another. In the INPUT statement below: r1 = first correlation r2 = second correlation (r1 and r2 must be independent of each other) n1 = first sample size n2 = second sample size alpha = value used to set the confidence level for the CI on b1-b2, with Confidence Level = (1-alpha)*100 Note = a brief description of the data in that row. Users can replace the data lines (between CARDS and PROC) with their own data. */ data rho1I2; input r1 r2 n1 n2 alpha Note \$40.; rprime1=0.5*log(abs((1+r1)/(1-r1))); rprime2=0.5*log(abs((1+r2)/(1-r2))); se1=SQRT(1/(n1-3)); se2=SQRT(1/(n2-3)); rprimediff=rprime1-rprime2; sediff= SQRT(se1**2+se2**2); z=rprimediff/sediff; zneg=0-abs(z); p=2*PROBNORM(zneg); cump=1-alpha/2; *CV = critical value of z; CV = PROBIT(cump); *Confidence intervals for rho 1 and rho 2; LPrime1=rprime1-CV*se1; UPrime1=rprime1+CV*se1; LPrime2=rprime2-CV*se2; UPrime2=rprime2+CV*se2; CI_1_Lower=(exp(2*LPrime1)-1)/(exp(2*LPrime1)+1); CI_1_Upper=(exp(2*UPrime1)-1)/(exp(2*UPrime1)+1); CI_2_Lower=(exp(2*LPrime2)-1)/(exp(2*LPrime2)+1); CI_2_Upper=(exp(2*UPrime2)-1)/(exp(2*UPrime2)+1); *Use method of Zou (2007) to compute CI for rho1-rho2 difference; CI_Lower=r1-r2-sqrt((r1-CI_1_Lower)**2+(CI_2_Upper-r2)**2); CI_Upper=r1-r2+SQRT((CI_1_Upper-r1)**2+(r2-CI_2_Lower)**2); CARDS; .4180 .5890 49 58 .05 r(FHT,FWT), Lancaster v Glendora .0400 .3640 49 58 .05 r(MHT,MWT), Lancaster v Glendora .1980 .3660 49 58 .05 r(FHT,MHT), Lancaster v Glendora .2990 .2090 49 58 .05 r(FWT,MWT), Lancaster v Glendora -.1810 .3300 49 58 .05 r(FWT,MHT), Lancaster v Glendora -.1810 .3300 49 58 .01 r(FWT,MHT), Lancaster v Glendora, .01 .0650 .0710 49 58 .05 r(FHT,MWT), Lancaster v Glendora .49 .36 145 87 .05 Zou (2007) Example 1 ; PROC print; var r1 r2 z p Note; ID; title 'Test of H0: rho1 = rho2, independent samples'; run; proc print; var r1 CI_1_Lower CI_1_Upper r2 CI_2_Lower CI_2_Upper alpha note; title 'Confidence intervals for rho 1 and rho 2'; ID; proc print; var r1 r2 alpha CI_Lower CI_Upper Note; ID; title 'Confidence interval for difference between rho1 and rho2'; run; /* Zou, G. Y. (2007). Toward using confidence intervals to compare correlations. Psychological Bulletin, 12, 399-413. */