Error when the same SUBJECT= effect is in both the RANDOM and REPEATED statements in PROC MIXED


If you have a model that includes a REPEATED statement of the form

    repeated / subject=animal type=cs;

then you cannot specify ANIMAL as an effect in a RANDOM statement.

For example, these statements result in an error stating "Convergence criteria met but final Hessian is not positive definite" and at least one of your variance-covariance parameter estimates will likely be equal to zero:

  proc mixed;
     class trt;
     model y=trt;
     random int / subject=animal(trt);   ** or random animal(trt);  
     repeated / subject=animal(trt) type=cs;
  run;

This happens because of the calculation of the V matrix, the variance-covariance matrix for the response variable y. V = Z'GZ + R, where G is the covariance matrix for the random effect, and is defined by the RANDOM statement; Z is the design matrix of your random effects; and R is the covariance matrix defined by the REPEATED statement. The RANDOM statement above sets up a simple variance component G matrix. If R is compound symmetric (TYPE=CS), it can be shown that the resulting V matrix, computed as Z'GZ + R, is also in a form of compound symmetry structure. This implies an overspecification of the covariance model, and often results in a zero variance-covariance estimate and a nonpositive definite final Hessian matrix. Dropping the effect from the RANDOM statement (deleting the RANDOM statement in the above example) solves the problem.

Other structures in the REPEATED statement, such as TYPE=UN, TYPE=TOEP, might also have the same problem, and you would need to drop the effect (the same effect as the SUBJECT= effect in the REPEATED statement) from the RANDOM statement, or change the structure of the REPEATED statement to something like TYPE=AR(1) if this structure makes sense to your data. Generally speaking, if the final Hessian matrix is not positive definite, you might want to consider, among other possible remedies, simplifying your model to remove the confounding in your covariance model.

For more information, see SAS Note 23237.