Programming the statistical procedures from SAS

Nested random effects in proc mixed

Posts: 0

Nested random effects in proc mixed

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?
Posts: 20

Re: Nested random effects in proc mixed

I posted a similar thread a few months ago but never got a response. My best guess is

random person(class school);
Respected Advisor
Posts: 2,655

Re: Nested random effects in proc mixed


random person(class school)


random person(class*school)

will work.
Regular Contributor
Posts: 169

Re: Nested random effects in proc mixed

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.
Respected Advisor
Posts: 2,655

Re: Nested random effects in proc mixed

Thanks, Dale. That tip should save us a considerable amount of time and effort!
Ask a Question
Discussion stats
  • 4 replies
  • 4 in conversation