BookmarkSubscribeRSS Feed
☑ This topic is solved. Need further help from the community? Please sign in and ask a new question.
Abishekaa
Obsidian | Level 7

This is a sample dataset: Each patient has multiple glucose levels that are categorized into episodes based on the time that glucose test date. Eg: Patient 2 has 3 glucose readings, the first two (80,85) carried out on the same day - therefore it is one episode. The third reading (160) carried out another day - hence its the second episode. 

ID Glucose episode
1    140         1
1    145         2
2    80          1 
2    85          1
2    160         2

1) I would like to fit a variance component mode to identify variability within & across episodes, and across patients.  I have tried the below code, and also using 'subject=episode(ID)' since the episodes are nested within each ID. Could you please explain what would be the best way to fit this model / if this is the right direction?

 

proc mixed data=test;
class ID episode;
model glucose = ;
random int episode/subject=ID;
run;
1 ACCEPTED SOLUTION

Accepted Solutions
SteveDenham
Jade | Level 19

Looks good - you should probably add the SOLUTION option to your RANDOM statement.

 

SteveDenham

View solution in original post

4 REPLIES 4
SteveDenham
Jade | Level 19

Looks good - you should probably add the SOLUTION option to your RANDOM statement.

 

SteveDenham

Abishekaa
Obsidian | Level 7

Hi Steve, Thank you! Could you please explain how the above code takes nesting into account? And, how would the model differ from using the below code?

 

proc mixed data=test;
class ID episode;
model glucose = ;
random int /subject=episode(ID);
run;
SteveDenham
Jade | Level 19

This code fits two variance components:

 

random int  episode/subject=ID

and is equivalent to:

 

random ID episode*ID;

While this code fits one variance component 

 

random int /subject=episode(ID)

and is equivalent to

 

random episode*ID;

The key here is that the matrix representation of nested effects is identical to the matrix representation of crossed effects (see the documentation of the RANDOM statement).

 

It comes down to partitioning the variability between ID and episode*ID, with the remainder, if any, in the residual.  All of this is going to be very data dependent.

 

SteveDenham

 

 

 

 

Abishekaa
Obsidian | Level 7
Thanks so much for the clear explanation, Steve. This is extremely helpful!

SAS Innovate 2025: Call for Content

Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!

Submit your idea!

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
  • 4 replies
  • 860 views
  • 2 likes
  • 2 in conversation