data corr; *** Below, specify the sample size "n" and the three correlations ***; n = 50; rx1y = .7; rx2y = .3; rx1x2 = .2; **********************************************************************; **_________________________________________________________________**; detR = (1-rx1y**2 - rx2y**2 - rx1x2**2) + (2*rx1y*rx2y*rx1x2); **********************************************************************; ************* Hotelling's t below ************************************; hotel_t = ((rx1y - rx2y)*sqrt(n-3))*(sqrt(1+rx1x2))*((2*detR)**-.5); **********************************************************************; ************* Williams's t below **************************************; willtnum = ((rx1y - rx2y) * sqrt((n-3)*(1+rx1x2))); willtden = sqrt(2*detR+((rx1y-rx2y)**2*(1-rx1x2))/(4*n-4)); will_t=willtnum/willtden; **********************************************************************; ** "Standard" Wiliam's t (T2); rbar=(rx1y+rx2y)/2; numt2 = (n-1)*(1+rx1x2); den2t = 2*((n-1)/(n-3))*detR+(rbar**2)*((1-rx1x2)**3); will_t2=(rx1y-rx2y)*(sqrt(numt2/den2t)); ************* Olkin's z below ****************************************; olknum = n**.5*(rx1y-rx2y); olkden =SQRT( (1-rx1y**2)**2 + (1-rx2y**2)**2 - (2*rx1x2**3) -(2*rx1x2 - rx1y*rx2y)*(1-rx1y**2 - rx2y**2 - rx1x2**2) ); olkin_z=olknum/olkden; **********************************************************************; ************* MRR's z below ******************************************; rsb= (rx1y**2+rx2y**2)/2; f = (1-rx1x2)/(2*(1-rsb)); IF f>1 then f=1; h = (1-(f*rsb))/(1-rsb); Zx1y = .5*(log(abs((1+rx1y)/(1-rx1y)))); Zx2y = .5*(log(abs((1+rx2y)/(1-rx2y)))); MRRa = (Zx1y-Zx2y); MRRb = SQRT((n-3)/(2*(1-rx1x2)*h)); MRR_z = MRRa*MRRb; **********************************************************************; *** Dunn & Clark's Z below *******************************************; covyx=(rx1x2*(1-rx1y**2-rx2y**2) - .5*(rx1y*rx2y)*(1-rx1y**2-rx2y**2-rx1x2**2))/((1-rx1y**2)*(1-rx2y**2)); Zx1y = .5*(log(abs((1+rx1y)/(1-rx1y)))); Zx2y = .5*(log(abs((1+rx2y)/(1-rx2y)))); Dunn_z = sqrt(n-3)*(Zx1y-Zx2y)*(2-2*covyx)**-.5; **__________________________________________________________________**; ******** Steiger's Z below *******************************************; r_b=(rx1y+rx2y)/2; cov_yx=(rx1x2*(1-r_b**2-r_b**2) - .5*(r_b*r_b)*(1-r_b**2-r_b**2-rx1x2**2))/((1-r_b**2)*(1-r_b**2)); Steigr_z = sqrt(n-3)*(Zx1y-Zx2y)*(2-2*cov_yx)**-.5; **__________________________________________________________________**; ************** Check for triangular inequality ***********************; lo_rx1x2=cos(arcos(rx1y) + arcos(rx2y)); up_rx1x2=cos(arcos(rx1y) - arcos(rx2y)); IF rx1x2 > up_rx1x2 or rx1x2 < lo_rx1x2 then check= 'Given rx1y & rx2y, the value of rx1x2 is out of bounds'; ELSE check='All correlations are in bounds'; **********************************************************************; Hotel_p=2*(1-probt(abs(hotel_t), n-3)); Will_p=2*(1-probt(abs(will_t), n-3)); Willt2_p=2*(1-probt(abs(will_t2), n-3)); olkin_p=2*(1-probnorm(abs(olkin_z))); MRR_p=2*(1-probnorm(abs(MRR_z))); Dunn_p=2*(1-probnorm(abs(Dunn_z))); Steigr_p=2*(1-probnorm(abs(Steigr_z))); proc print noobs; var Hotel_t Will_t Will_t2 Olkin_z Mrr_z Dunn_z Steigr_z ; proc print noobs; var Hotel_p Will_p Willt2_p Olkin_p Mrr_p Dunn_p Steigr_p; proc print noobs; var check; title1 'Note Hotel_t=Hotelling t, Will_t=Williams modified t per Hendrickson,' ; title2 'Stanley and Hills, Olkin_z=Olkins z, Mrr_z=Meng, Rosenthal & Rubin Z' ; title3 'Rubin Z, Will_t2=Williams standard t, Dunn_z=Dunn & Clark Z,'; title4 'Steigr_z=Steiger modification of Dunn & Clark z'; run;