/*========================================================= File name: 7_ZPF.txt Written by: Karl L. Wuensch, WuenschK@ECU.edu Date: 7. February 2013 =========================================================== For the following correlation matrix, the correlations to be compared are r12 and r34 X1 X2 X3 X4 X1 -- r12 r13 r14 X2 -- -- r23 r24 X3 -- -- -- r34 Users can replace the data lines (between CARDS and PROC) with their own data. Each data row represents the matrix for a single group. "Steiger" is whether to apply (1) or not apply (0) Steiger's (1980) modification, which is to set r12 and r34 to the mean of r12 and r34 when estimating the standard errors of the difference between r12 and r34 under the null hypothesis of no difference. This modification is not appropriate and is not used when constructing the confidence interval for the difference. "N" is the sample size, and "Note" is a descriptive string. The correlation coefficients comprise the remainder of the input data. ***************************************************************************/ data ZPF; input Steiger N r12 r13 r14 r23 r24 r34 alpha Note $15.; If Steiger = 0 then do; r12S = r12; r34S = r34; end; Else If Steiger = 1 then do; r12S=(r12+r34)/2; r34S=r12S; end; k=(r13-r23*r12S)*(r24-r23*r34S)+(r14-r13*r34S)*(r23-r13*r12S)+ (r13-r14*r34S)*(r24-r14*r12S)+(r14-r12S*r24)*(r23-r24*r34S); Z12=.5*log((1+r12)/(1-r12)); Z34=.5*log((1+r34)/(1-r34)); ZPF = sqrt((n-3)/2)*(Z12-Z34)/sqrt(1-(k/(2*(1-r12S**2)*(1-r34S**2)))); *Remove leading asterisk on next two lines if you want PF; *PF=(r12-r34)*SQRT(n)/SQRT((1-r12**2)**2+(1-r34**2)**2-k); *p_PF=2*PROBNORM(-1*ABS(PF)); p_ZPF=2*PROBNORM(-1*ABS(ZPF)); *Use method of Zou (2007, p. 409-410) to compute CI for rho12 - rho34; num=.5*r12*r34*(r13**2 + r14**2 + r23**2 + r24**2) + r13*r24 + r14*r23 - (r12*r13*r14 + r12*r23*r24 + r13*r23*r34 + r14*r24*r34); denom=(1 - r12**2)*(1 - r34**2); corr12_34=num/denom; cump=1-alpha/2; CV=PROBIT(cump); *CV = critical value of z; SE=SQRT(1/(n-3)); rprime12=0.5*log(abs((1+r12)/(1-r12))); L12p=rprime12 - CV*SE; * lower limit of 95% CI for rho-prime; U12p=rprime12 + CV*SE; * upper limit of 95% CI for rho-prime; L12=(exp(2*L12p)-1)/(exp(2*L12p)+1); U12=(exp(2*U12p)-1)/(exp(2*U12p)+1); rprime34=0.5*log(abs((1+r34)/(1-r34))); L34p=rprime34-CV*SE; * lower limit of 95% CI for rho-prime; U34p=rprime34+CV*SE; * upper limit of 95% CI for rho-prime; L34=(exp(2*L34p)-1)/(exp(2*L34p)+1); U34=(exp(2*U34p)-1)/(exp(2*U34p)+1); Label L12='Lower CI rho12'; Label L34='Lower CI rho34'; Label U12='Upper CI rho12'; Label U34='Upper CI rho34'; CI_Lower=r12-r34-SQRT((r12-L12)**2+(U34-r34)**2-2*corr12_34*(r12-L12)*(U34-r34)); CI_Upper=r12-r34+SQRT((U12-r12)**2+(r34-L34)**2-2*corr12_34*(U12-r12)*(r34-L34)); CARDS; 0 24 .628 .164 -.189 -.145 -.201 .624 .05 Burbank 1 24 .628 .164 -.189 -.145 -.201 .624 .05 Burbank 0 49 .418 .198 .065 -.181 .299 .040 .05 Lancaster 1 49 .418 .198 .065 -.181 .299 .040 .05 Lancaster 0 19 .438 .412 .114 -.032 .230 .487 .05 Long Beach 1 19 .438 .412 .114 -.032 .230 .487 .05 Long Beach 0 58 .589 .366 .071 .330 .209 .364 .05 Glendora 1 58 .589 .366 .071 .330 .209 .364 .05 Glendora 0 150 .521 .281 .043 .042 .199 .316 .05 All Areas 1 150 .521 .281 .043 .042 .199 .316 .05 All Areas 0 66 .396 .208 .143 .023 .423 .189 .05 Zou Example 3 1 66 .396 .208 .143 .023 .423 .189 .05 Zou Example 3 0 603 .38 .45 .53 .31 .55 .25 .05 Wuensch example 1 603 .38 .45 .53 .31 .55 .25 .05 Wuensch example 0 103 .50 .70 .50 .50 .80 .60 .05 Steiger B 1 103 .50 .70 .50 .50 .80 .60 .05 Steiger B ; /* The Wuensch example is from the document found at http://core.ecu.edu/psyc/wuenschk/stathelp/ZPF.docx. "Steiger B" is from Steiger , Case B. */ proc print Label; var Steiger r12 L12 U12 r34 L34 U34 alpha Note; ID; Title 'Confidence Intervals for rho-12 and rho-34'; run; PROC print; var Steiger r12 r34 ZPF -- p_ZPF CI_Lower CI_Upper alpha Note; ID; title 'ZPF test with confidence intervals'; run;