## Compare two distribution of correlation coefficient

Occasional Contributor
Posts: 17

# Compare two distribution of correlation coefficient

Hi,

I would compare two distributions of correlation coefficient A and B (two sample of correlation coefficients). I want to know if B came from the same population as A. A and B are not independent. (so KS test not applicable)

How can I do this?

best regards,
Super User
Posts: 10,210

## Re: Compare two distribution of correlation coefficient

It looks like you are perform t-test by useing correlation coefficient statistic estimator ?
If it is, you do not need to calculate the correlation coefficient separately.
proc ttest has do it for you automatically.

Ksharp
Occasional Contributor
Posts: 17

## Re: Compare two distribution of correlation coefficient

> It looks like you are perform t-test by useing
> correlation coefficient statistic estimator ?
> If it is, you do not need to calculate the
> correlation coefficient separately.
> proc ttest has do it for you automatically.
>
>
> Ksharp

A ttest will be based only on mean comparison, so it is not my objective. I want to compare a distribution of correlation coefficient to another one distribution of coorelation coefficient .

Say if A is a distribution of (1000) correlation coefficient obtained from corrlation between average scores on a population N and B another distribution of (1000) correlation coefficient obtained from correlation between average scores on a population n (nЄN).

a ttest reject the equality of A and B even if mean A =0.98 and mean B= 0.97?!!

Super User
Posts: 10,210

## Re: Compare two distribution of correlation coefficient

Hi.
How about Wilcox Rank Sum test ? It is assuming A and B both from the same distribution. And it is non-parameter method , which is much robust.

Ksharp
Occasional Contributor
Posts: 17

## Re: Compare two distribution of correlation coefficient

> Hi.
> How about Wilcox Rank Sum test ? It is assuming A and
> B both from the same distribution. And it is
> non-parameter method , which is much robust.
>
>
> Ksharp

Hi,

I used the test also but what I see is that these tests are very sensitive. As I mentionned above even if the two distribution have the same shapes, same means, the test tend to reject the hypothesis of the equality if the two distribution.

Does a quantile test exists? something that compares paired quantiles ?

Thanks,
Super User
Posts: 10,210

## Re: Compare two distribution of correlation coefficient

Hi.
If you want to compare paired quantiles.
You can make another 'difference' variable ( dif = A -B ),then test whether its mean equal zero.
But I am not quit sure this method's power, since you want some exact distribution test.

Ksharp
Super Contributor
Posts: 365

## Re: Compare two distribution of correlation coefficient

I still do not understand why you can not use KS. A null hypothesis for KS is that both samples are drawn from the same distribution. Is not it your purpose?

Sincerely,
SPR
Occasional Contributor
Posts: 17

## Re: Compare two distribution of correlation coefficient

>
> I still do not understand why you can not use KS. A
> null hypothesis for KS is that both samples are drawn
> from the same distribution. Is not it your purpose?
>
> Sincerely,
> SPR

Hi,

Indeed, my purpose is is that both samples are drawn from the same distribution but KS assumption suppose that A and B are independent which is not the case here

Thanks
Regular Contributor
Posts: 171

## Re: Compare two distribution of correlation coefficient

You can use the GLIMMIX procedure to test hypotheses about correlations in dependent data. Below is code to generate variables Y1, Y2, and Y3 with a specified correlation structure. After generating the data, PROC CORR is run to show that the specified correlation structure was actually generated. The data are then written in a form suitable for the GLIMMIX procedure and then the GLIMMIX procedure is invoked with a COVTEST statement to test equality of two of the correlations.

/***********************************/
/* Construct variables Y1, Y2, Y3 */
/* which have covariance structure */
/* */
/* 1 rho12 rho13 */
/* rho12 1 rho23 */
/* rho13 rho23 1 */
/***********************************/
data test;
rho12 = 0.6;
rho13 = 0.6;
rho23 = 0.3;
a11 = 1;
a21 = rho12;
a31 = rho13;
a22 = sqrt(1 - a21**2);
a32 = (rho23 - a31*a21)/a22;
a33 = sqrt(1 - a31**2 - a32**2);
do subject=1 to 10000;
x1 = rannor(1234579);
x2 = rannor(1234579);
x3 = rannor(1234579);
y1 = a11*x1;
y2 = a21*x1 + a22*x2;
y3 = a31*x1 + a32*x2 + a33*x3;
output;
end;
drop rho: a: x:;
run;

/* Compute correlations between Ys */
proc corr data=test;
var y:;
run;

/* Write the data in long form */
/* for use in GLIMMIX procedure */
data test_long;
set test;
y = y1; response=1; output;
y = y2; response=2; output;
y = y3; response=3; output;
run;

/* Obtain correlations using the GLIMMIX procedure */
/* and test whether the rho12=rho13. */
proc glimmix data=test_long;
class subject response;
model y =;
random response / subject=subject residual type=unr;
covtest general 0 0 0 -1 1 0;
run;

Feel free to modify the code to change the correlations. You might also want to change the sample size. I used a very large sample size to demonstrate that the assumed correlations were actually generated.
Discussion stats
• 8 replies
• 510 views
• 0 likes
• 4 in conversation