BookmarkSubscribeRSS Feed
Ryan
Calcite | Level 5

Hello,

The following example [along with the actual data] provided in SAS shows how to test for differences in correlation matrices across independent samples using the CONTRAST statement:

http://support.sas.com/documentation/cdl/en/statug/63033/HTML/default/viewer.htm#statug_glimmix_sect...

The actual code to test for differences in correlation matrices between independent samples ("species") is as follows:

   proc glimmix data=iris_univ;
      class species var id;
      model response = species*var;
      random _residual_ / type=unr group=species subject=id;
      covtest 'Equal Covariance Matrices'  homogeneity;
      covtest 'Equal Correlation Matrices' general
           0  0  0  0  1  0  0  0  0  0
           0  0  0  0 -1  0  0  0  0  0,
           0  0  0  0  1  0  0  0  0  0
           0  0  0  0  0  0  0  0  0  0
           0  0  0  0 -1  0  0  0  0  0,
           0  0  0  0  0  1  0  0  0  0
           0  0  0  0  0 -1  0  0  0  0,
           0  0  0  0  0  1  0  0  0  0
           0  0  0  0  0  0  0  0  0  0
           0  0  0  0  0 -1  0  0  0  0,
           0  0  0  0  0  0  1  0  0  0
           0  0  0  0  0  0 -1  0  0  0,
           0  0  0  0  0  0  1  0  0  0
           0  0  0  0  0  0  0  0  0  0
           0  0  0  0  0  0 -1  0  0  0,
           0  0  0  0  0  0  0  1  0  0
           0  0  0  0  0  0  0 -1  0  0,
           0  0  0  0  0  0  0  1  0  0
           0  0  0  0  0  0  0  0  0  0
           0  0  0  0  0  0  0 -1  0  0,
           0  0  0  0  0  0  0  0  1  0
           0  0  0  0  0  0  0  0 -1  0,
           0  0  0  0  0  0  0  0  1  0
           0  0  0  0  0  0  0  0  0  0
           0  0  0  0  0  0  0  0  -1 0,
           0  0  0  0  0  0  0  0  0  1
           0  0  0  0  0  0  0  0  0 -1,
           0  0  0  0  0  0  0  0  0  1
           0  0  0  0  0  0  0  0  0  0
           0  0  0  0  0  0  0  0  0 -1 / estimates;
   run;


I would like to adjust this code such that the correlation matrices are being compared between DEPENDENT samples (e.g., same sample measured twice). Any help would be MUCH appreciated.

Thanks,

Ryan

p.s. I've asked this same question on SAS-L. Apologies to those who read/respond to questions on SAS-L and here.

3 REPLIES 3
SteveDenham
Jade | Level 19

Hi Ryan,

Read it there and here, and I still don't have a real good answer, so let's torture the data until it surrenders :smileysilly:

When you think about this as a repeated measures analysis, what happens?

For example, would the following work?

proc glimmix data=iris_univ;

      class species var id measurement;

      model response = species*var*measurement;

      random _residual_ / type=unr group=species subject=id;

     random measurement/residual type=chol group=measurement subject=id;

      covtest 'Equal Covariance Matrices'  homogeneity;

Now comes the really FUN part (because I worry that this might not be what is needed).  Using a GENERAL option to compare across measurements, while maintaining the species structure that you gave.  i will "leave this as an exercise for the reader" for a couple of reasons--I'm pressed for time today, and, well, it's going to be hard and I'm never really good at writing out contrast statements.

Steve Denham

Message was edited by: Steve Denham

Ryan
Calcite | Level 5

Steve,

Thanks for responding. I think it is worth clarifying that "species" reflects independent groups. My question is how to compare the correlation matrices across two sets of measurements (e.g., taken at two time points) from the same sample. Assuming three variables and two time points, the dataset should look like this in vertical format:

ID  Time  Variable   Response

1      1          1             10

1      1          2             34

1      1          3             16

1      2          1             22

1      2          2             23

1      2          3             13

2      1          1             27

2      1          2             11

2      1          3             14

2      2          1             10

2      2          2             22

2      2          3             24

.

.

.

Which could be parameterized in GLIMMIX as follows (according to the link provided previously):

proc glimmix data=mydata;

      class ID Time Variable;

      model response = Time*Variable;

      random _residual_ / type=unr /*group=Time*/ subject=ID;

run;

The reason I've greyed out "group=Time" on the RANDOM statement is that while it will allow for the test between correlation matrices across different time points (using the COVTEST statement), it assumes that the measurements between time points are not correlated. I'm not sure if and what the second RANDOM statement should be written as.  And, once I add the second RANDOM statement, the COVTEST will become particularly complicated and perhaps will render the test for differences between correlation matrices impossible.

Does this help clarify my question?

Ryan

SteveDenham
Jade | Level 19

Ryan,

Working from the statement "it will allow for the test between correlation matrices across different time points (using the COVTEST statement), it assumes that the measurements between time points are not correlated", I would think that adding the second random statement specifying the correlation structure between time points addresses the assumption.  And I agree that the COVTEST statement will become particularly complicated.  It is why I ran away and hid from it last week (and to catch a plane).  It looks like all you would need to do, though, is systematize the matrix in the COVTEST statement using the general option.

Steve Denham

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
  • 3 replies
  • 1845 views
  • 0 likes
  • 2 in conversation