Gerard E. Dallal, Ph.D.

[The technical details are largely a restatement of the Technical Appendix of Littell RC, Henry PR, and Ammerman CB (1998), "Statistical Analysis of Repeated Measures Data Using SAS Procedures", Journal of Animal Science, 76, 1216-1231.]

**Abstract**

Therandomandrepeatedstatements of SAS's PROC MIXED have different roles. Therandomstatement identifies random effects. Therepeatedstatement specifies the structure of the within subject errors. They are not interchangeable. However, there are overspecified models that can be specified by using arandomorrepeatedstatement alone. Unfortunately, one such model is the commonly encounterd repeated measures with compound symmetry. This has the potential of leading to confusion over the proper use of the two types of statements.

The simple answer to why SAS's PROC MIXED can seem so confusing is that it's so powerful, but there's more to it than that. Early on, many guides to PROC MIXED present an example of fitting a compound symmetry model to a repeated measures study in which subjects (ID) are randomized to one of many treatments (TREAT) and then measured at multiple time points (PERIOD). The command language to analyze these data can be written

proc mixed; class id treat period; model y=treat period treat*period; repeat period/sub=id(treat) type=cs;or

proc mixed; class id treat period; model y=treat period treat*period; random id(treat);

Because both sets of command language produce the correct analysis,
this immediately raises confusion over the roles of the **repeated**
and **random** statements, In order to sort this out, the underlying
mathematics must be reviewed. Once the reason for the equivalence is
understood, the purposes of the repeated and random statements will be
clear.

PROC MIXED is used to fit models of the form

**y**is a vector of responses**X**is a known design matrix for the fixed effects**β**is vector of unknown fixed-effect parameters**Z**is a known design matrix for the random effects**U**is vector of unknown random-effect parameters**e**is a vector of (normally distributed) random errors.

For the repeated measures example,

- y
_{ijk}is response at time*k*for the*j*-th subject in the*i*-th group - μ, α
_{i}, γ_{k}, and (αγ)_{ik}are fixed effects - u
_{ij}is the random effect corresponding to the j-th subject in the i-th group - e
_{ijk}is random error

The variance of y_{ijk} is

The covariance between any two observations is

= σ

Under the assumption of compound symmetry,
cov(e_{ijk},e_{ijn}) is
σ_{e}^{2}+σ, for k=n, and σ_{e}^{2}, otherwise.
It therefore follows that

The model is redundant because σ_{u}^{2} and
σ_{e}^{2} occur only in the sum
σ_{u}^{2} + σ_{e}^{2}, so
the sum
σ_{u}^{2} + σ_{e}^{2} can be
estimated, but σ_{u}^{2} and σ_{e}^{2}
cannot be estimated individually.
The command language file with the
**random** statement resolves the redundancy by introducing the
**u**-s into the model and treating the repeated measures as
independent. The command language file with the **repeated**
statement resolves the redundancy by removing the **u**-s from the
model.

Littel et al. point out that a similar redundancy exists for the unstructured covariance matrix (TYPE=UN), but there is no reduncancy for an auto-regressive covariance structure (TYPE=AR1). In the latter case, both random and repeated statements should be used. See their article for additional details.