I’d always assumed that if the option “order=internal” is used on the PROC MIXED statement, that the rows of an R matrix would be ordered according to the values of the time variable. It turns out that the rows of R have the same order as the time variable in the fixed effects. If “time(ref=first)” is used in the CLASS statement then the first category will be placed in the LAST row of R, as it is for the fixed effects.
The attached SAS program estimates a model using the ARH(1) covariance structure twice, first with “time(ref=first)”, then with “time(ref=last)”. Data are from https://stats.oarc.ucla.edu/wp-content/uploads/2016/02/repeat-1.txt, the model is:
Title1 "arh(1) structure, time(ref=first)";
ods output R=R1;
proc mixed data=long order=internal;
class exertype time(ref=first);
model pulse = exertype time exertype*time / solution;
repeated time / subject=id type=arh(1) R;
run;
ods output close;
Using “time(ref=first)”, I get the following covariance pattern estimates and R matrix:
|
Covariance Parameter Estimates |
||
|
Cov Parm |
Subject |
Estimate |
|
Var(1) |
id |
83.2217 |
|
Var(2) |
id |
120.57 |
|
Var(3) |
id |
35.9136 |
|
ARH(1) |
id |
0.5022 |
|
Estimated R Matrix for Subject 1 |
|||
|
Row |
Col1 |
Col2 |
Col3 |
|
1 |
35.9136 |
13.7881 |
33.0464 |
|
2 |
13.7881 |
83.2217 |
50.3053 |
|
3 |
33.0464 |
50.3053 |
120.57 |
R[1,1] corresponds with Var(3) in the covariance estimates, R[2,2] with Var(1), R[3,3] with Var(2). The order of the TIME variable in the fixed effects is 2, 3, 1 and that order seems to be used for the covariance parameter estimates as well.
The same model using “time(ref=last)” in the class statement produces the following covariance parameter estimates and R matrix:
|
Covariance Parameter Estimates |
||
|
Cov Parm |
Subject |
Estimate |
|
Var(1) |
id |
35.7683 |
|
Var(2) |
id |
87.1927 |
|
Var(3) |
id |
115.50 |
|
ARH(1) |
id |
0.5101 |
|
Estimated R Matrix for Subject 1 |
|||
|
Row |
Col1 |
Col2 |
Col3 |
|
1 |
35.7683 |
28.4861 |
16.7237 |
|
2 |
28.4861 |
87.1927 |
51.1893 |
|
3 |
16.7237 |
51.1893 |
115.50 |
Diagonal values of R now correspond with values for Var(1) to Var(3) from the covariance parameter estimates.
Is this a known "feature" for time variables using repeated measures in PROC MIXED? The R matrix will not be as expected if the default "ref=last" is not used for the time variable and the covariance pattern assumes ordered categories.
Please refer to this usage note:
http://support.sas.com/kb/69066
Especially #2.
As noted in the usage note, a workaround would be to create another variable, such as time1, which is a copy of time, and use time1 in the REPEATED statement. For example,
proc mixed data=long order=internal;
class exertype time(ref=first) time1;
model pulse = exertype time exertype*time / solution;
repeated time1 / subject=id type=arh(1) R;
run;
Hope this helps.
Jill
Please refer to this usage note:
http://support.sas.com/kb/69066
Especially #2.
As noted in the usage note, a workaround would be to create another variable, such as time1, which is a copy of time, and use time1 in the REPEATED statement. For example,
proc mixed data=long order=internal;
class exertype time(ref=first) time1;
model pulse = exertype time exertype*time / solution;
repeated time1 / subject=id type=arh(1) R;
run;
Hope this helps.
Jill
Thanks Jill, for the quick reply with a workaround as well!
April 27 – 30 | Gaylord Texan | Grapevine, Texas
Walk in ready to learn. Walk out ready to deliver. This is the data and AI conference you can't afford to miss.
Register now and save with the early bird rate—just $795!
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.