BookmarkSubscribeRSS Feed
nadra
Calcite | Level 5
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,
8 REPLIES 8
Ksharp
Super User
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
nadra
Calcite | Level 5
> 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

Hi Ksharp, thanks for answering!

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?!!

nadra
Ksharp
Super User
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
nadra
Calcite | Level 5
> 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,
Ksharp
Super User
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
SPR
Quartz | Level 8 SPR
Quartz | Level 8
Hello Nadra,

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
nadra
Calcite | Level 5
> Hello Nadra,
>
> 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
Dale
Pyrite | Level 9
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.

sas-innovate-2024.png

Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.

Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.

 

Register now!

What is ANOVA?

ANOVA, or Analysis Of Variance, is used to compare the averages or means of two or more populations to better understand how they differ. Watch this tutorial for more.

Find more tutorials on the SAS Users YouTube channel.

Discussion stats
  • 8 replies
  • 2982 views
  • 0 likes
  • 4 in conversation