The CORR Procedure

Example 1.4 Applications of Fisher’s z Transformation

This example illustrates some applications of Fisher’s z transformation. For details, see the section Fisher’s z Transformation.

The following statements simulate independent samples of variables X and Y from a bivariate normal distribution. The first batch of 150 observations is sampled using a known correlation of 0.3, the second batch of 150 observations is sampled using a known correlation of 0.25, and the third batch of 100 observations is sampled using a known correlation of 0.3.

data Sim (drop=i);
do i=1 to 400;
  X = rannor(135791);
  Batch = 1 + (i>150) + (i>300);
  if Batch = 1 then Y = 0.3*X + 0.9*rannor(246791);
  if Batch = 2 then Y = 0.25*X + sqrt(.8375)*rannor(246791);
  if Batch = 3 then Y = 0.3*X + 0.9*rannor(246791);
  output;
end;
run;

This data set will be used to illustrate the following applications of Fisher’s z transformation:

  • testing whether a population correlation is equal to a given value

  • testing for equality of two population correlations

  • combining correlation estimates from different samples

Testing Whether a Population Correlation Is Equal to a Given Value rho 0

You can use the following statements to test the null hypothesis upper H 0 colon rho equals 0.5 against a two-sided alternative upper H 1 colon rho not-equals 0.5. The test is requested with the option FISHER(RHO0=0.5).

title 'Analysis for Batch 1';
proc corr data=Sim (where=(Batch=1)) fisher(rho0=.5);
   var X Y;
run;

Output 1.4.1 displays the results based on Fisher’s transformation. The null hypothesis is rejected since the p-value is less than 0.0001.

Output 1.4.1: Fisher’s Test for upper H 0 colon rho equals rho 0

Analysis for Batch 1

The CORR Procedure

Pearson Correlation Statistics (Fisher's z Transformation)
VariableWith VariableNSample CorrelationFisher's zBias AdjustmentCorrelation Estimate H0:Rho=Rho0
95% Confidence LimitsRho0p Value
XY1500.220810.224510.00074100.220110.0620340.3674090.50000<.0001


Testing for Equality of Two Population Correlations

You can use the following statements to test for equality of two population correlations, rho 1 and rho 2. Here, the null hypothesis upper H 0 colon rho 1 equals rho 2 is tested against the alternative upper H 1 colon rho 1 not-equals rho 2.

ods output FisherPearsonCorr=SimCorr;
title 'Testing Equality of Population Correlations';
proc corr data=Sim (where=(Batch=1 or Batch=2)) fisher;
   var X Y;
   by Batch;
run;

The ODS OUTPUT statement saves the "FisherPearsonCorr" table into an output data set in the CORR procedure. The output data set SimCorr contains Fisher’s z statistics for both batches.

The following statements display (in Output 1.4.2) the output data set SimCorr:

proc print data=SimCorr;
run;

Output 1.4.2: Fisher’s Correlation Statistics

ObsBatchVarWithVarNObsCorrZValBiasAdjCorrEstLclUclpValue
11XY1500.220810.224510.00074100.220110.0620340.3674090.0065
22XY1500.336940.350640.001130.335940.1856760.470853<.0001


The p-value for testing upper H 0 is derived by treating the difference z 1 minus z 2 as a normal random variable with mean zero and variance 1 slash left-parenthesis n 1 minus 3 right-parenthesis plus 1 slash left-parenthesis n 2 minus 3 right-parenthesis, where z 1 and z 2 are Fisher’s z transformation of the sample correlations r 1 and r 2, respectively, and where n 1 and n 2 are the corresponding sample sizes.

The following statements compute the p-value in Output 1.4.3:

data SimTest (drop=Batch);
   merge SimCorr (where=(Batch=1) keep=Nobs ZVal Batch
                  rename=(Nobs=n1 ZVal=z1))
         SimCorr (where=(Batch=2) keep=Nobs ZVal Batch
                  rename=(Nobs=n2 ZVal=z2));
   variance = 1/(n1-3) + 1/(n2-3);
   z = (z1 - z2) / sqrt( variance );
   pval = probnorm(z);
   if (pval > 0.5) then pval = 1 - pval;
   pval = 2*pval;
run;

proc print data=SimTest noobs;
run;

Output 1.4.3: Test of Equality of Observed Correlations

n1z1n2z2variancezpval
1500.224511500.350640.013605-1.081350.27954


In Output 1.4.3, the p-value of 0.2795 does not provide evidence to reject the null hypothesis that rho 1 equals rho 2. The sample sizes n 1 equals 150 and n 2 equals 150 are not large enough to detect the difference rho 1 minus rho 2 equals 0.05 at a significance level of alpha equals 0.05.

Combining Correlation Estimates from Different Samples

Assume that sample correlations r 1 and r 2 are computed from two independent samples of n 1 and n 2 observations, respectively. A combined correlation estimate is given by r overbar equals hyperbolic tangent left-parenthesis z overbar right-parenthesis, where z overbar is the weighted average of the z transformations of r 1 and r 2:

z overbar equals StartFraction left-parenthesis n 1 minus 3 right-parenthesis z 1 plus left-parenthesis n 2 minus 3 right-parenthesis z 2 Over n 1 plus n 2 minus 6 EndFraction

The following statements compute a combined estimate of rho by using Batch 1 and Batch 3:

ods output FisherPearsonCorr=SimCorr2;
proc corr data=Sim (where=(Batch=1 or Batch=3)) fisher;
   var X Y;
   by Batch;
run;

data SimComb (drop=Batch);
   merge SimCorr2 (where=(Batch=1) keep=Nobs ZVal Batch
                   rename=(Nobs=n1 ZVal=z1))
         SimCorr2 (where=(Batch=3) keep=Nobs ZVal Batch
                   rename=(Nobs=n2 ZVal=z2));
   z = ((n1-3)*z1 + (n2-3)*z2) / (n1+n2-6);
   corr = tanh(z);
   var = 1/(n1+n2-6);
   zlcl = z - probit(0.975)*sqrt(var);
   zucl = z + probit(0.975)*sqrt(var);
   lcl= tanh(zlcl);
   ucl= tanh(zucl);
   pval= probnorm( z/sqrt(var));
   if (pval > .5)  then pval= 1 - pval;
   pval= 2*pval;
run;

proc print data=SimComb noobs;
   var n1 z1 n2 z2 corr lcl ucl pval;
run;

Output 1.4.4 displays the combined estimate of rho. The table shows that a correlation estimate from the combined samples is r=0.2264. The 95 percent-sign confidence interval is (0.10453,0.34156), using the variance of the combined estimate. Note that this interval contains the population correlation 0.3.

Output 1.4.4: Combined Correlation Estimate

n1z1n2z2corrlcluclpval
1500.224511000.239290.226400.104530.34156.000319748


Last updated: April 10, 2023