BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
I want to set up a nested four-level model in proc mixed, say repeated observations within persons within classes within schools. How do I formulate this nesting? Ideally I would do something like:

random school;
random class(school);
"random person(class(school))";

but how to specify this last level?
1 ACCEPTED SOLUTION

Accepted Solutions
Dale
Pyrite | Level 9
The person-specific random effect can be equivalently specified employing a REPEATED statement. Note that the MIXED documentation states with regard to computational issues that "In general, specify random effects with a lot of levels in the REPEATED statement and those with a few levels in the RANDOM statement."

It is well known that a random intercept model results in a within-subject compound symmetric residual covariance structure. Thus, using the advice to employ a REPEATED statement in place of the RANDOM statement, you would want to construct the REPEATED statement to specify TYPE=CS covariance structure.

The MIXED documentation also states "If possible, "'actor out' a common effect from the effects in the RANDOM statement and make it the SUBJECT= effect. This creates a block-diagonal G matrix and can often speed calculations."

Following the above cited recommendations, I would employ the following RANDOM/REPEATED statements:

random intercept / subject=school;
random intercept / subject=class(school);
repeated / subject=person(class*school) type=cs;

The repeated statement can be specified with or without the asterisk between class and school.

View solution in original post

4 REPLIES 4
sfleming
Calcite | Level 5
I posted a similar thread a few months ago but never got a response. My best guess is

random person(class school);
SteveDenham
Jade | Level 19
Either

random person(class school)

or

random person(class*school)

will work.
Dale
Pyrite | Level 9
The person-specific random effect can be equivalently specified employing a REPEATED statement. Note that the MIXED documentation states with regard to computational issues that "In general, specify random effects with a lot of levels in the REPEATED statement and those with a few levels in the RANDOM statement."

It is well known that a random intercept model results in a within-subject compound symmetric residual covariance structure. Thus, using the advice to employ a REPEATED statement in place of the RANDOM statement, you would want to construct the REPEATED statement to specify TYPE=CS covariance structure.

The MIXED documentation also states "If possible, "'actor out' a common effect from the effects in the RANDOM statement and make it the SUBJECT= effect. This creates a block-diagonal G matrix and can often speed calculations."

Following the above cited recommendations, I would employ the following RANDOM/REPEATED statements:

random intercept / subject=school;
random intercept / subject=class(school);
repeated / subject=person(class*school) type=cs;

The repeated statement can be specified with or without the asterisk between class and school.
SteveDenham
Jade | Level 19
Thanks, Dale. That tip should save us a considerable amount of time and effort!

SAS Innovate 2025: Save the Date

 SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!

Save the date!

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
  • 21800 views
  • 1 like
  • 4 in conversation